Play youtube videos in a Windows Phone app

Asked

Viewed 327 times

2

Hello, I am creating an app for Windows Phone 8/8.1 programming in C#, one of the features will be the possibility to watch youtube videos, but I could not make it work using Mediaelement. Is there another way to get it ? Thank you.

1 answer

1

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

https://github.com/RSuter/MyToolkit/wiki/YouTube

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 button clicked):

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)
  • 1

    your link has been switched from Codeplex pro Github because the first one is being disabled. A joint effort is being made for the change: https://pt.meta.stackoverflow.com/questions/6317/codeplex-be%C3%A1-deactivated-no-dia-25-12-2017-what-we-update-them-links. If the link I used was inappropriate, please choose one that is but does not come from Codeplex. Thank you.

  • @Thank you. bjus

Browser other questions tagged

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