Recover Chromium HLS audio at ad discontinuities

This commit is contained in:
Technomancer702
2026-10-13 17:23:00 -07:00
parent 035667cfba
commit b9dad30f06
14 changed files with 454 additions and 216 deletions

View File

@ -606,6 +606,10 @@ class WatchPage {
});
const hls = this.hls, generation = this.playbackGeneration;
this.audioRecovery?.dispose();
this.audioRecovery = new HlsAudioRecovery(hls, this.video, Hls.Events,
() => this.hls === hls && this.playbackGeneration === generation,
{ beforeRecovery: () => this.getCaptionTracks().prepareMediaRecovery() });
this.getCaptionTracks().bindHls(hls, Hls.Events);
this.hls.loadSource(url);
this.hls.attachMedia(this.video);
@ -619,6 +623,9 @@ class WatchPage {
this.hls.on(Hls.Events.ERROR, (event, data) => {
if (this.hls !== hls || this.playbackGeneration !== generation) return;
const mediaError = data.type === Hls.ErrorTypes.MEDIA_ERROR;
const needsRecovery = mediaError && (data.fatal || ['bufferAppendError', 'bufferAppendingError', 'fragParsingError'].includes(data.details));
if (needsRecovery && this.audioRecovery.requestRecovery('media error')) return;
if (data.fatal) {
console.error('[WatchPage] HLS fatal error:', data);
// Try proxy on CORS error (only if not already proxied/transcoded)
@ -646,6 +653,8 @@ class WatchPage {
stop() {
this.playbackGeneration = (this.playbackGeneration || 0) + 1;
this.audioRecovery?.dispose();
this.audioRecovery = null;
// Stop history tracking and save final progress
this.stopHistoryTracking();
this.saveProgress();