Play YouTube videos in a Windows Phone application

2
Hello, I'm creating an application for Windows Phone 8 / 8.1 programming in C #, one of the features will be the ability to watch youtube videos, but I could not make it work using MediaElement. Is there another way to do it? Thank you.

    
asked by anonymous 29.01.2015 / 13:56

1 answer

1

You can use the YouTube class that is available in the MyToolkit library for Windows Phone, take a look:

link

Example to play a YouTube video using a MediaElement, but using the GetVideoUriAsync method: XAML with MediaElement:

XAML with MediaElement:

<MediaElement x:Name="player" Width="480" Height="320" />

The code to start the video in the player (for example, on a clicked button):

var url = await YouTube.GetVideoUriAsync(youTubeId, YouTubeQuality.Quality720P);
if (url != null)
{
    player.Source = url.Uri;
    player.Play();
}
else
    // TODO show error (video uri não existe)
    
29.01.2015 / 14:03