Michel (Starnut) Posted February 15, 2014 Share Posted February 15, 2014 Hey guys, has anyone encountered glitches or even complete game freezes based on audio playback with Phaser 1.1.4? I'm playing back short WAVs in the course of my game and every once in a while the game freezes up completely for half a second or so on an iPhone 4S iOS7. It's not as tremendous on an iPhone 5 with iOS7 but still glitching. Feels like a garbage collector is getting to work there. I was able to track the issue back to audio playback since no freeze appears if I turn it off. Also, I tested on my iPad1 and (apart from the fact that Safari under iOS 5.1.1 doesn't manage do actually play the sound) I could see the game slowing down every time sound playback was triggered. The whole game runs smoothly with sound playback turned off, though. Here is the code I use:// create sounds and stack themthis.sounds.push(this.game.add.audio("someAudio", 1, false));// ... later in the game, play themthis.sounds[i].play('', 0, volume, false, true);Am I missing something? Is there a proper way to reuse sounds without filling up memory? Link to comment Share on other sites More sharing options...
AllanRW Posted February 15, 2014 Share Posted February 15, 2014 I dont use phaser, but you need to convert your wav file to m4a format to play on ios safari, and if you have the option, preload the sound first. Also, the user must touch first to activate sounds. Link to comment Share on other sites More sharing options...
rich Posted February 15, 2014 Share Posted February 15, 2014 Sound preloading and touch activation is all handled automatically, but I agree the audio file ought to be in a format native for iOS and at a bitrate suitable for mobile. Link to comment Share on other sites More sharing options...
Michel (Starnut) Posted February 15, 2014 Author Share Posted February 15, 2014 Thanks, guys. Don't get me wrong, though: the wav samples do play fine on iOS 6/7 just the mem fills up apparently. But I'll go with m4a then. Which format is best for android devices? Ogg?@rich: actually I chose wav cause you mentioned in some thread that it's great for short samples because it doesn't need decoding. Any bit rates you can recommend? Or is it just try&error? Have little experience with audio. Link to comment Share on other sites More sharing options...
Zaidar Posted February 15, 2014 Share Posted February 15, 2014 I just "finished" a game using sound and I tested on my Android 4.4, the .wav sounds work. Link to comment Share on other sites More sharing options...
Michel (Starnut) Posted February 15, 2014 Author Share Posted February 15, 2014 It actually works fine on my 1st gen Nexus7 with 4.2. I was just wondering what the *best* format was. Link to comment Share on other sites More sharing options...
rich Posted February 15, 2014 Share Posted February 15, 2014 I still mostly use wav for short sounds outside of iOS as it seems to work great on Android. On iOS I encode to m4a though, anything possible to help reduce decoding time really. It's definitely not "normal" for the game to pause like that though, so it must be working overtime doing something (decoding audio possibly) Link to comment Share on other sites More sharing options...
Michel (Starnut) Posted February 16, 2014 Author Share Posted February 16, 2014 So for Chrome on iOS you'd rather go with m4a as well? Link to comment Share on other sites More sharing options...
Recommended Posts