Thomas
Thomas

Reputation: 1821

Control YouTube video embedded in html

I have a page with a YouTube video embedded in html. I want to stop the video when it's closed using the YouTube API. I have included SWFObject (and jquery), but I'm not able to control the video using any of the described methods.

document.getElementById()
swfobject.registerObject('id', 'version')

How can I control a youtube video using the js api without embedding it through swfobject i.e. by hooking up to the existing tag in the DOM?

Edit for clarification: The video is displayed in a lightbox that is opened by the user and closed by clicking outside it. I want the video to stop playing when the user closes this lightbox.

Upvotes: 2

Views: 4352

Answers (1)

dominic
dominic

Reputation: 571

this might be a better way: http://apiblog.youtube.com/2011/01/introducing-javascript-player-api-for.html

embed as an iframe. you can still control it with javascript.

Upvotes: 2

Related Questions