android监听视频播放结束

android监听视频是否播放结束,今天做的项目是在一个主界面中插入一个播放器,所以不是单纯的视频app,以前用的方法是:

mvideoview.setOnCompletionListener(new OnCompletionListener() {

            @Override
            public void onCompletion(MediaPlayer mp) {
             //your code
            }
        });

但今天一直报错:

Caused by: java.lang.ClassCastException: com.example.vitamio_test.MainActivity cannot be cast to io.vov.vitamio.MediaPlayer$OnCompletionListener 

The method setOnCompletionListener(MediaPlayer.OnCompletionListener) in the type VideoView is not applicable for the arguments (new MediaPlayer.OnCompletionListener(){})

不知道是更新了还是怎么了,这个MediaPlayer一定要有,不然会报类型转换错误,完整的如下:

mVideoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() 
        		        { 
        		         @Override 
        		         public void onCompletion(MediaPlayer mp) 
        		         { 
        		        	  mp.seekTo(0);//循环播放
        		                mp.start(); 
        		         } 
        		        }); 

你可能感兴趣的:(android程序)