Created
March 30, 2017 15:32
-
-
Save pelid/60b3d641e97f2ca6da6d5e6d3dc49e62 to your computer and use it in GitHub Desktop.
This file contains 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
<script> | |
function onYouTubeIframeAPIReady() { | |
$modal.on('show', function(){ | |
new YT.Player('player', { | |
height: '360', | |
width: '640', | |
videoId: 'M7lc1UVf-VE', | |
events: { | |
'onReady': onPlayerReady, | |
} | |
}); | |
} | |
function onPlayerReady(event) { | |
var player = event.target | |
if ($modal.isVisible()){ | |
player.playVideo(); | |
} else { | |
$modal.on('show', function(){ | |
player.playVideo(); | |
}) | |
} | |
$modal.on('closed', function(){ | |
player.stopVideo(); | |
}) | |
}) | |
} | |
</script> | |
<script async defer src="https://www.youtube.com/iframe_api"></script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment