Question

I'm just asking this question, because I can't find any info on the internet about it, probably because it's a rare case.

Problem is that I have a piano app that uses multiple MediaPlayers to play mp3 samples. It's the only way to get fast response and not having to load them all to memory like in a soundpool, or resorting to a native code synth.

It works great, and I don't have any problems on normal android devices. However, on the Amazon Kindle Fire (first edition) I get strange noises after I play several keys. It looks like the MediaPlayer native implementation somehow has some bugs. I don't get real errors, but sounds are cut-off or make garbled strange rendering noises. This ofcourse makes my users unhappy, and leaves me with a low rated app.

I tried switching rendering engines by using .ogg samples. These work great, no strange noises anymore, but they too are cut-off, making it not a very good replacement.

The only lead I found was some error message, I do sometimes get, about invalid data. I'll try to see if I can fix that one, but I am afraid it has nothing to do with it.

Anyone encountered similar issues on the Kindle Fire (or maybe other platforms)?

Update It seems that the strange errors that sometimes popped up about incorrect data are indeed causing this. I am using AssetFileDescriptors to load raw resource files. This is exact the same stuff that MediaPlayer.create(R.raw.mp3file) does. I just tested with the samples on the sdcard, and now I don't get any strange audio issues. So, I think I'll actually can solve this. :)

Was it helpful?

Solution

Well, the solution is a very simple one. And I also understand now why it is not encountered much.

I found out that I did not copy the MediaPlayer.create(R.raw.resid) source completely. I forgot to close the AssetFileDescriptor after each use, and did just reuse them. Somehow that is not a good practice, and switching to closing them fixed it!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top