I am very new to android programming. I am playing a video in Vi开发者_JAVA百科deoView, i want to switch to other activity when video play ends.code is below:
VideoView video = (VideoView) findViewById(R.id.myVideo);
Uri uri = Uri.parse("android.resource://com.example.samplevideo/"+R.raw.appvideo);
video.setVideoURI(uri);
video.start();
What to do to Switch on other Activity when video playing finished?
Register a setOnCompletionListener(..)
.
video.setOnCompletionListener(new MediaPlayer.OnCompletionListener(){
@Override
public void onCompletion(MediaPlayer mp){
// invoke your activity here
}
});
Update: added the missing return type.
精彩评论