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?
from the API docs:
so in jQuery:
To start video
To stop video
You may want to replace "&autoplay=1" with "?autoplay=1" incase there are no additional parameters
works for both vimeo and youtube on FF & Chrome
My solution to this that works for the modern YouTube
embed
format is as follows.Assuming the
iframe
your video is playing in hasid="#video"
, this simple bit of Javascript will do the job.I've seen proposed solutions to this issue involving use of the
YouTube API
, but if your site is not anhttps
site, or your video is embedded using the modern format recommended by YouTube, or if you have theno-cookies
option set, then those solutions don't work and you get the "TV set to a dead channel" effect instead of your video.I've tested the above on every browser I could lay my hands on and it works very reliably.
1.include
2.add your youtube iframe.
3.magic time.
I've had this problem before and the conclusion I've come to is that the only way to stop a video in IE is to remove it from the DOM.
if you are using sometimes playerID.stopVideo(); doesnot work, here is a trick,