Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

playlist not ready when onReady is called


Your docs say: "playlist is loaded when onReady is called"
http://support.jwplayer.com/customer/portal/articles/2051720-javascript-api-reference-legacy#playlist

However this is not the case.
jwplayer().onReady(jwplayer().getPlaylist());
is undefined.

Workaround is a setTimeout delay of 100ms (surely works for every client?), which you stated here:
http://support.jwplayer.com/customer/portal/questions/10523831-play-call-not-being-run-in-jwplayer-onload-

Also stated that this should be fixed in JW 6.12, which is not.

live example:
http://jsbin.com/pequwa/2/edit?html,js,console,output

The reason we need this:
We want to add specific tracking to Google Analytics using your API events. We also want to add the title of the video to each tracking event to see in GA which video caused the event.

As far as I know I can only get the title with:
jwplayer().getPlaylist()[0].title
(we have only one file present in playlist)

The workaround seems to work but I'm not sure if this will do for each client.
Additionally now we can't track the autostart via onPlay() since the title is not defined yet. And after 100ms the autostart won't fire onPlay() anymore.

We need JW 6 as fallback for IE8 and IE7 so this needs to work.

1 Community Answers

Alex

JW Player Support Agent  
0 rated :

Hi,

I was able to get your event to log the playlist array when I wrapped the console.log() method in a function. Here is the code that worked for me:

jwplayer().onReady(function() {console.log(’onReady: ’ + jwplayer().getPlaylist());});

Please let me know if you need any more help or have any other questions.

Thank you!

This question has received the maximum number of answers.