问题
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.
回答1:
Look here add youtube to winform. Just use their example. I hope this help.
回答2:
- Add a
WebBrowser
control to your form - Retrieve the
embed
code of your video - 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).
回答3:
You should probably just keep track of the play clicks in your application or database and use a web browser control to navigate to the pages you need.
回答4:
You could simply download the swf and play it inside the form. For that you can start here.
For the counter, do you just want to count how many times the button was pressed? That is trivial.
Do you want the actual count that Youtube.com displays? You may be able to sift through the source to get it, although I don't know if direct swf downloads count as plays for Youtube.
来源:https://stackoverflow.com/questions/12223392/play-youtube-video-in-windows-form