JSFiddle - React, Tailwind, and code Playground

by ian_smithz

HTML

<div id="player"/>

JavaScript

var tag = document.createElement('script');
tag.src = "http://www.youtube.com/iframe_api";
document.head.appendChild(tag);



var player;

function onYouTubeIframeAPIReady() {
    player = new YT.Player('player', {
        height: '390',
        width: '640',
        videoId: 'nhX4rQ79C1A',
        events: {
            'onReady': onPlayerReady
        }
    });
}
window.onYouTubeIframeAPIReady = onYouTubeIframeAPIReady;

function onPlayerReady(event) {
    event.target.playVideo();
}