开发者

It is possible to play/stop a youtube video using external software?

It is possible to play/sto开发者_JAVA技巧p a youtube video(inside a web browser like FireFox), using external software(C#)?


I would assume this is not allowed by the YouTube Terms of Service, but I'm not sure. In any case, if this is more of a pet project or proof of concept here are some thoughts:

  • I doubt there are any existing libraries, etc... that can do this b/c of the TOS point.
  • You could probably build this on your own as so:
    • Load a page in a WebBrowser form control.
    • Once the page has loaded (DocumentCompleted event), search the DOM (browser.Document) for the video player element. You would probably look for a Flash element or some typically CSS class/id that YouTube always uses.
    • Get the screen position of that element. Not sure how to do this, maybe you can figure it out?
    • Simulate a mouse click (http://www.gamedev.net/community/forums/topic.asp?topic_id=321029) on the video player.

Once you have found the screen position, you only need to do the mouse click subsequent times. I like the above approach because you can more easily port it to other video sites if you need to - rather than relying on APIs.

I'm also curious why you want to do this. Could you let us in on your thoughts?


Yes, but it is with JavaScript which you can handle with C#. You can hook into the YouTube API.

http://code.google.com/apis/youtube/overview.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜