Question

In my app, I have a list of videos and i am not sure how to play them one after another.

Here is the code to play a single video:

 var uri = Android.Net.Uri.Parse (Android.OS.Environment.ExternalStorageDirectory.ToString () + "/" + i + ".mp4");        
 vi.SetVideoURI (uri);
 vi.Start (); 

 where vi is a VideoView and i = 1,2,3...n

Please help, Thanks

Was it helpful?

Solution 2

I got it working,

            VideoView vi = FindViewById<VideoView>(Resource.Id.video2);

            var uri = Android.Net.Uri.Parse (Android.OS.Environment.ExternalStorageDirectory.ToString () + "/" + 1 + ".mp4");        
            vi.SetVideoURI (uri);
            vi.Start (); 
            int i = 2;
            vi.Completion += (object sender, EventArgs e) => {
                if(i<= NoOfFiles)
                {
                    var uri2 = Android.Net.Uri.Parse (Android.OS.Environment.ExternalStorageDirectory.ToString () + "/" + i + ".mp4");        
                    vi.SetVideoURI (uri2);
                    vi.Start (); 
                    i++;
                }
            };

Where NoOfFiles = total number of videos;

OTHER TIPS

You can use getBufferPercentage(), getDuration (),getCurrentPosition () these three methods related to videoview.It solves your problems.

use exoPlayer. this library help you to concatenate multi video together

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top