Skip to content

Instantly share code, notes, and snippets.

@SashaKolbasov
Last active January 6, 2019 16:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SashaKolbasov/47d4eee3b789d0081f47b75865d283a6 to your computer and use it in GitHub Desktop.
Save SashaKolbasov/47d4eee3b789d0081f47b75865d283a6 to your computer and use it in GitHub Desktop.
Pause YouTube video
<iframe src="https://www.youtube.com/embed/XXX?enablejsapi=1" frameborder="0" allowfullscreen></iframe>
<iframe src="https://www.youtube.com/embed/fjjkcWP4heM?rel=0&amp;controls=0&amp;showinfo=0&amp;start=5&amp;enablejsapi=1" frameborder="0" allowfullscreen></iframe>
<iframe src="https://www.youtube-nocookie.com/embed/knfrxj0T5NY" frameborder="0" allow="accelerometer; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
$('#block .el').on('click', function () {
$("iframe").each(function () {
$(this)[0].contentWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}', '*')
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment