views:

180

answers:

3

Hi,

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

A: 

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.

Derek
A: 

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://plain7.com/test.htm

Raine
A: 

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 :)

Peter Watts