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

有帮助吗?

解决方案 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;

其他提示

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top