3

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.

Darksody
  • 481
  • 1
  • 4
  • 15
  • There's a bug registerd for YouTubeExtractor. Are you getting a 403 response? See https://github.com/flagbug/YoutubeExtractor/issues/194 – Joel Jun 24 '16 at 19:11
  • I can not reproduce your issue. Do you add the YoutubePlayer to to the UI? Can you please post your YouTube Uri? – Jayden Jun 28 '16 at 07:19
  • Thanks @Joel YoutubeExtractor really had an issue and solved my problem. – Darksody Jun 29 '16 at 07:29
  • @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 Jun 29 '16 at 07:30
  • 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 Jun 29 '16 at 07:40
  • @JaydenGu Yes, you are correct :) The problem comes from the youtube "API", that GetVideoUriAsync() method fails to parse the mp4 uri. I am also working on an alternative player using a webview, but that has a very big downside for me: i don't know how to make it play in a background audio task, being in a webview, for mobile... – Darksody Jun 29 '16 at 09:55
  • Can you give me the mp4 uir that can not be played? I test some uri from youtube that all of them can play. – Jayden Jun 29 '16 at 09:59

1 Answers1

0

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.

sommmen
  • 6,570
  • 2
  • 30
  • 51