Avoid too many errors in client on fast-restream

pull/6544/head
Chocobozzz 2024-08-08 15:22:55 +02:00
parent 62bf86c186
commit da3420ac40
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
2 changed files with 24 additions and 0 deletions

View File

@ -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.live
this.dvrDuration = data.details.totalduration

View File

@ -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)