There are multiple YT.player objects created on different elements on the same page.
player1 = new YT.Player( 'player-1' , {...
player2 = new YT.Player( 'player-2' , {...
player3 = new YT.Player( 'player-3' , {...
Some divs visibility is changeable via Javascript. On some browsers (e.g. IE 11) the onPlayerReady callback of the Youtube Iframe API is only called once the DIV becomes visible.
// 4. The API will call this function when the video player is ready.
function onPlayerReady(event) {
event.target.playVideo();
}
Is there some build in check to see wether the YT.player object has been readied or not?
In other words can I check player-1, player-2, player-3 before I call for example stopVideo on them? Because if I call
player-3.stopVideo()
and player-3 has not received an onPlayerReady event, I get an "unknown Method stopVideo()"-Exception.