media.playEventSound() plays only once in win emulator

I’m trying to work around the audio.play() lag issue by using media.playEventSound(), as recommended by numerous posts here and on the net.  My problem is that if I load a sound using media.newEventSound(), I can only play it once using media.playEventSound() when I’m using the Windows emulator.  I pre-load the sound using:

[lua]

sound_handle = media.newEventSound(sound_filename)

[/lua]

And then later…
 

[lua]

media.playEventSound(sound_handle)

[/lua]

The second time playEventSound() is called with the same sound_handle no sound will be played.

If I do instead:

[lua]

media.playEventSound(sound_filename)

[/lua]

each time it works fine, but it causes the same sound latency I’m trying to avoid, and I’m concerned about whether this is loading the sound over and over, eating memory.

As I mentioned before this happens only in the Windows emulator.  The sounds work correctly when I install the apk on my Rezound.  (There’s still a little sound lag, but not as bad as with audio.play()).

Has anyone else had this problem, and even better, know how to fix it?

  • Adam

i saw that too, when profiling media.* vs audio.* latency.  i’m no longer using media.*, but what i did for testing purposes was put in something like this:

if (system.getInfo("environment") == "simulator") then -- reload newEventSound here, then simulator WILL play it again end -- playEventSound here

i saw that too, when profiling media.* vs audio.* latency.  i’m no longer using media.*, but what i did for testing purposes was put in something like this:

if (system.getInfo("environment") == "simulator") then -- reload newEventSound here, then simulator WILL play it again end -- playEventSound here