简体   繁体   English

使用reset()和release()调用时出现Android MediaPlayer错误

[英]Android MediaPlayer bug when using reset() and release() calls

The bug I'm seeing is on the calls to reset() and release() never returning thus leaving my application in an indefinitely stopping state. 我看到的错误是调用reset()和release()永远不会返回,从而使我的应用程序处于无限停止状态。 It doesn't matter if I call stop() before reset() or release() the hang can always be reproduced. 如果我在reset()或release()之前调用stop()并不总是可以重现挂起。

Anyone experienced any similar issues with the MediaPlayer locking up? 任何与MediaPlayer锁定有任何类似问题的人? Any tips? 有小费吗? I'm working on a multi-threaded application. 我正在研究一个多线程应用程序。

The DDMS reports the following when looking at the threads that are holding: 查看正在保留的线程时,DDMS会报告以下内容:

CLASS | CLASS | METHOD | 方法| FILE | 文件| LINE | LINE | NATIVE NATIVE

android.media.MediaPlayer _release MediaPlayer.java -2 true android.media.MediaPlayer _release MediaPlayer.java -2 true
android.media.MediaPlayer release MediaPlayer.java 1049 false android.media.MediaPlayer发布MediaPlayer.java 1049错误

You may have stumbled across this bug: http://code.google.com/p/android/issues/detail?id=959 . 您可能偶然发现了这个错误: 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. 如果您正在为API级别16或更高级别开发,我强烈建议您折腾蹩脚的MediaPlayer并使用Google的Exoplayer

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). 由于我也支持API级别15,因此在16和16时(或17现在不记得)时,我在该API和Exoplayer中使用标准MediaPlayer是抽象的。

It's not perfect, but it's a lot better and I've seen much much better buffering. 它并不完美,但它好多了,而且我看到了更好的缓冲。

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(); 我改变了我的stop(); to: pause, then seekTo. to:暂停,然后搜索。

I also face this issue in android 2.2, when calling MediaRecorder.release(); 我在android 2.2中也遇到了这个问题,当调用MediaRecorder.release()时;

Sometime it didn't response, my program flow just stuck on it. 有时它没有响应,我的程序流程只是坚持它。 it cause my UI freeze, and bring ANR later.... 它导致我的UI冻结,并在以后带来ANR ....

BTW, my customer says that they didn't face it when using android 2.3.3 顺便说一句,我的客户说他们在使用android 2.3.3时没有面对它

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM