I've used the iframe function to embed videos, and I'm hiding/showing the content and videos through JavaScript.
I have one problem. When I press play on the first video, and then click on the next without stopping the first one, the first one just keeps on playing.
What can I do to stop the video in the "background", when showing new content?
$(function(){
$("#link1").click(show1);
});
function show1(){
$("#pic1").fadeIn();
$("#pic2").hide();
}
I'm just using this simple JavaScript function, where the "pic1" and "pic2" id is the id of the div, the video are embedded in.
I just can't seem to make it work. I tried to put remove, but then you can't see the video again if you want to.
This is an implementation of the YouTube player API, without loading additional files. To get this work, you have to suffix all of your
<iframe>
'ssrc
attribute with?enablejsapi=1
.Example (I broke the code over a few lines for readability, you can safely omit the linebreaks):
JavaScript + jQuery code: