开发者

How to switch to activity when video play stop

开发者 https://www.devze.com 2023-04-12 03:44 出处:网络
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:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消