JSFiddle - React, Tailwind, and code Playground

HTML

<iframe id="player"  width="560" height="315" src="https://www.youtube.com/embed/oRSijEW_cDM?enablejsapi=1&origin=https%3A%2F%2Ffiddle.jshell.net" frameborder="0" allowfullscreen></iframe>

JavaScript

g = window;
  // 2. This code loads the IFrame Player API code asynchronously.
  var tag = document.createElement('script');
  tag.src = "https://www.youtube.com/iframe_api";
  var firstScriptTag = document.getElementsByTagName('script')[0];
  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
  // 3. This function creates an <iframe> (and YouTube player)
  //    after the API code downloads.
  g.onYouTubeIframeAPIReady = function () {
    //alert("dfg");
    g.player = new YT.Player('player', {events: {'onReady': onPlayerReady,'onStateChange': onPlayerStateChange }
  });
  g.player2 = new YT.Player('player2');
  }
  // 4. The API will call this function when the video player is ready.
  g.onPlayerReady = function(event) {
    event.target.playVideo();
  }
  // 5. The API calls this function when the player's state changes.
  //    The function indicates that when playing a video (state=1),
  //    the player should play for six seconds and then stop.
  g.done = false;
  g.onPlayerStateChange = function(event) {
    if (event.data == YT.PlayerState.PLAYING && !done) {
      setTimeout(stopVideo, 100);
      done = true;
    }
  }
  g.stopVideo = function () {
    player.stopVideo();
  }