How to catch “Sorry, This video cannot be played” error on VideoView

后端 未结 4 2058
执念已碎
执念已碎 2021-01-01 08:49

I have a VideoView and I am streaming videos from a remote server. Most of the times It would play the videos very smoothly. But sometimes, it displays an error message \"So

4条回答
  •  情话喂你
    2021-01-01 09:34

    I prefer setting listeners like this within onCreate method. Hopefully helps someone out

    videoView.setOnErrorListener(new OnErrorListener () {
        @Override
        public boolean onError(MediaPlayer mp, int what, int extra) {
            Log.e(TAG, "Error playing video");
            return true;
        }
    });
    

提交回复
热议问题