AirenSoft / OvenPlayer

OvenPlayer is JavaScript-based LLHLS and WebRTC Player for OvenMediaEngine.
https://airensoft.com/ome.html
MIT License
516 stars 126 forks source link

How can I implement the hls.recoverMediaError() method? #416

Open tanero opened 8 months ago

tanero commented 8 months ago

https://github.com/video-dev/hls.js/blob/master/docs/API.md#fatal-error-recovery

When a fatal error occurs, as in the example above, I want the hls.recoveryMediaError() method to run. However, after initializing the ovenplayer, I could not find how to access this method. Is there a way to solve?

hls.on(Hls.Events.ERROR, function (event, data) {
  if (data.fatal) {
    switch (data.type) {
      case Hls.ErrorTypes.MEDIA_ERROR:
        console.log('fatal media error encountered, try to recover');
        hls.recoverMediaError();
        break;
      case Hls.ErrorTypes.NETWORK_ERROR:
        console.error('fatal network error encountered', data);
        // All retries and media options have been exhausted.
        // Immediately trying to restart loading could cause loop loading.
        // Consider modifying loading policies to best fit your asset and network
        // conditions (manifestLoadPolicy, playlistLoadPolicy, fragLoadPolicy).
        break;
      default:
        // cannot recover
        hls.destroy();
        break;
    }
  }
});
SangwonOh commented 8 months ago

@tanero Hi!

Currently, when a fatal error occurs in Hls.js, OvenPlayer raise an error event. And you can't recover playback unless you call ovenplayer.load() again or recreate the player.

So, calling hls.recoverMediaError() when a fatal media error occurs is not yet supported. It seems difficult to support it right away because OvenPlayer's HLS error handling policy needs to be changed.

We will let you know again when various error handling becomes possible.