Skip to content

Instantly share code, notes, and snippets.

@cahva
Last active February 18, 2019 09:05
Show Gist options
  • Save cahva/3cf2dd37b4bc58700408ea98ceeef95a to your computer and use it in GitHub Desktop.
Save cahva/3cf2dd37b4bc58700408ea98ceeef95a to your computer and use it in GitHub Desktop.
Embed script to add youtube video to videosync event
<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