Skip to content

Instantly share code, notes, and snippets.

@Tusko
Created July 1, 2016 07:08
Show Gist options
  • Select an option

  • Save Tusko/5e0137791c59ea5998d9d905c41fbf53 to your computer and use it in GitHub Desktop.

Select an option

Save Tusko/5e0137791c59ea5998d9d905c41fbf53 to your computer and use it in GitHub Desktop.
YT.player for background
// Load the YouTube API asynchronously
var tag = document.createElement('script'),
firstScriptTag = document.getElementsByTagName('script')[0],
player;
tag.src = "https://www.youtube.com/iframe_api";
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
// Create the player object when API is ready
window.onYouTubeIframeAPIReady = function () {
player = new YT.Player('bg_player', {
videoId: 'cqdwhljFmcc', // YouTube Video ID
width: 560, // Player width (in px)
height: 316, // Player height (in px)
playerVars: {
autoplay: 1, // Auto-play the video on load
controls: 0, // Show pause/play buttons in player
showinfo: 0, // Hide the video title
modestbranding: 1, // Hide the Youtube Logo
loop: 1, // Run the video in a loop
fs: 0, // Hide the full screen button
cc_load_policty: 0, // Hide closed captions
iv_load_policy: 3, // Hide the Video Annotations
autohide: 0 // Hide video controls when playing
},
events: {
onReady: function (e) {
e.target.mute();
}
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment