Android MediaPlayer 警告:应该已经设置了字幕控制器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20166186/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 02:24:13  来源:igfitidea点击:

Android MediaPlayer warning: Should have subtitle controller already set

androidandroid-mediaplayer

提问by PFort

My Nexus 4 got upgraded to 4.4 and now whenever MediaPlayer plays a sound, I get the warning:

我的 Nexus 4 升级到 4.4,现在每当 MediaPlayer 播放声音时,我都会收到警告:

Should have subtitle controller already set

And also when calling mp.release()I now get the warning

而且在打电话时mp.release()我现在收到警告

mediaplayer went away with unhandled events

The same app on a Nexus 7 with 4.3 doesn't display these warnings.

Nexus 7 4.3 上的同一个应用程序不会显示这些警告。

回答by Ganesh

In Android 4.4kitkat, there is a new feature which supports WebVTTfor HLSwhich has introduced some changes in MediaPlayer. (Reference: Kitkathighlights- Closed Captions)

Android 4.4kitkat,没有支持新的功能,WebVTTHLS它推出了一些变化MediaPlayer。(参考:Kitkat亮点- 隐藏字幕)

From your description of the error, it looks like the actual player engine is not invoking setSubtitleAnchoras VideoViewis doing here. This leads to the error message from another method herewhich is invoked as part of the preparestate transition before invoking the listener.

从你的错误的描述,它看起来像实际的播放引擎不调用setSubtitleAnchor因为VideoView是做在这里。这会导致此处另一个方法的错误消息prepare在调用侦听器之前作为状态转换的一部分被调用。

P.S:Is your player a custom player or a standard player which comes pre-bundled as part of the Androiddistribution? Can you share any further logs?

PS:您的播放器是自定义播放器还是作为发行版一部分预先捆绑的标准播放器Android?你能分享更多的日志吗?

回答by DroidShout

mp.reset();
mp.release();

That should help you get rid of the second warning

这应该可以帮助您摆脱第二个警告