Sometimes the MP3 plays. Sometimes it doesn't

Anyone getting this?
Any ideas on forcing playback?

While on the topic of audio, has anyone gotten an estimation on the results of of the size/speed tradeoff if subbing a (preferably low res) wav file for music instead of mp3?

I found a solution for getting the engine to allow MP3s to keep playing – see the Enhancement Pack thread.

The phone can only play one compressed file at a time, and if that happens to be an MP3 or AAC file, your game’s compressed sounds won’t get played. So uncompressed audio is a better bet. Apple recommends 16-bit linear PCM in a CAF file for uncompressed audio, and IMA/ADPCM IMA for compressed audio. You can use /usr/bin/afconvert to convert audio.

I vaguely remember using WAV files in an early build of my first game, but I don’t remember how reliable that was. Must have been some trouble if I switched to CAF.

I had an issue with the mp3 music in my app not playing automatically if I relied on “play on awake”, and just loaded the scene through Application.LoadLevel(). Sometimes it seemed to fail to start the audio due to loading too much stuff at once… but it wasn’t reproducible. If this sounds familiar, you may want to just manually use Audio.Play(), which I’ve had no issues with yet.

I had the same problem and solution that PirateNinjaAlliance had. When I relied on the “Play On Awake” checkbox for the MP3 audio source, I would occasionally not get music. I was never able to get it to reproduce 100% of the time, but handling the starting of the audio through the scripts seemed to fix my problems.

Excellent, thanks.

Well, it looks like the problem is still there.
There is only one compressed sound loaded.
Whether it audio.Play() function calls it at any given point or it’s loaded at startup, I cannot get any of three MP3’s I’ve tried to consistently play.

Any suggestions?
Play on Awake is not enabled.

Upon reading through documentation, I came to the conclusion that compressed audio on the iPhone was not supported and therefore am using .wav audio for all sfx.

Are you guys implying that is not true and there is a way to reliably play back .mp3s?

We had the same issue with unreliable playback where 1/2 of the time it played and half of the time it did not (with .mp3s)

We’ve used mp3s for all the background music in Crazy Snowboard. Initially we were seeing the same problems that you describe, but we fixed it by doing the following:

  • Start your game with a near empty ‘Splash’ scene (we do this for all our games to initialize persistent objects like game state controls, menu managers, etc)
  • Add an audio source with an mp3 (any mp3) and set Play on Awake to true and the Volume to 0 (this is just an audio preloader which catches the problem of the first mp3 only playing 50% of the time - but since the volume is 0 it doesn’t matter if it plays or not)
  • Load your second scene immediately (or pause for a few secs if your splash scene shows a game logo or something similar)
  • Make sure you only have one mp3 playing/loaded in any one scene
  • Use WAVs for all your soundFX

Another added bonus of having a barebones splash scene at the start is that your app will load much quicker than if your first scene is a large one.

That seems along the lines of what I was going to do.
Start with a ‘dummy’ audio clip, then move on to the actual one.
I appreciate the input.

BTW anyone know of a good utility to capture video from the editor?

Snapz Pro is the best IME (in my experience… did I just make that one up?)

Whether you made it up or not, I’m going to go use it elsewhere on the web and pretend I made it up.

Let’s see the projects you’re working on. :stuck_out_tongue:

jk, of course. :shock:

Throwing a dummy compressed sound in as the first audio clip seems to work perfectly. Thanks again for the feedback.

I had the exact same issue. Finally fixed it by de-selecting 3D sound option.