I'm tyring to embed a youtube video using swfobject. I've written a function so that the video plays when a link is clicked. Everything works like a charm in firefox, but in IE6, it says 'ytplayer is undefined' and the video loads, but does not play. Where am I going wrong? Here's the .js file:
var params = { allowScriptAccess: "always" };
var atts = { id: "myytplayer" };
swfobject.embedSWF(vidurl, "ytplayer", "470", "350", "8", null, null, params, atts);
function onYouTubePlayerReady(playerId) {
ytplayer = document.getElementById("myytplayer");
}
function play() {
document.getElementById('videooverlay').style.display="none";
document.getElementById('playbutton').style.display="none";
ytplayer.playVideo();
}