The docs say we should use a div container where the <iframe>
element will be appended.
That works:
new YT.Player('player', {
height: '390',
width: '640',
videoId: 'M7lc1UVf-VE',
events: {
onReady: onPlayerReady,
onStateChange: onPlayerStateChange
}
});
But I should have an element <div id="player"></div>
on the page.
Is it possible that if I already have the iframe element with the embedded video to use that iframe in the YT.Player
constructor?
I would like to have something like this:
new YT.Player('iframeId').playVideo();
But the playVideo
isn't there because the player is not loading (I guess that's happening because we are providing the iframe id).
Is there a way to connect an existing iframe with the YT.Player instance?