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

17,019

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

Share:
17,019

Related videos on Youtube

Sreedhu Madhu
Author by

Sreedhu Madhu

Updated on September 15, 2022

Comments

  • Sreedhu Madhu
    Sreedhu Madhu over 1 year

    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.

  • Sreedhu Madhu
    Sreedhu Madhu almost 10 years
    still getting alert message
  • Daniel Maclean
    Daniel Maclean over 8 years
    Works a treat. I found this a great fix for simulators where playing MP4 files on certain versions of Android would throw this error. The MP4 file in question was being used as a splash screen.
  • Kairi San
    Kairi San about 8 years
    how can you prevent to display 'can't play this video' alert message? i mean how will the video will play and the alert message will not show? it only doesn't show the alert message.