I am working on a page that contains a YouTube video embedded in HTML. I am trying to find a way to stop the video when it is closed using the YouTube API, but so far my attempts have been unsuccessful. I have included SWFObject and jQuery in the code, yet I am unable to control the video using the methods described.
document.getElementById()
swfobject.registerObject('id', 'version')
Is there a way to manipulate a YouTube video using the JavaScript API without embedding it through SWFObject? Ideally, I would like to link to the existing <video>
tag in the DOM for this functionality.
To provide some context, the video is displayed within a lightbox that opens when clicked by the user and closes when they click outside of it. My goal is to ensure that the video stops playing automatically when the user exits the lightbox window.