Answer the question
In order to leave comments, you need to log in
How to stop youtube video from playing in JS using JS?
Hello!
<iframe width="800" height="480" src="https://www.youtube.com/embed/" frameborder="0" allowfullscreen id="youtube"></iframe>
- so the video is inserted on the page. Answer the question
In order to leave comments, you need to log in
Not exactly trivial, but nonetheless:
In the video download url add ?enablejsapi=1
Then stop the video, in the event you need:
document.getElementById('video').contentWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}', '*');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question