Answer the question
In order to leave comments, you need to log in
How to pause the current youtube video on click and start the next one?
Friends, please explain how to click on the link to pause the current video and start the next one?
It turned out only to pause the current one, but I can’t figure out how to start the next one?
Here is a simple example:
<div class="video">
<iframe width="560" height="315" src="https://www.youtube.com/embed/f7Ir5icRsZ0?autoplay=1&rel=0&enablejsapi=1" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
<iframe width="560" height="315" src="https://www.youtube.com/embed/f7Ir5icRsZ0?rel=0&enablejsapi=1" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
</div>
<a href="#" class="play">следующее</a>
$(document).on('click', '.play', function(){
$(".video iframe").each(function() {
$(this)[0].contentWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}', '*');
//$(this)[1].contentWindow.postMessage('{"event":"command","func":"playVideo","args":""}', '*');
//$(this).next("iframe")[0].contentWindow.postMessage('{"event":"command","func":"playVideo","args":""}', '*');
});
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question