I have a c# Forms project in VisualStudio in which I want to embed a youtube video.
To do so, I add a web browser control in the designer.
The browser works fine
Please visit YouTube Embedded Players and Player Parameters
What you are trying here is an IFrame Embed. Try This: Open Notepad and paste it :
Save this as an html file and open it on browser. If everything goes fine you see Elvis Presley singing It's Midnight.This is similar to the string you have tried to make your Web Browser Navigate to.
Now Comeback to your code on Visual Studio and inplace of your earlier
youtubePlayer.Navigate("...");
Put this code :
youtubePlayer.Navigate("http://www.youtube.com/v/HLj0aLPLsys?version=3");//Embedded AS3 Player
Or This,
youtubePlayer.Navigate("http://www.youtube.com/apiplayer?video_id=HLj0aLPLsys&version=3");//Chromeless AS3 Player
Note : both of the solutions to your problems are deprecated but work and are the closest solutions that can be reached.
To make the player run the video automatically without user Interference add to the end of the string
&autoplay=1
To allow the webBrowser to take up the entire space available in the form Bounds set :
youtubePlayer.Dock = DockStyle.Fill;
Also to get rid of the Annoying script Errors message :
youtubePlayer.ScriptErrorsSuppressed = true;