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/app/+videos/+video-watch/video-watch.component.ts | 3 --- client/src/assets/player/p2p-media-loader/hls-plugin.ts | 7 ++++++- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'client') diff --git a/client/src/app/+videos/+video-watch/video-watch.component.ts b/client/src/app/+videos/+video-watch/video-watch.component.ts index 5fd095c36..1ee18f52f 100644 --- a/client/src/app/+videos/+video-watch/video-watch.component.ts +++ b/client/src/app/+videos/+video-watch/video-watch.component.ts @@ -688,9 +688,6 @@ export class VideoWatchComponent implements OnInit, OnDestroy { private handleLiveStateChange (newState: VideoState) { if (newState !== VideoState.PUBLISHED) return - const videoState = this.video.state.id - if (videoState !== VideoState.WAITING_FOR_LIVE && videoState !== VideoState.LIVE_ENDED) return - console.log('Loading video after live update.') const videoUUID = this.video.uuid 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