Last active
December 17, 2015 19:38
-
-
Save Usse/5661393 to your computer and use it in GitHub Desktop.
Youtube api boilerplate
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
<div style="width:759px; height:427px;" id="ytPlayer"></div> |
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
var video = { | |
player : null, | |
init : function() { | |
var tag = document.createElement('script'); | |
tag.src = "https://www.youtube.com/iframe_api"; | |
var firstScriptTag = document.getElementsByTagName('script')[0]; | |
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); | |
var done = false; | |
$("#goBackstage").on("click", function() { | |
video.player.stopVideo(); | |
}) | |
} | |
} | |
function onYouTubeIframeAPIReady() { | |
video.player = new YT.Player('ytPlayer', { | |
height: '427', | |
width: '759', | |
videoId: 'VIDEO_ID', | |
playerVars: { | |
'controls': 0, | |
'rel' : '0', | |
'modestbranding' : 0, | |
'showinfo' :0 | |
} | |
}); | |
} | |
function stopVideo() { | |
video.player.stopVideo(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment