Hey, all. My game is nearly finished and runs indefinitely on the Player, but crashes randomly on Android devices. One one test device (Kindle Fire) each sound stops a split second before the end, but on other devices they play to the end. When testing in Eclipse on my phone the only hint in the LogCat are numerous instances of this warning:
02-26 17:11:38.350: W/MediaPlayer(3440): mediaplayer went away with unhandled events
I've triple checked that the cases match between the files and the references in the project, and the function I use to play sounds checks for the existence of a file before trying to create a sound with it, so I can put in code like play_sound("no_such_file.mp3") without causing a crash.
Any other ideas of what could cause the mediaplayer error?
PaulH
Comments
Are there any other compressed sound formats that are more reliable than mp3? If not, is there a minimum length at which an mp3 file can be used safely?
PaulH
http://www.giderosmobile.com/forum/discussion/331/what-is-the-best-sound-format
Based on that I think I'll keep all speech, music and looping sounds in mp3 (which is most of them) and convert the others (general sound effects) to wav. I'll see if that helps. As long as it doesn't crash I can find ways to deal with performance issues, avoiding having too many concurrent sounds, maybe adding a fraction of a second of silence on the end of speech to prevent the clipping, etc.
Thanks again for the reply.
PaulH
http://benbritten.com/2010/05/04/streaming-in-openal/
Playing lots of MP3 files simultaneously may exhaust the number of sound buffers allowed?
So my guess (assuming Gideros actually uses OpenAL) is MP3 files are handled completely different from WAV files even if they are the same sound and the MP3 is short. In that case its a good idea to convert to WAV. If you have thousands of short sounds, perhaps put them all together would help?
https://github.com/gideros/gideros
https://www.youtube.com/c/JohnBlackburn1975
I've just converted all the sounds under 2 seconds long to 16 bit mono wav format. Many of the others are segments of conversations. In the Windows version I kept them in separate files so the code could know which character's mouth to animate depending on the file that's playing. For the mobile version the faces aren't visible during speech, so I'm combining each conversation into a single mp3, 44100 Hz, 48 kbps, mono format. Time to try it on the phone...
Previously, I've also tried libmpg123+OpenAL on iOS and Android but it consumes too much CPU power and therefore I've decided to use the methods provided by the OS (and hoped that they're efficient and using specialised hardware).
In the future, I want to provide 3 different methods (independent of the file format) so that experienced users can choose the most appropriate one:
- sample: load all sound data to the memory and play
- stream: load and play in small fragments with queue buffers
- background: use OS provided methods where available and if not available (such as desktop) fallback to stream.
https://github.com/gideros/gideros
https://www.youtube.com/c/JohnBlackburn1975