Videojs - reconnect live stream automatically

When you attempt to play live stream, but media server is down or disconnected the the video.js player keeps loading playlist continuously every 5 seconds about. If you leave the website page in this state or try to reconnect media server by reloading video source programmatically, after few minutes the browser may crash due to lack of memory.

Videojs fires "retryplaylist" event every 5 seconds about, when the only one HLS playlist or final rendition of the HLS playlist failed to load media file. In Nuevo plugin (from version 6.0.1) we have added a few options to limit the number of playlist loading retries and play "offline" video once the limit reached. When "offline" video ended, the browser is automatically refreshed and attempts to load Hls playlist again.

In the example above after first playlist retry error "offline" MP4 video is loaded and playing for 60 seconds. Once video finished website page is reloaded and player attempts to load playlist once again.

The user can decide about the number of playlist load retries (suggested minimum is 2) and MP4 offline video to play through Nuevo plugin options.

Code Snippet
player.nuevo({ retryNumber:2, retryVideo: '//path-to-offline-video.mp4' });

The idea with offline video after playlist loading error is not perfect, but certainly better than showing black video and risking a browser's crash. Unfortunately, this solution does not work on iOS browsers as iOS use native HLS streaming and doesn't fire playlist retry event.

If you have better idea, you can always listen to retryplaylist error or other player error and take appropriate action.

Nuevodevel Blog
Nuevodevel Tweeter