Android MediaPlayer bug when using reset() and release() calls

和自甴很熟 提交于 2019-12-03 04:36:13

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.

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.

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

Sayallenthing

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!