View a Youtube video through videoView through Xamarin

0

I need to display a video by a URL , such as a YouTube link using the VideoView tool,

I did some research on this, and I got this code, but it did not work, I always get the message that the video could not be executed.

I already gave permission and checked the internet connection and everything is ok, I tested the APP in both the emulator and the cell phone.

If anyone can help me with this I will be very grateful!

My code:

public void playVideo()
            {
                try
                {
                    string url = "https://www.youtube.com/watch?v=2lkBFpyo1Mc";
                    nvidCamera.SetVideoURI(Android.Net.Uri.Parse(url));
                    nvidCamera.RequestFocus();
                    nvidCamera.Start();
                }
                catch (Exception ex)
                {
                    alertShow("Ocorreu um problema: " + ex, false);
                }
            }
    
asked by anonymous 07.09.2016 / 20:23

1 answer

1

There is no way, youtube provides the API itself, they will never provide the actual Youtube video URL, this would violate various legal concepts, as well as the right of the owners, although they still have the videos of advertisements that are the way they make money through this service that is free to us.

Here's the Youtube API download: link

And some examples on github / youtube ready: link

However I do not know how to use this in Xamarim, so a workaround would be to use a webview + embedded url from youtube, something like:

var youtubePlayer = new WebView {
      Source = "https://www.youtube.com/embed/ID_VIDEO"
};

More details at link

Please, if you have any questions regarding this please comment

    
07.09.2016 / 20:40