youtube iframe api with jquery

I’ve only used the jsapi once, but I think you have to add an id to the end of your src string like this:

http://www.youtube.com/e/VIDEO_ID?enablejsapi=1&version=3&playerapiid=ytplayer

Then catching the reference to the player:

function onYouTubePlayerReady(playerId)  {
      
      ytplayer = document.getElementById("myytplayer");

}

But the problem with this is that the video is loaded in an iframe and communicating becomes tricky. I haven’t tried this before but here’s a possible solution: