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

Show other playlist item on error


Hello, when player can't play source it will generate onError event. In that event I want to show next playlist item. Player only changes info but does not start playing this new item.

jwplayer("myvideo").on('error', function (message) {
jwplayer("myvideo")
.stop()
.playlistItem(currIndex + 1) // Changes information, like Title and description, still can see exclamation mark
.play(true)
;
});

When doing `.load({file: url})` it's working, but removing all playlists.
Any ideas how to fix that? Using JW v7.2.4

4 Community Answers

Alex

JW Player Support Agent  
1 rated :

Hi, there.

You should be able to accomplish this by using the .getPlaylistIndex() and .playlistItem() calls like this:

var playerInstance = jwplayer("myvideo");

playerInstance.on("error", function() {
  var currentIndex = playerInstance.getPlaylistIndex();
  var nextIndex = currentIndex + 1;
  playerInstance.playlistItem(nextIndex);
});

I’ve tested this on my local environment and it worked.

letherton

User  
0 rated :

Is it possible to have associated array as playlists? {"48":{...}, "56": {...}} or do I have to keep it as indexed array?

letherton

User  
0 rated :

I have simulated most simple example. Still not working.
Output from console:

--START OF TEST--
12:59:27.699 Runing player with #0
12:59:28.269 HTTP "Content-Type" of "video/quicktime" is not supported. Load of media resource https://example.com failed.
12:59:28.283 Error playing media: MediaError { code: 4 } " https://example.com" jwplayer.js:1:16380
12:59:28.285 Runing player with #1

My code:

$(document).ready(function () {
console.log('--START OF TEST--');

playerInstance = jwplayer("myvideo").setup({
width: $("#video").width(),
height: 365,
playlist: playlistsJson,
autostart: false
});

test(0);

playerInstance.on('error', function (message) {
test(1);
});
});


function test(index) {
console.log('Runing player with #'+index);

playerInstance.playlistItem(index);
}

As you can see on second video I do not receive any errors. But still on player I see correct title with exclamation mark and no video playing.

What am I doing wrong?

Alex

JW Player Support Agent  
0 rated :

I did not see any videos attached. Can you please give me a link to a page where you have the affected player installed? That will help me troubleshoot your issue.

Thank you.

This question has received the maximum number of answers.