Hello all…

Today I will show you how to get notified when a video completes playing in android.
PLease check this post for playing a video and the resources.
First create a folder named “raw” inside the “res” folder and copy a video inside it.
Now copy the xml from this link.

For listening to the video completion add a setOnCompletionListener to the VideoView Object.
Here is hoe we do this.

package com.coderzheaven.pack;

import android.app.Activity;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.net.Uri;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.Toast;
import android.widget.VideoView;

public class VideoViewDemo extends Activity {
    public void onCreate(Bundle savedInstanceState) {
    	    private void showVideo()
    	        VideoView vd = (VideoView)findViewById(R.id.videoview);
    	        Uri uri = Uri.parse("android.resource://"+ getApplication().getPackageName() +"/"+R.raw.asal);
    	        MediaController mc = new MediaController(this);
    	        vd.setOnCompletionListener(new OnCompletionListener() {
					public void onCompletion(MediaPlayer mp) {
						Toast.makeText(getApplicationContext(), "Video completed", Toast.LENGTH_LONG).show();

Leave a Reply

Your email address will not be published. Required fields are marked *




Theme by HermesThemes

Copyright © 2018 CoderzHeaven. All Rights Reserved

Please wait...

Subscribe to our newsletter

Want to be notified when our article is published? Enter your email address and name below to be the first to know.