I'm trying to capture the YT object. The onYouTubePlayerReady() functions is called but I can't seem to do anything with the object.
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("swfobject", "2.2");
</script>
<script type="text/javascript">
function onYouTubePlayerReady (playerID)
{
ytplayer = document.getElementById(playerID);
}
function play ()
{
if (ytplayer)
{
ytplayer.playVideo();
}
}
play();
</script>
ytplayer is referenced to the DOM and not the video itself (play therefor throws Uncaught TypeError: Object # has no method 'playVideo', but this is basically the example given by google.
What am I doing wrong?