Saturday, January 15, 2011

In Android - Automatically Start activity after complete video

Hello ,

Today we have discussed about video finish or playing video when then another activity start.

In complete video You have to put Listener for video properties.

This are the basic funda for playing video in android.

So this are the code below.

vd is the VideoView variable.

First of all pass uri.

Uri uri = Uri.parse("PATH OF VIDEO");

Then set media controller And set video uri ....

MediaController mc = new MediaController(this);

vd.setMediaController(mc);

vd.setVideoURI(uri);

vd.start();

Now On complete video setoncompletelistner properties on VideoView this code below....

vd.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {

@Override

public void onCompletion(MediaPlayer mp) {

Log.v("log_tag","Complete Video");

}

});



2 comments:

  1. what about if I want to start a new activity when the video completes?

    I have a new intent identified, but the activity won't start. Everything in my manifest is laid out. I am stumped.

    ReplyDelete
  2. thanks, very useful post.

    Rahul

    ReplyDelete

How to Use Google Lens on Android: Practical Everyday Use Cases

Google Lens is built into most Android phones already, but most people only use it for the occasional plant or object identification. It act...