Last active
February 18, 2019 09:05
-
-
Save cahva/3cf2dd37b4bc58700408ea98ceeef95a to your computer and use it in GitHub Desktop.
Embed script to add youtube video to videosync event
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
<script> | |
/* wait for element to be ready and then add embedded youtube */ | |
function tryEl(e) { | |
var privEl = document.querySelector('.video-player'); | |
if (!privEl) { | |
window.requestAnimationFrame(tryEl); | |
} else { | |
changeText(privEl); | |
} | |
} | |
function changeText(el) { | |
var youtubeId = 'GmzWbgzo6B4' | |
var youtubeUrl = 'https://www.youtube.com/embed/' + youtubeId; | |
var iFrame = document.createElement('iframe'); | |
window.initBitmovin = function() { return false; } | |
bitmovin = null; | |
iFrame.setAttribute('style', 'width: 100%'); | |
iFrame.setAttribute('frameborder', '0'); | |
iFrame.setAttribute('allowfullscreen','1'); | |
iFrame.setAttribute('allow', 'accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture'); | |
iFrame.setAttribute('src', youtubeUrl); | |
el.appendChild(iFrame); | |
} | |
tryEl(); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment