It is possible to play/stop a youtube video(inside a web browser like FireFox), using external software(C#)?
A:
Yes, but it is with JavaScript which you can handle with C#. You can hook into the YouTube API.
Dustin Laine
2010-06-14 18:58:51
That not what I ment. I'm talking about a software(not website) that somehow send message to the web browser. The web browser is opened on some youtube.com video and my software will play/stop that video
Adir
2010-06-14 19:48:45
could we know why you need such this ?
Space Cracker
2010-06-14 22:13:28
A:
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?
Chad
2010-06-15 02:23:14
thank you Chad :) this is just for fun. sometimes I use youtube to hear music while I'm playing some game(full screen), so I tought it will be useful to use some kind of a keystroke to play or pause the music during the game without minimizing.
Adir
2010-06-15 10:37:14
Ah! I feel your pain. What I do for external music while playing a full screen game is to use Winamp and it's Global Hotkeys (a default install option). Trouble, of course, is that you'll need to get your music on your computer. I think there are a good number of YouTube audio extractor plug-ins (e.g. https://addons.mozilla.org/en-US/firefox/addon/10544/ ) for FireFox. You could extract the audio and then play it in WinAmp in the background. Best of luck, let us know if you do roll your own app to do this. Thanks.
Chad
2010-06-15 13:37:11