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

Running JS on second video on playlist starting


We've spent the last day or so trying to work this out and haven't had any luck so far. We're trying to make some JS get fired only when the second video in a playlist is played. We've tried the following:

jwplayer().on('playlistItem', function (index, playlist)
if (index == 1) {
// do stuff
}
});

and

jwplayer().on('playlistItem', function (obj) {
if (obj.index == 1) {
//do stuff
}
});

Neither seem to be running the code - has anyone got any ideas what we're doing wrong?

Thanks.

1 Community Answers

George

JW Player Support Agent  
0 rated :

Hey Jack,

Mind sending me a test page that’s giving you trouble and telling more about what you’re trying to accomplish? The code below runs fine for me.
var playerone = jwplayer(“container”);
playerone.setup({…});
playerone.on(“playlistItem”,function(x){
if(x.index==1){
alert(“next item”);
}
});

This question has received the maximum number of answers.