UWP application run sequence of videos in Mediaelement coming from a List<string>

Asked

Viewed 70 times

0

I’m using the Media Element in an application UWP to run a sequence of videos, as I do for when one video ends the other runs in sequence?

In the code below when the first video of List<string> videos10 ends the other of the sequence does not rotate

My idea is to do the job SequenciaDeVideosNoArquivoTexto(); receive a sequence of video names from a text file.

So with the text file I will have full control of the sequence of videos that I will exchange constantly.

    public MainPage()
    {
        this.InitializeComponent();

        SequenciaDeVideosNoArquivoTexto();
    }


    private void SequenciaDeVideosNoArquivoTexto()
    {
        //A LIST ABAIXO FAREI PEGAR AS INFORMAÇÕES DO ARQUIVO TEXTO
        List<string> videos10 = new List<string>();
        videos10.Add("Call Farma");
        videos10.Add("Dia Mundial");
        videos10.Add("Dolex Nueva");
        videos10.Add("Mori Farma");

        foreach (var item in videos10)
        {
            LoadMediaFromString("ms-appx:///Videos/" + item + ".mp4");
        }
    }


    private void LoadMediaFromString(string path)
    {
        try
        {
            Uri pathUri = new Uri(path);
            mediaPlayer.Source = pathUri;
        }
        catch (Exception ex)
        {

            if(ex is FormatException)
            {

            }

            throw;
        }
    }

1 answer

0

You must use the object MediaPlaybackList();, add your videos to this playlist and then assign it as your player’s source.

Reference

  • you could show me how to use the Mediaplabacklist() object; how do I add the videos in this Playlist.

  • Leandro Angelo seeing some examples on the internet is explained how to get the desired file through - var filePicker = new Windows.Storage.Pickers.Fileopenpicker(); but in my case I will pass the information through a text file that will have the names of the videos, how to do to instead of using Fileopenpicker I pass these names.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.