Having trouble with the YouTube player OnStateChange event not firing. I've researched similar posts but none seem to match my unique situation since I'm using a different version (chromeless JavaScript).
Here's the HTML:
<div id="ytapiplayer">
You need Flash player 8+ and JavaScript enabled to view this video.
</div>
And the JavaScript:
var params = { allowScriptAccess: "always", wmode: "Opaque" };
var atts = { id: "player" };
swfobject.embedSWF("http://www.youtube.com/apiplayer?enablejsapi=1&version=3",
"ytapiplayer", "100%", "100%", "8", null, null, params, atts);
function onYouTubePlayerReady(playerId){
player = document.getElementById("player");
}
Following the documentation example, I then do:
var player = document.getElementById('player');
Everything works fine, except that when the state changes, the OnStateChange event does not seem to fire. Here's the code in question:
document.getElementById('player').addEventListener('OnStateChange',
function(new_state){
console.log(new_state);
}
)
However, the new state never gets printed out. Am I missing something? http://jsfiddle.net/8QtrC/1/