Last active
November 2, 2018 11:46
-
-
Save Adoonq/f0027e198340ed45b6ae87f04dfbcefa to your computer and use it in GitHub Desktop.
YouTube VideoBackground
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
iframe { | |
position: absolute; | |
top: 0; | |
left: 0; | |
width: 100%; | |
height: 100%; | |
@media (min-aspect-ratio: 16/9) {height: 300%; top: -100%} | |
@media (max-aspect-ratio: 16/9) {width: 300%; left: -100%} | |
} |
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 src="https://www.youtube.com/iframe_api"></script> | |
var videoId = 'leSaAaWrkK0', | |
muted = 0; | |
if (videoId) { | |
$('[data-youtube]').html('<div id="player"></div>'); | |
function onYouTubeIframeAPIReady() { | |
var player = new YT.Player('player', { | |
videoId: videoId, | |
events: {'onReady': onPlayerReady}, | |
playerVars: {controls: 0, showinfo: 0, rel: 0, autoplay: 1, loop: 1, iv_load_policy: 3, mute: muted, playlist: videoId} | |
}); | |
} | |
function onPlayerReady(event) {event.target.playVideo()} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment