Search code examples
.netwpfyoutubevlc

How can I play youtube videos with vlc dotnet library in WPF


I want to develop an player app. I can play from file or rtp-udp stream with vlc dotnet library. But I can't play youtube link. can anyone help me? Thanks in advance


Solution

  • Yes, you should be able to do it following the next steps:

    1) Get the download URL of the youtube Video. There is a lot of information how to do that. But to make an example I provide you the following link: http://en.savefrom.net/1-how-to-download-youtube-video/

    In the method3 you have a way to do it via "sfrom.net". So for example if you have the youtube video: "https://www.youtube.com/watch?v=k1K_4UkVSAE", you can use the following download url: "http://sfrom.net/https://www.youtube.com/watch?v=k1K_4UkVSAE".

    2) Use the previous URL with the VLCDotNet library. I load that with the LocationMedia.

    Example:

    vlcControl.Media = new LocationMedia("http://sfrom.net/https://www.youtube.com/watch?v=k1K_4UkVSAE");
    

    I tried that, and works.

    Edit: You can use this website to obtain the direct URL of a youtubeVideo. Easier than the way I explained in the paragraph 1. http://en.savefrom.net/#url=https:/www.youtube.com/watch?v=k1K_4UkVSAE&utm_source=sfrom.net&utm_medium=short_domains&utm_campaign=sfrom.net