Hello,
I'm playing around with YouTubes Javascript API. I've set up a test page on my local enviornment, but the play function is not working. The video loads, and I can press play on the yt video screen, but my link "play" isn't working. Can someone tell me what I'm doing wrong??
I've been following this: http://code.google.com/apis/youtube/js_api_reference.html
<html>
<head>
<script type="text/javascript" src="public/javascripts/swfobject.js"></script>
</head>
<body>
<div id="ytapiplayer">
You will need Flash 8 or better to view this content.
</div>
<script type="text/javascript">
var params = { allowScriptAccess: "always" };
var atts = { id: "myytplayer" };
swfobject.embedSWF("http://www.youtube.com/v/OQSNhk5ICTI&enablejsapi=1&playerapiid=ytplayer", "ytapiplayer", "425", "365", "8", null, null, params, atts);
function onYouTubePlayerReady(playerId) {
ytplayer = document.getElementById("myytplayer");
}
function play() {
if (ytplayer) {
ytplayer.playVideo();
}
}
</script>
<a href="javascript:void(0);" onclick="play();">Play</a>
</body>
</html>