Skip to content

Instantly share code, notes, and snippets.

@nerdfiles
Created February 10, 2013 08:45
Show Gist options
  • Save nerdfiles/4748910 to your computer and use it in GitHub Desktop.
Save nerdfiles/4748910 to your computer and use it in GitHub Desktop.
Hooking it up.
<!DOCTYPE html>
<html>
<body onLoad="createVideo(1, 640, 360, 'DVX9dAj8e8w', 'small', 'light', 1);">
<div id="div_theVideo1" style="width:640px; height:360px; background-color: #CCC;"></div>
<INPUT TYPE="button" VALUE="Play" onClick="document.getElementById('div_theVideo1').childNode.playVideo();">
<INPUT TYPE="button" VALUE="Pause" onClick="document.getElementById('div_theVideo1').childNode.pauseVideo();">
<script async="true">
// Load YouTube IFrame Player API code "asynchronously."
var tag = document.createElement('script');
//tag.src = "//www.youtube.com/iframe_api";
tag.src = "https://www.youtube.com/player_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
var plyr;
function createVideo(inPlayerNumber, inWidth, inHeight, inYouTubeVideoId, invidquality, invidcolor, inVidControlsOffOn) {
plyr = new YT.Player("div_theVideo" + inPlayerNumber, {
playerVars: {
enablejsapi: 1,
modestbranding: 1,
vq: invidquality,
theme: invidcolor,
showinfo: 1,
controls: inVidControlsOffOn,
wmode: 'opaque',
autoplay: 1
},
height: inHeight,
width: inWidth,
videoId: inYouTubeVideoId
});
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment