Skip to content

Instantly share code, notes, and snippets.

@famousgarkin
Created April 12, 2016 19:52
Show Gist options
  • Save famousgarkin/4cd1fc884ff76f5fe23c13b0b08bdf80 to your computer and use it in GitHub Desktop.
Save famousgarkin/4cd1fc884ff76f5fe23c13b0b08bdf80 to your computer and use it in GitHub Desktop.
<!doctype html>
<html>
<body>
<script src="https://www.youtube.com/iframe_api"></script>
<script>
function onYouTubeIframeAPIReady() {
console.log('API ready')
var player = new YT.Player('ytplayer', {
events: {
onReady: function() {
console.log('player ready')
player.playVideo()
console.log(player.getDuration())
}
}
})
}
</script>
<iframe id="ytplayer" type="text/html" width="640" height="390"
src="http://www.youtube.com/embed/M7lc1UVf-VE?enablejsapi=1&origin=http://localhost"
frameborder="0"></iframe>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment