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

Était-ce utile?

La 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;

Autres conseils

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

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top