Created
June 7, 2016 06:51
-
-
Save EmilSabitov/be84712dd03fe29175524401beb4e221 to your computer and use it in GitHub Desktop.
Work with youtube iframe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// iframe | |
var youtubePlayer = document.getElementsByClassName('youtube-player')[0]; | |
// play | |
youtubePlayer.contentWindow.postMessage('{"event":"command","func":"playVideo","args":""}', '*'); | |
// pause | |
youtubePlayer.contentWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}', '*'); | |
// stop | |
youtubePlayer.contentWindow.postMessage('{"event":"command","func":"stopVideo","args":""}', '*'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment