VideoView视频播放

来源:互联网 发布:英文字体识别软件 编辑:程序博客网 时间:2024/09/21 09:03

Uri uri = Uri.parse(url);  //网络视频

mVideoView = (VideoView) findViewById(R.id.videoView);
         

mVideoView.setMediaController(new MediaController(this));  //设置控制器,系统自带的控制器


mVideoView.setVideoURI(uri);     //设置视频源


mVideoView.start();


mVideoView.requestFocus();  
//Call this to try to give focus to a specific view or to one of its descendants.

//称这个是试图把焦点集中在明确的view或者其子类中,请求焦点


mVideoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
             @Override
             public void onCompletion(MediaPlayer mp) {
                 // TODO Auto-generated method stub
             Toast.makeText(getApplicationContext(), "视频播放结束了", 1).show();
             }
         });
//Register a callback to be invoked when the end of a media file has been reached during playback.
//登记回调以便在media文件达到播放结束的时候调用。播放完成后调用,即监听播放完成

0 0
原创粉丝点击