Search code examples
androidandroid-mediaplayer

Android MediaPlayer fails (status 0x80000000) when calling prepare (local mp3 file)


I've finished developing a game, but it's very annoying that sometimes (yes, only sometimes!) when I open it, it fails, and I can see in logcat this error: java.io.IOException: Prepare failed.: status=0x80000000.

It's very weird because it's a local file (2MB mp3 file), and I don't know why it shows a IOException. And only sometimes, not always...

EDIT: It seems that is related with proguard, because it only happens with release version...


Solution

  • I finally solved it.

    It happened because my MediaPlayer variables were static, so when I restart the app I was creating more MediaPlayers without releasing previous ones, and there is a limit of 8 (at least in Android 2.3.6, where I tested it). Calling mediaPlayer.release() (if mediaPlayer != null, of course) it's solved.

    Hope it helps someone.