ActivityPub-federated video streaming platform using P2P directly in your web browser
Avoid too many errors in client on fast-restream
Chocobozzzda3420ac4096
diff --git a/client/src/assets/player/shared/p2p-media-loader/hls-plugin.ts b/client/src/assets/player/shared/p2p-media-loader/hls-plugin.tsindex ca4637f497..e158d650c3 100644--- a/client/src/assets/player/shared/p2p-media-loader/hls-plugin.ts+++ b/client/src/assets/player/shared/p2p-media-loader/hls-plugin.ts@@ -411,6 +411,10 @@ export class Html5Hlsjs {this.edgeMargin = this.hlsjsConfig.liveSyncDurationCount * data.details.targetduration}+ if (this.isLive && !data.details.live) {+ this.player.trigger('hlsjs-live-ended')+ }+this.isLive = data.details.livethis.dvrDuration = data.details.totaldurationdiff --git a/client/src/assets/player/shared/p2p-media-loader/p2p-media-loader-plugin.ts b/client/src/assets/player/shared/p2p-media-loader/p2p-media-loader-plugin.tsindex 591497df5c..e217d06daf 100644--- a/client/src/assets/player/shared/p2p-media-loader/p2p-media-loader-plugin.ts+++ b/client/src/assets/player/shared/p2p-media-loader/p2p-media-loader-plugin.ts@@ -31,6 +31,8 @@ class P2pMediaLoaderPlugin extends Plugin {private networkInfoInterval: any+ private liveEnded = false+constructor (player: videojs.Player, options?: P2PMediaLoaderPluginOptions) {super(player)@@ -75,8 +77,21 @@ class P2pMediaLoaderPlugin extends Plugin {player.on('hlsjs-initialized', onHLSJSInitialized)+ // ---------------------------------------------------------------------------++ const onHLSJSLiveEnded = () => {+ debugLogger('hls.js says the live is ended')++ this.liveEnded = true+ }++ player.on('hlsjs-live-ended', onHLSJSLiveEnded)++ // ---------------------------------------------------------------------------+this.on('dispose', () => {this.player.off('hlsjs-initialized', onHLSJSInitialized)+ this.player.off('hlsjs-live-ended', onHLSJSLiveEnded)})}@@ -127,6 +142,11 @@ class P2pMediaLoaderPlugin extends Plugin {this.p2pEngine.on(Events.SegmentError, (segment: Segment, err) => {if (navigator.onLine === false) return+ // We may have errors if the live ended because of a fast-restream in the same permanent live+ if (this.liveEnded) {+ (this.player as any).handleTechEnded_()+ return+ }logger.error(`Segment ${segment.id} error.`, err)