Use JWPlayer to failover your streams

If you’d like a more client-side way to failover your streams you can define an onError event handler within JWPlayer to handle this event.

1. Fail over after error occurs with the playback:

jwplayer("myElement").setup({
       file: "https://[wowzaserver1]/vod/mp4:sample.mp4/playlist.m3u8"
});
jwplayer("myElement").onError(function(){ 
       jwplayer("myElement").load([{file:"http://[wowzaserver2]/vod/mp4:sample.mp4/playlist.m3u8"}]);
       jwplayer("myElement").play();
});

2. If your stream is buffering a lot and you’d like to failover if the buffering exceeds x amount of seconds, you can do the following:


jwplayer("myElement").onBuffer(function(event){
       var currentBuffer = jwplayer("myElement").getBuffer();
       // if currentBuffer >0 or rising you may consider failing over 
}); 

Comments are closed.