3
votes

I am currently developing an UWP youtube player and i am having some big trouble with playing the actual video. I am using this to play a youtube video in a media element:

  using MyToolkit.Multimedia;
var url = await YouTube.GetVideoUriAsync(youtubeid, YouTubeQuality.Quality1080P);
var YoutubePlayer = new MediaElement();
YoutubePlayer.Source = url.Uri;

It used to work just fine for about a month, but now it just... doesn't. It gets the right video URI (the mp4), i also tried with the YoutubeExtractor nuget package, but for some reason, when i use YoutubePlayer.Play(), it just doesn't play. It does nothing. No error, no nothing.

I found an alternative of using a webview and custom C# controls that calls javascript methods, but i prefer not to go that way, since it is much smoother having a media element.

Any help would do, i've been searching the internet for days now and still can't find an answer.

Thank you.

1
There's a bug registerd for YouTubeExtractor. Are you getting a 403 response? See github.com/flagbug/YoutubeExtractor/issues/194Joel
I can not reproduce your issue. Do you add the YoutubePlayer to to the UI? Can you please post your YouTube Uri?Jayden
Thanks @Joel YoutubeExtractor really had an issue and solved my problem.Darksody
@JaydenGu yeah, sorry about that. The youtube player is already added to the UI, i just entered the "var YoutubePlayer = new MediaElement()" there so you know what type it is :)Darksody
I said if you add MediaElement in code behind, you should able to add it to the page UI by GridName.Children.Add(YoutubePlayer).Jayden

1 Answers

0
votes

A while ago i tried the same and i couldn't get youtubeExtractor to work. I then moved on to LibVideo - which did work.

This is a forked repo which implemented some fixes that were not accepted yet at the time. https://github.com/sommmen/libvideo

The project is no longer being maintained sadly, but this still works for me till this day.