How to get around media.playSound() lagging the game at first call?

I am testing on an iPhone 3g, and using media.playSound(), the game freezes for a half second, and then continues on while playing the music.

The suggestion in the Corona docs say to do this to preload the music:

media.playSound( ‘sound.mp3’ )
media.stopSound()

This sort of helps if you have only one music file that will play, but I have 4 songs that I would like to be able to pick from to play randomly. When I use the above code on all 4 songs before the game starts, and then pick a random one to play, it lags the game for a half second. Though, in the case that the random song happens to be the last one on the list of songs loaded, the freeze is not near as long.

The effect is undesirable. Does anyone have any other ideas around this?

Thanks! [import]uid: 8541 topic_id: 2599 reply_id: 302599[/import]

I think until this bug is fixed, it’s best to just have your song-switching on a screen where constant animation isn’t going on (such as a pause screen or options panel), that way users don’t notice much (if any) lag since they aren’t in-game at the moment. [import]uid: 7849 topic_id: 2599 reply_id: 7389[/import]