Uri uri = Uri.parse(url); //网络视频
mVideoView = (VideoView) findViewById(R.id.videoView);
mVideoView.setMediaController(new MediaController(this)); //设置控制器,系统自带的控制器
mVideoView.setVideoURI(uri); //设置视频源
mVideoView.start();
//Call this to try to give focus to a specific view or to one of its descendants.
//称这个是试图把焦点集中在明确的view或者其子类中,请求焦点
@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文件达到播放结束的时候调用。播放完成后调用,即监听播放完成