JSFiddle - React, Tailwind, and code Playground

by lchau

HTML

<script src= "https://player.twitch.tv/js/embed/v1.js"></script>
<button id="playit">Play</button>
<button id="removeit">Remove</button>
<div id="PLAYER_DIV_ID"></div>

JavaScript

var options = {
   width: 854,
   height: 480
};
var player = new Twitch.Player("PLAYER_DIV_ID", options);
document.getElementById('PLAYER_DIV_ID').style.display = 'none'; // or your own hide/show method

document.getElementById('playit').onclick = function() {
	document.getElementById('PLAYER_DIV_ID').style.display = 'block';
  player.setChannel('twitchpresents');
  player.play();
}

document.getElementById('removeit').onclick = function() {
	document.getElementById('PLAYER_DIV_ID').style.display = 'none';
	player.pause();
}