streamroot / videojs-hlsjs-plugin

hls.js Source Handler for video.js 5
http://www.streamroot.io
MIT License
155 stars 80 forks source link

Extend hlsjsConfig with ability to ignore errors #102

Open stevendesu opened 5 years ago

stevendesu commented 5 years ago

Currently when a fatal error is thrown and cannot be recovered, _hls.destroy() is called, tech.error is set, and the error event is triggered. This basically halts all playback, forces an error display on the player, and makes recovery nearly impossible.

In some cases people may want to implement their own recovery logic - particularly if they have unique insights into the reason for the failure, or a special fallback case. In my case, a stream had two different M3U8 URLs. When one failed to play, the other could be used as a backup (different cameras for the same event). I therefore wishes to intercept the HLS error event and, if fatal, switch to the other camera, seek to the same currentTime(), and continue playback.

It would be nice if the entire _onError method were optional, perhaps with something like:

    var options = {
        html5: {
            hlsjsConfig: {
                ignoreErrors: true
            }
        }
    };
stevendesu commented 5 years ago

In particular, I would even like to prevent videojs-hlsjs-plugin from calling _hls.recoverMediaError(), as this unloads and reloads the video, putting a play button in front of the user - which is rather confusing during a live stream (and arguably confusing even during VOD without any messaging to explain why their video just started over)