I have a jquery slider that I have built, basically just three pannels that slide by applying negative left CSS values. Works great, but I have a youtube video in one slide that wont stop when I slide. I've tried display:none and Visibility:hidden which works in all but IE, the audio keeps going in IE.
Is there an easy way to kill a video with jquery?
This works for me on both YouTube and Vimeo players. I'm basically just resetting the src attribute, so be aware that the video will go back to the beginning.
$theArticleDiv is my current video's container - since I have multiple videos on the page, and they're being exposed via a Drupal view at runtime, I have no idea what their ids are going to be. So I've bound muy click event to a currently visible element, found its parent, and decided that's $theArticleDiv.
('.views-field-field-video-1 iframe') finds the current video's iframe for me - in particular the one that's visible right now. That iframe has a src attribute. I just pick that up and reset it right back to what it already was, and automagically the video stops and goes back to the start. If my users want to pause and resume, they can do it without closing the video, of course - but frankly if they do close the video, I feel they can live with the fact that it's reset to the start.
HTH
Actually you only need javascript and build the embed of the youtube video correctly with swfobject google library
This is an example
After that you can call this functions:
It took me a bit of scouting around to suss this out, but I've settled on this cross-browser implementation:
HTML
jQuery
What it essentially does is open my lightbox and populate my src attribute, and on close, just remove the src value (then re-populates it on open).
I got this to work on all modern browsers, including IE9|IE8|IE7. The following code will open your YouTube video in a jQuery UI dialog modal, autoplay the video from 0:00 on dialog open, and stop video on dialog close.
I was facing the same problem. After a lot of alternatives what I did was just reset the embed src="" with the same URL.
Code snippet:
I was able to at least stop the video from playing when I hide it.:-)
Simple like that.
include the following line in the function to close pop.