Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3831

YouTube Player API fails on 2th div/ iframe

$
0
0

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      }    })}
player object after first load:player object after second load:
player object after first loadplayer object after second load

Viewing all articles
Browse latest Browse all 3831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>