From ebb3491005ba50b0bf8a76ca55bc814eff00ea2e Mon Sep 17 00:00:00 2001 From: Trevor Mears Date: Sun, 28 Dec 2025 01:35:17 -0800 Subject: [PATCH] Added non-fatal media error recovery and buffer stall recovery --- public/js/components/VideoPlayer.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/public/js/components/VideoPlayer.js b/public/js/components/VideoPlayer.js index 5939eba..85237ae 100644 --- a/public/js/components/VideoPlayer.js +++ b/public/js/components/VideoPlayer.js @@ -125,9 +125,24 @@ class VideoPlayer { this.stop(); break; } + } else if (data.type === Hls.ErrorTypes.MEDIA_ERROR) { + // Non-fatal media error - try to recover (handles audio codec issues) + console.log('Non-fatal media error, attempting recovery...'); + this.hls.recoverMediaError(); } }); + // Detect audio track switches (can cause audio glitches on some streams) + this.hls.on(Hls.Events.AUDIO_TRACK_SWITCHED, (event, data) => { + console.log('Audio track switched:', data); + }); + + // Detect buffer stalls which may indicate codec issues + this.hls.on(Hls.Events.BUFFER_STALLED_ERROR, () => { + console.log('Buffer stalled, attempting recovery...'); + this.hls.recoverMediaError(); + }); + this.hls.on(Hls.Events.MANIFEST_PARSED, () => { this.video.play().catch(e => console.log('Autoplay prevented:', e)); });