Larik
Larik

Reputation: 99

How to switch to activity when video play stop

I am very new to android programming. I am playing a video in VideoView, 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?

Upvotes: 1

Views: 1283

Answers (1)

Peter Knego
Peter Knego

Reputation: 80330

Register a setOnCompletionListener(..).

video.setOnCompletionListener(new MediaPlayer.OnCompletionListener(){
    @Override
    public void onCompletion(MediaPlayer mp){
        // invoke your activity here
    } 
});

Update: added the missing return type.

Upvotes: 3

Related Questions