how to add youtube videos in windows player in winforms using c#. what is other way to do this.

sknake commented: duplicate posts -1

Dani AI

Generated

Short answer for : host the YouTube player inside a browser control in your WinForms app rather than trying to feed YouTube URLs into the Windows Media Player control. The site no longer exposes a simple, stable raw video file for direct playback, and modern YouTube playback expects an embedded player (or a browser/runtime that supports HTML5 media). and raised the local-file/WMP and Flash-era concerns — those were valid for older setups, but the practical, robust route today is an embedded browser or a media library that supports the actual stream types.

A minimal approach (quick proof-of-concept) is to load the YouTube iframe into a browser control. Example using the legacy WebBrowser control:

// Replace VIDEO_ID with the YouTube video id (e.g. dQw4w9WgXcQ)
string html = "<!doctype html><html><body style='margin:0'>" +
"<iframe width='100%' height='100%' src='https://www.youtube.com/embed/VIDEO_ID?autoplay=1' " +
"frameborder='0' allow='autoplay; encrypted-media' allowfullscreen></iframe></body></html>";
webBrowser1.DocumentText = html;

Prefer WebView2 (Edge) or CefSharp for production: they render modern pages reliably and handle YouTube features. With WebView2 you simply navigate the control to the embed URL (ensure the WebView2 runtime is installed).

If you must play raw streams or downloaded files, use a capable player library (LibVLC/LibVLCSharp, Vlc.DotNet) rather than WMP — but be careful: downloading or replaying YouTube content outside the official player can violate YouTube's Terms of Service and copyright rules. Troubleshooting tips: verify the embedded URL (use the /embed/VIDEO_ID form), ensure the embedded runtime supports HTML5/encrypted-media, and test with a modern embedded browser control if the legacy WebBrowser shows a blank/failed page.

Recommended Answers

All 5 Replies

Just add the wmp dll from references, and than store that videos in a folder, and than give a path of that folder to wmp.

as per the original question. Windows Media Player cannot stream videos from youtube because windows don't have a FLV codec. and they won't make on because Microsoft and Adobe and a falling out a few years back, and since Adobe acquired the flash platform and refused to give Microsoft the rights to use it on thier system. Microsoft created silverlight, and thus, Flash Video Integration into windows won't be around legally for quite some time. Sorry.

BUT

if you want to just load a flash plugin com object into you C# windows form app and load into that a swf movie that plays FLV, you can then migrate flv videos from youtube to your application.

But that's all the help I can provide as I am really busy right not, and this is a very complicated project.

`````````````````````````````````````````````
Originally Posted by avirag View Post

u can check this link also
http://msdn.microsoft.com/en-us/library/bb383953.aspx

i want to view youtube lively in my appliction using flash player or media player in windows form in c#.net.

lol yeah, that will work, IF the video on the net is in a windows acceptable format, like WMV, or an AVI package that your system has a codec for, otherwise, it will crash. There are no easy answers.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.