I'm using the youtube player api. I'm following the doc here:
http://code.google.com/apis/youtube/js_api_reference.html
having a problem adding an event listener on the player, it seems to just get stuck there. I put an alert statement directly after, which never gets called:
ytplayer.addEventListener("onStateChange", "onytplayerStateChange");
alert("I never get called...");
any idea why this would happen? Running it through FF chrome safari, same thing happens on all. Other player features all work fine. I'm using the swfobject version. I'm running this live from a server too. I don't get it.
Thanks
take a look at the source code of this page, may be it will get you going in the right direction. The number under the video is the state of the video caught and updated the way you are trying to implement
http://goo.gl/b93ns
Place your callback in the global namespace, eg window.onytplayerStateChange = function.
While its pretty crappy its one of the few ways i was able to successfully get the callback to work. I was told its because the addEventListener is a custom function overriding the native code that does a lookup via string in the global namespace.
I think it's a bug. Here's the solution that worked for me:
In the Player URL, you must include a '&' after the ?. So the example is this:
VIDEO_ID?enablejsapi=1&playerapiid=ytplayer
But use this instead:
VIDEO_ID?&enablejsapi=1&playerapiid=ytplayer
(note the & before 'enable')
Doesn't make much sense, but it's working now :)
Try using Firebug http://getfirebug.com/ for FireFox, it should help you find any javascript errors. I'm having problems with the youtube event listeners too but mine work in Firefox.