Troubleshooting YouTube onYouTubeIframeAPIReady() and onPlayerStateChange()
FYI => “YouTube Player API Reference for <iframe> Embeds”
In typical Google documentation style there are a couple important details you’ll need to know that don’t exactly jump off the page—especially is you’re working as hard as you are skimming to get things working.
“If you do write the <iframe> tag, then when you construct the YT.Player object, you do not need to specify values for the width and height, which are specified as attributes of the <iframe> tag, or the videoId and player parameters, which are are specified in the src URL.”
And perhaps it’s somewhere in the YouTube API docs but for:
player = new YT.Player(‘player’,…
the ‘player’ (i.e., the one in quotes) is the id=” ” of your YouTube iframe object. Perhaps that’s obvious to seasoned YouTube API junkies but perhaps that’s not you.