How to play YouTube videos in Windows C # application

I created a Windows application using the WebBrowser control and am trying to play a video on YouTube. I installed Adobe Shockwave Player and tried to watch the video in my Windows application, but it does not show any videos. When I press the play button, the screen looks like this: enter image description here

My code to play video

StreamWriter sw = new StreamWriter("utube.html");
        string PlayString = currentVideoUrl.Trim().Replace("watch?v=", "v/");
        string Finalplaycode = "<embed src=" + PlayString + "&hl=en&fs=1& type=application/x-shockwave-flash allowscriptaccess=always allowfullscreen=true width=425 height=344></embed>";
        sw.Write(Finalplaycode);
        sw.Close();
        string PathToNavigate = Directory.GetParent(Application.ExecutablePath) + @"\utube.html";
        webBrowser1.Navigate(PathToNavigate);

and my example video link: http://www.youtube.com/watch?v=oZdnezj9Dfg&feature=BFa&list=PLD3E900BFF6534896&lf=plpp_video

can someone help me in this matter? Am I missing a plugin or something else? I am using .NetFramework 4.0

0
source share
1 answer

, , , . :

<embed src=http://www.youtube.com/v/video_id...>

:

<embed src="http://www.youtube.com/v/video_id...">

, , :

<embed type="application/x-shockwave-flash" width="425" height="344" 
src="http://www.youtube.com/v/UejelYnVI3U&amp;hl=en&amp;fs=1"></embed>

YouTube. , iframes. HTML5, , Flash. . http://www.google.com/support/youtube/bin/answer.py?answer=171780.

Update:

HTML : iframe . , WebBrowser:

<html>
<body>
<iframe class="youtube-player" type="text/html" width="640" height="385"
 src="http://www.youtube.com/embed/oZdnezj9Dfg" frameborder="0">
</iframe>

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0">
<param name="src" value="http://www.youtube.com/v/oZdnezj9Dfg&amp;hl=en&amp;fs=1" />
<embed type="application/x-shockwave-flash" width="425" height="344" 
  src="http://www.youtube.com/v/oZdnezj9Dfg&amp;hl=en&amp;fs=1">
</embed>
</object>

</body>
<html>

. , .

, <object>, Flash. Flash , .

, HTML . , <html> .

+2

All Articles