Need confirmation about my litte sound "library"

Hi,

at the moment i am struggeling a little bit with the corona sound. First i tried only the audio.* library which worked very well on iOS but on Android i have a unacceptable lag. So i read in the forum that i have to use the media.* library for Android. I tried it and there is no lag anymore. Because i want to use mp3 for my audio i wrote a little library which automatically uses the correct audio lib for the different OS. If i use the lib everything seems to work very well. Because it is the first time i use sounds it would be very nice if you could confirm that my little lib is ok. All recommendations are welcome :slight_smile:

Of course isAndroid and isSimulator are set in the main.lua like:

myClass.isAndroid = “Android” == system.getInfo(“platformName”)
myClass.isSimulator = “simulator” == system.getInfo(“environment”)

Thanks,

Thomas

local M = {} M.isAndroid = false M.isSimulator = false function M:newSound(path) local soundId if M.isAndroid or M.isSimulator then soundId = media.newEventSound( path ) -- for Android else soundId = audio.loadSound( path ) end return soundId end function M:playSound(handle) if M.isAndroid or M.isSimulator then media.playEventSound( handle ) else audio.play(handle, { channel=audio.findFreeChannel()}) end end function M:disposeSound(handle) if M.isAndroid or M.isSimulator then handle = nil else audio.stop() audio.dispose(handle) handle = nil end end return M

That looks reasonable.

Rob

Thanks Rob.

Is there any equivalent in the media.* api for audio.dispose?

Not that I know of.

That looks reasonable.

Rob

Thanks Rob.

Is there any equivalent in the media.* api for audio.dispose?

Not that I know of.