Play youtube video in windows form

19,856

Solution 1

Look here add youtube to winform. Just use their example. I hope this help.

Solution 2

  1. Add a WebBrowser control to your form
  2. Retrieve the embed code of your video
  3. Load the video into the WebBrowser

Example :

 const string page = "<html><head><title></title></head><body>{0}</body></html>";
 webBrowser1.DocumentText = string.Format(page, "<iframe width=\"560\" height=\"315\" src=\"http://www.youtube.com/embed/yg2u_De8j5o\" frameborder=\"0\" allowfullscreen></iframe>");

As for counting the views : each time a user click the "View" button, load the video then increment your counter (this one should be easy enough).

Share:
19,856
Arnk
Author by

Arnk

Updated on June 04, 2022

Comments

  • Arnk
    Arnk about 2 years

    I'm new to dot net and have a task to complete. I don't know how to start.

    My Question: There should be a youtube video on my windows form. As a user clicks the play button that form should get refreshed and prints "1 person viewed" with the video playing. similarly user can repeat the process: he can again hit the play button and it will get refreshed. Now this time you will again see the video along with the text "2 person viewed". Basically, it's maintaining a counter of hitting the play button.

    I'm unable to find anything regarding this on Google. I don't know how I will embed that video into the form.

  • Arnk
    Arnk almost 12 years
    im not maintaining any db plus how to use browser controls ?? please give me some tutorial if you find something relevant
  • Arnk
    Arnk almost 12 years
    Thanks a lot :) it really helped
  • Arnk
    Arnk almost 12 years
    i have to count number of times the play button is pressed
  • Axiumin_
    Axiumin_ over 6 years
    That won't work anymore as it got discontinued :\