From 077a413ff826c3bf2db01bb4b0cda04af47aeef7 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 19 Jan 2022 10:44:12 +0100 Subject: Automatically restart live on server/live restart --- client/src/assets/player/p2p-media-loader/hls-plugin.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'client/src/assets/player') diff --git a/client/src/assets/player/p2p-media-loader/hls-plugin.ts b/client/src/assets/player/p2p-media-loader/hls-plugin.ts index 421ce4934..640858025 100644 --- a/client/src/assets/player/p2p-media-loader/hls-plugin.ts +++ b/client/src/assets/player/p2p-media-loader/hls-plugin.ts @@ -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 = null @@ -225,7 +227,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 +373,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, () => { -- cgit v1.2.3