Forums » Community Projects

proper loading and playing of audio

Aug 11, 2014 jen@arvig.net link
Looking at playing around with a /plugin and thought to ask here about a issue I am haing loading and playing a .ogg file as a verbal prompt in game. I am new to lua so be gental :)

errors out that it could not load the offline.ogg -and- naturally a play error when called apon

I load the audio with this i hope:

gksound.GKLoadSound{soundname='aye_sir,filename='aye_sir.ogg'}

And call it like this after a print output, again i hope

print("Aye Sir!")
gksound.GKPlaySound("aye_sir");

The one thing I know is that its not the .ogg file since i did a swap with within the /honk plugin and it plays without issue.

Its syntax or a location of the loading audio code..

A some what related question... would it be advisable for someone to load lets say 1mb worth of .ogg audio clips and call as needed -or- just load > play > offload as needed?
Aug 11, 2014 meridian link
I see two problems with your gksound.GKLoadSound code:
1) your soundname string is missing a closing apostrophe
soundname='aye_sir,filename=... s/b soundname='aye_sir',filename=...
2)You should put your sounds in the plugin directory they are used with.
e.g. filename='plugins/MyPlugin/aye_sir.ogg'

Keeping the sounds in the top-level directory makes things a bit disorganized.

As far as I know, there isn't a way to offload sounds. Once you call GKLoadSound{} the sound persists until you close the client (even reloading the interface doesn't unload sounds). You also cannot replace an existing sound with GKLoadSound{}; a unique soundname is needed each time it is called.