Is it necessary to play sounds that were loaded with media:newEventSound(soundfile)

Is it necessary to play sounds that were loaded with media:newEventSound(soundfile) via timer.performWithDelay instead of playing them directly?

As in the documentation:

local soundID = media.newEventSound( "beep.caf" )  
   
local playBeep = function()  
 media.playEventSound( soundID )  
end  
timer.performWithDelay( 1000, playBeep, 0 )  

Is this also possible?

local soundID = media.newEventSound( "beep.caf" ) media.playEventSound( soundID ) [import]uid: 295 topic_id: 1500 reply_id: 301500[/import]

Dan,

both are valid.

One thing I noticed is that in the simulator, playing a sound the first time can cause an slight hang up.
On the device everything runs fine. I use the 2nd approach you posted, but I first load them and then during the game I just play them. I hope you don’t load them everytime you are playing them.

Cheers
Michael Hartlef

http://www.whiteskygames.com
http://www.twitter.com/mhartlef [import]uid: 5712 topic_id: 1500 reply_id: 4221[/import]

Yeah, I noticed that in the simulator, playing a sound the first time can cause an slight hang up. So I immediately tried it on the device to see if the same thing would happen but it didn’t. I’ve heard many time that if something doesn’t run as expected on the simulator to make sure to try it on the device too. The simulator & device are different, especially when it comes to timing issues.

Also I preload all my sounds at the very beginning in the setup/initialization code.

Thanks [import]uid: 295 topic_id: 1500 reply_id: 4224[/import]