Part 20 - Playing Video and Audio in a MediaElement Control

Play Part 20 - Playing Video and Audio in a MediaElement Control

The Discussion

  • User profile image

    Hi Bob,

    First off i'd just like to say I love the videos and I am looking at signing up to LearnVisualStudio.Net to learn more, if my University Lecturers were as good as you I might have understood more than just the absolute basics.

    I'm trying to create a sort of amalgamation between this SoundBoard App and the Hub App template so that when I click on any of the item tiles instead of taking me to an item page it plays a sound in myMediaElement based on the UniqueId, kind of like what you have done in the I Love Cupcakes app a couple of lessons on from this.

    This is what I have so far in my HubPage.xaml.cs.

    private void ItemView_ItemClick(object sender, ItemClickEventArgs e)
                var itemId = ((SampleDataItem)e.ClickedItem).UniqueId;

                var uri = "ms-appx:///Assets/" + itemId + ".wav";
                myMediaElement.Source = new Uri(uri, UriKind.Absolute);


    It runs fine but breaks when I try to click the button and I'm not sure where I'm going wrong. Any chance you could help me with this?




  • User profile image

    how I embed a link or a video URL in my media element, is related with api, data parasing or data binding....

  • User profile image

    How to insert a list of videos to play

    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)

    Uri pathUri = new Uri("ms-appx:///Videos/" + item + ".mp4");
    mediaPlayer.Source = pathUri;
    catch (Exception ex)

Add Your 2 Cents