使用VideoView,如何删除“无法播放此视频”?警报消息? [英] Using VideoView, how to remove "can't play this video" alert message?
问题描述
我们的应用播放了一组视频,有时我们无法播放此视频警报消息。
Our app plays a set of videos, sometimes we are getting can't play this video alert message.
我们正在播放sd卡中的视频或流式播放该视频尚未下载。通常,在互联网连接速度较慢的情况下进行流式传输时会出现错误。
We are either playing video from sd card or streaming if that video is not yet downloaded. Mostly, error arises while streaming with slow internet connection.
通过阅读一些帖子和博客,我几乎看不到该错误的原因。
I understood few causes of this error from reading some posts and blogs.
但是,现在我想在发生错误时播放下一个视频而不显示该错误消息。
But, now I want to play the next video when the error occurs without showing that error message.
我为此使用了以下侦听器,
I used the below listener for that ,
video.setOnErrorListener(new OnErrorListener() {
@Override
public boolean onError(MediaPlayer mp, int what, int extra) {
Log.d("video", "setOnErrorListener ");
return false;
}
});
该方法在错误发生时被调用,但不能停止显示该警报消息。
Method got invoked when the error arises, but can't stop showing that alert message.
有没有办法停止显示该警报消息?
Is there any way to stop showing that alert message?
预先感谢。
推荐答案
返回 false
或没有 OnErrorListener
完全会导致调用 OnCompletionListener
。
Returning false
or not having an OnErrorListener
at all will cause the OnCompletionListener
to be called.
因此返回 true
而不是函数中的 false
,不会显示任何错误,即
So return true
instead of false
from the function and no error will be shown, i.e.
video.setOnErrorListener(new OnErrorListener() {
@Override
public boolean onError(MediaPlayer mp, int what, int extra) {
Log.d("video", "setOnErrorListener ");
return true;
}
});
有关更多信息,请参见 Android文档
For more info see Android Document
这篇关于使用VideoView,如何删除“无法播放此视频”?警报消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!