Video View error displays "Can't Play this video" again and again Video View

I played a video in video view in android. I can't stop this alert "Can't Play this video". I need to change the alert "Sorry! Unable to play the video due to user has stopped his live stream"

I used following code

 mStreamVideo.setOnErrorListener(new MediaPlayer.OnErrorListener() {
       @Override
       public boolean onError(MediaPlayer mp, int what, int extra) {
           return true;
       }
   });

Upvotes: 0

Views: 879

Answers (1)

V-rund Puro-hit
V-rund Puro-hit

Reputation: 5534

Here try this way...

mStreamVideo.setOnErrorListener(new MediaPlayer.OnErrorListener() {

    @Override
    public boolean onError(MediaPlayer mp, int what, int extra) {
        AlertDialog.Builder build = new AlertDialog.Builder(this);
        build.setPositiveButton("OK", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {

            }
        });
        AlertDialog alt = build.create();
        alt.setMessage("Sorry! Unable to play the video due to user has stopped his live stream");
        alt.show();
        return true;
    }
});

Upvotes: 1

Related Questions