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

Resume live stream - onError() not triggered when stream is down


Hello everyone,

I have a question about resuming auto playing and resuming live streams.
The thing is, when stream is disconnected during playback, the video just freezes and noting happens, onError event is not even triggered. It should show message and try to reload the video every 5 seconds.
I am using auto-start so it should resume when source is available.

If I click anywhere on the player or refresh the page, onError is triggered correctly and when stream is available it auto resumes, as intended.

The SAME code works for rmtp stream with one file, but hear I am using .m3u8 with 2 fallbacks.
Do you have any idea, why jwplayer().onError(..) is not triggered?

Thank you for all your answers in advance!

Br, Klemen

My code:

jwplayer(window.playerDiv).setup({
'id': 'playerID',
playlist: [{
'image': '/portal/img_new/video/PosnetekVzivo_710x432.png',
'sources': [{
file: 'http://fms1.arnes.si/vp_611_9d0d/ngrp:live_all/playlist.m3u8'
},{
file: 'http://fms1.arnes.si/vp_611_9d0d/ngrp:live_all/jwplayer.smil'
},{
file: 'rtmp://fms1.arnes.si/vp_611_9d0d/live'
}]
}],
'logo': {
file: 'mmplayer/arnes-video-logo.png',
hide:'true',
position: 'top-right',
margin:'15'
},
'width': '710',
'height': '432',
'flashplayer':'https://video-test.arnes.si/portal/mmplayer/player.swf',
'html5player':'https://video-test.arnes.si/portal/mmplayer/jwplayer.html5.js',
'autostart': true,
'primary': 'flash'
});
jwplayer().onError(function () {
location.reload();
showOnStreamDownNotification();
waitAndLoad();
});

function waitAndLoad(){

setTimeout(loadFile, 5000) //wait 5 seconds before continuing
}

function loadFile(){
var playlist = jwplayer().getPlaylist();
jwplayer().load(playlist);
}

6 Community Answers

video-podpora

User  
0 rated :

I should also mention that location.reload() inside onError is just for testing, it works without it with simple rmtp stream.

Andrew

JW Player Support Agent  
1 rated :

Hi,

Just to be clear, when a stream is not running, are you not providing TS files? Or is the manifest itself unable to be accessed?

Currently, the player’s behavior is to not error out if a TS file is absent. This is included to attempt to continue playback in the event of a stream render error. Potentially, you may be able to use onBuffer similar to our example here:
support.jwplayer.com/customer/portal/articles/1442607-example-a-custom-error-message

video-podpora

User  
0 rated :

Thanks for the answer and information about onError().

I am now trying with onBuffer() but the problem I have is that it runs every 5 seconds regardles if the stream is ON or OFF, therefore it keeps reloading player during the stream.

Everything else seems to work, it auto starts when I open the player if the stream is ON, it auto-resumes when the stream is back.

Is this the problem with stream? Should I add something to player setup config?

My code now with only onBuffer() event:

jwplayer(window.playerDiv).setup({
'id': 'playerID',
playlist: [{
'image': 'test.png',
'sources': [{
file: 'http://.../ngrp:live_all/playlist.m3u8'
},{
file: 'http://.../jwplayer.smil'
},{
file: 'rtmp:/.../live'
}]
}],
'flashplayer':'https://.../player.swf',
'html5player':'https://.../jwplayer.html5.js',
'autostart': true,
'primary': 'flash'
});

jwplayer().onBuffer(function(){
theTimeout = setTimeout(function(){
showOnStreamDownNotification();
jwplayer().load(jwplayer().getPlaylist());
},5000);
});


Thank you in advance for answer,

Br, Klemen



Andrew

JW Player Support Agent  
0 rated :

Hi,

Is there any way that you’d be able to place this on a page for us to look at?

video-podpora

User  
0 rated :

Unfortunately the website is in a closed network as it is a test environment with java backend and wowza service.

But I figured out a quick solution that seems to work with fallbacks, as onBuffer() only works with HLS I also need onError() to support fallbacks.

I am now checking the state of a player before reloading.

jwplayer().onError(function(){
theTimeout = setTimeout(function(){
if(jwplayer().getState()=="IDLE"){
showOnStreamDownNotification();
jwplayer().load(jwplayer().getPlaylist());
}
},5000);
});

jwplayer().onBuffer(function(){
theTimeout = setTimeout(function(){
if(jwplayer().getState()=="BUFFERING"){
showOnStreamDownNotification();
jwplayer().load(jwplayer().getPlaylist());
}
},5000);
});

The thing is onBuffer event is triggering far too often and the player might already be in a PLAYING state but the reload will still happen.


Andrew

JW Player Support Agent  
0 rated :

You can do something with onBufferChange and its callback to determine the status.
http://support.jwplayer.com/customer/portal/articles/1413089-javascript-api-reference#buffer

This question has received the maximum number of answers.