Using VideoView, how to remove “can't play this video” alert message?

笑着哭i 提交于 2019-12-12 08:19:40

问题


Our app plays a set of videos, sometimes we are getting can't play this video alert message.

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?

Thanks in advance.


回答1:


Returning false or not having an OnErrorListener at all will cause the OnCompletionListener to be called.

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;
    }
});

For more info see Android Document



来源:https://stackoverflow.com/questions/24380070/using-videoview-how-to-remove-cant-play-this-video-alert-message

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