]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/assets/player/p2p-media-loader/hls-plugin.ts
Fast forward on HLS decode error
[github/Chocobozzz/PeerTube.git] / client / src / assets / player / p2p-media-loader / hls-plugin.ts
index 421ce4934d2a11016aef55599318169f5bdb1009..ae31bcfe176fc78ece41142170c7c36c9df4843a 100644 (file)
@@ -89,6 +89,8 @@ class Html5Hlsjs {
   private readonly source: videojs.Tech.SourceObject
   private readonly vjs: typeof videojs
 
+  private maxNetworkErrorRecovery = 5
+
   private hls: Hlsjs
   private hlsjsConfig: Partial<HlsConfig & { cueHandler: any }> = null
 
@@ -172,6 +174,12 @@ class Html5Hlsjs {
   dispose () {
     this.videoElement.removeEventListener('play', this.handlers.play)
 
+    // FIXME: https://github.com/video-dev/hls.js/issues/4092
+    const untypedHLS = this.hls as any
+    untypedHLS.log = untypedHLS.warn = () => {
+      // empty
+    }
+
     this.hls.destroy()
   }
 
@@ -225,7 +233,7 @@ class Html5Hlsjs {
   }
 
   private _handleNetworkError (error: any) {
-    if (this.errorCounts[Hlsjs.ErrorTypes.NETWORK_ERROR] <= 5) {
+    if (this.errorCounts[Hlsjs.ErrorTypes.NETWORK_ERROR] <= this.maxNetworkErrorRecovery) {
       console.info('trying to recover network error')
 
       // Wait 1 second and retry
@@ -371,6 +379,9 @@ class Html5Hlsjs {
       this.dvrDuration = data.details.totalduration
 
       this._duration = this.isLive ? Infinity : data.details.totalduration
+
+      // Increase network error recovery for lives since they can be broken (server restart, stream interruption etc)
+      if (this.isLive) this.maxNetworkErrorRecovery = 300
     })
 
     this.hls.once(Hlsjs.Events.FRAG_LOADED, () => {