Added non-fatal media error recovery and buffer stall recovery

This commit is contained in:
Trevor Mears
2025-12-28 01:35:17 -08:00
parent a7e0db7a4f
commit ebb3491005
+15
View File
@@ -125,9 +125,24 @@ class VideoPlayer {
this.stop(); this.stop();
break; 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.hls.on(Hls.Events.MANIFEST_PARSED, () => {
this.video.play().catch(e => console.log('Autoplay prevented:', e)); this.video.play().catch(e => console.log('Autoplay prevented:', e));
}); });