Last active
June 15, 2018 04:10
-
-
Save weimenglin/468524c6fe73cceb5a12ce82c079a9ae to your computer and use it in GitHub Desktop.
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
<div data-video="videoId" data-autoplay="0" data-loop="1" id="youtube-audio"></div> | |
<script src="https://www.youtube.com/iframe_api"></script> | |
<script> | |
var player; | |
function onYouTubeIframeAPIReady() { | |
var ctrlq = document.getElementById("youtube-audio"); | |
ctrlq.innerHTML = '<div id="youtube-player"></div>'; | |
ctrlq.style.cssText = 'display:none'; | |
player = new YT.Player('youtube-player', { | |
height: '0', | |
width: '0', | |
videoId: ctrlq.dataset.video, | |
playerVars: { | |
autoplay: ctrlq.dataset.autoplay, | |
loop: ctrlq.dataset.loop, | |
}, | |
events: { | |
'onReady': function() { | |
player.setPlaybackQuality("small"); | |
player.playVideo(); | |
} | |
} | |
}); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment