23

The bug I'm seeing is on the calls to reset() and release() never returning thus leaving my application in an indefinitely stopping state. It doesn't matter if I call stop() before reset() or release() the hang can always be reproduced.

Anyone experienced any similar issues with the MediaPlayer locking up? Any tips? I'm working on a multi-threaded application.

The DDMS reports the following when looking at the threads that are holding:

CLASS | METHOD | FILE | LINE | NATIVE

android.media.MediaPlayer _release MediaPlayer.java -2 true
android.media.MediaPlayer release MediaPlayer.java 1049 false

Jona
  • 13,325
  • 15
  • 86
  • 129
  • I also got this problem. Is there any solution to fix it? – Judy Aug 25 '17 at 08:36
  • @Judy we never found a fix. We tried a lot of combinations and hacks. We finally moved away from using the Android top level media APIs. Not recommended for everyone but in our case we needed full control of playback so we build our player from scratch. – Jona Sep 05 '17 at 15:24

4 Answers4

8

You may have stumbled across this bug: http://code.google.com/p/android/issues/detail?id=959. It has sat for some time, I wouldn't expect it to be addressed any time soon, unfortunately.

skyler
  • 8,010
  • 15
  • 46
  • 69
1

If you are developing for API level 16 or above, I strongly suggest you toss the crappy MediaPlayer and use Exoplayer from Google.

I did and never looked back. Since I also support API level 15, I have an abstraction to use the standard MediaPlayer when in that API and Exoplayer when in 16 (or 17 can't remember now).

It's not perfect, but it's a lot better and I've seen much much better buffering.

Martin Marconcini
  • 26,875
  • 19
  • 106
  • 144
0

If you're simply trying to start the song/sound from the beginning, you can write a reset function, that simply does:

mediaplayer.seekTo(0);

I changed my stop(); to: pause, then seekTo.

user
  • 86,916
  • 18
  • 197
  • 190
0

I also face this issue in android 2.2, when calling MediaRecorder.release();

Sometime it didn't response, my program flow just stuck on it. it cause my UI freeze, and bring ANR later....

BTW, my customer says that they didn't face it when using android 2.3.3

This: http://code.google.com/p/android/issues/detail?id=959#makechanges

And this: http://code.google.com/p/android/issues/detail?id=5047#makechanges

RRTW
  • 3,160
  • 1
  • 35
  • 54