@Override public void onShowCustomView(View view, CustomViewCallback callback) { super.onShowCustomView(view, callback); if (view instanceof FrameLayout){ FrameLayout frame = (FrameLayout) view; if (frame.getFocusedChild() instanceof VideoView){ VideoView video = (VideoView) frame.getFocusedChild(); frame.removeView(video); a.setContentView(video); video.setOnCompletionListener(this); video.setOnErrorListener(this); video.start();
@Test public void shouldSetOnErrorListener() throws Exception { TestErrorListener l = new TestErrorListener(); view.setOnErrorListener(l); ShadowVideoView shadowVideoView = shadowOf(view); assertThat(shadowVideoView.getOnErrorListener()).isSameAs(l);
mVideoPlayer.setOnErrorListener(new MediaPlayer.OnErrorListener() {
mVideoView.setOnErrorListener(new MediaPlayer.OnErrorListener() {
@Override
public boolean onError(MediaPlayer mp, int what, int extra) {
private VideoView myvideoview; private String urlStream; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); String streamV = "http://media.jorgesys.com/reforma.m3u8"; new playM3U8().execute(streamV); myvideoview = (VideoView)this.findViewById(R.id.myvideoview); myvideoview.setOnPreparedListener(new OnPreparedListener() { @Override public void onPrepared(MediaPlayer mp) { myvideoview.start(); myvideoview.setOnErrorListener(new OnErrorListener() { @Override public boolean onError(MediaPlayer mp, int what, int extra) { Log.i("Exception", "url: " + url); return false;
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_video_play); libPlayVideo_tv_title = (TextView) findViewById(R.id.libPlayVideo_tv_title); libPlayVideo_tv_title.setText("视频播放"); videoView = (VideoView) findViewById(R.id.libPlayVideo_videoView); videoView.setOnErrorListener(new MediaPlayer.OnErrorListener() { @Override public boolean onError(MediaPlayer mp, int what, int extra) { if (isFirst) { isFirst = false; Toast.makeText(VideoPlayActivity.this, "播放该视频异常", Toast.LENGTH_SHORT).show(); return true; String mVideoPath = getIntent().getStringExtra(VedioRecordActivity.kVideoSavePath); File file = new File(mVideoPath); if (file.exists()) { videoView.setVideoPath(file.getAbsolutePath()); videoView.start(); setLoop(file.getAbsolutePath()); } else { Log.e("tag","not found video " + mVideoPath);
private void setupCallbacks() {
mVideoView.setOnErrorListener(new MediaPlayer.OnErrorListener() {
private void initVideoView() {
videoView = (VideoView) findViewById(R.id.video_view);
File file = new File("/sdcard/videocapture_example.mp4"); // 获取SD卡上要播放的文件
if(file.exists()) {
videoView.setVideoPath(file.getAbsolutePath());
videoView.requestFocus(); // 让VideoView获得焦点
videoView.start();
videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
// 在播放完毕被回调
videoView.setOnErrorListener(new MediaPlayer.OnErrorListener() {
@Override
public boolean onError(MediaPlayer mp, int what, int extra) {
// 发生错误重新播放
ToastUtil.showMessage("播放出错", Toast.LENGTH_SHORT, true);
return false;
mVideoView.setOnErrorListener(this);
interfazWeb.setContentView(mCustomViewContainer);
mCustomVideoView.setOnCompletionListener(this);
mCustomVideoView.setOnErrorListener(this);
mCustomVideoView.start();
@Override public void onShowCustomView(View view, CustomViewCallback callback) { super.onShowCustomView(view, callback); if (view instanceof FrameLayout){ FrameLayout frame = (FrameLayout) view; if (frame.getFocusedChild() instanceof VideoView){ VideoView video = (VideoView) frame.getFocusedChild(); frame.removeView(video); a.setContentView(video); video.setOnCompletionListener(this); video.setOnErrorListener(this); video.start(); }`enter code here`
@Override public void onShowCustomView(View view, CustomViewCallback callback) { super.onShowCustomView(view, callback); if (view instanceof FrameLayout){ FrameLayout frame = (FrameLayout) view; if (frame.getFocusedChild() instanceof VideoView){ VideoView video = (VideoView) frame.getFocusedChild(); frame.removeView(video); a.setContentView(video); video.setOnCompletionListener(this); video.setOnErrorListener(this); video.start();
webview.setWebChromeClient(new WebChromeClient() { @Override public void onShowCustomView(View view, CustomViewCallback callback) { super.onShowCustomView(view, callback); if (view instanceof FrameLayout) { FrameLayout frame = (FrameLayout) view; if (frame.getFocusedChild() instanceof VideoView) { VideoView video = (VideoView) frame.getFocusedChild(); frame.removeView(video); a.setContentView(video); video.setOnCompletionListener(this); video.setOnErrorListener(this); video.start();
videoView.setOnErrorListener(this);
vidView.setOnErrorListener(new MediaPlayer.OnErrorListener() {
@Override
public boolean onError(MediaPlayer mp, int what, int extra) {
public void loadPlayer() { _activity.setContentView(R.layout.hls_video_view); if (_activity.url == null) { Development.ExceptionMsg("Video Url is Null!"); return; VideoView view = (VideoView) _activity.findViewById(R.id.video_player); if (!_activity.isLive) { //MediaController for vod only MediaController controller = new MediaController(_activity); controller.setAnchorView(view); view.setMediaController(controller); _activity.LogStreamStart(); _activity.HideBuffering(); view.setOnCompletionListener(this); view.setOnPreparedListener(this); view.setOnErrorListener(this); //this is important, and should perhaps be part of the interface view.setOnTouchListener(_activity); view.setVideoURI(Uri.parse(_activity.url)); view.requestFocus(); view.start();
mVv.setOnErrorListener(this);
mVv.setOnCompletionListener(this);
mController.setCanReplay(canReplay);
mVideoView.setOnErrorListener(this);
mVideoView.setOnCompletionListener(this);
mVideoView.setVideoURI(mUri);
_customViewCallback = callback; if (view instanceof FrameLayout){ FrameLayout frame = (FrameLayout) view; if (frame.getFocusedChild() instanceof VideoView){ final VideoView video = (VideoView) frame.getFocusedChild(); _customView = video; frame.removeView(video); Activity a = (Activity)_context; a.setContentView(video); video.setOnCompletionListener(new OnCompletionListener() { @Override public void onCompletion(MediaPlayer mp) { mp.stop(); video.stopPlayback(); onHideCustomView(); video.setOnErrorListener(new OnErrorListener() { @Override public boolean onError(MediaPlayer mp, int what, int extra) { return false; if (!video.isPlaying()) video.start();
videoView.setOnErrorListener(new MediaPlayer.OnErrorListener() {
@Override
public boolean onError(MediaPlayer mp, int what, int extra) {