AP - pause youtube video with button

Hi Michael,

Youtube doesn’t allow cross-domain access to its content so you can’t simulate a click or key stroke to play/pause the video.
However, I found out that Youtube allows to get the video player from the iframe, so you can get the player and control the video.

var ytIframeId = $(prez.object('YouTube_1').node).find('iframe').attr('id');
var ytPlayer = YT.get(ytIframeId);
var playerState = ytPlayer.getPlayerState();
if (playerState == 1) // playing
  ytPlayer.pauseVideo();
else if (playerState == 2 || playerState == 5) // paused or cued
  ytPlayer.playVideo();

Regards