I'm trying to find a way to get the YouTube Player API to work multible times on a single page, for eq: the div and the player gets loaded (works fine), then removed, then readded (only loads the player, it returns an object/ sets player
to an object that does not contain the API functions).
<div id="videoDiv"></div>
if (typeof t === "undefined") {
t = document.createElement('script');
t.src = 'https://www.youtube.com/iframe_api';
s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(t, s);
} else {
player.destroy();
onYouTubeIframeAPIReady()
};
var player;
function onYouTubeIframeAPIReady() {
player = new YT.Player('videoDiv',
{
videoId: '',
playerVars: {
'playsinline': 1
}
})
}