perf(player): add MpegTS auto-recovery and optimize initial buffer to prevent Stream Error

This commit is contained in:
Michael committed 2026-03-10 22:02:44 +01:00
1 parent b8922a2f08
commit 118887ab6f
2 files changed
+24 -4

No files matched your search

+9 -2
View File
@@ -292,13 +292,20 @@
if (!mpegts.isSupported()) return false;
const player = mpegts.createPlayer({ type: 'mpegts', isLive: isLive, url: url }, {
enableWorker: true,
stashInitialSize: 64 * 1024, // Turbo Start: 64KB initial buffer
stashInitialSize: 256 * 1024, // Optimized Turbo Start
maxStashSize: 20 * 1024 * 1024 // 20MB buffer capacity
});
player.attachMediaElement(video);
player.load();
player.play().catch(() => playOverlay.style.display = 'flex');
player.on(mpegts.Events.ERROR, () => showError('Stream error'));
player.on(mpegts.Events.ERROR, (type, detail) => {
log('MpegTS Error: ' + type + ' - ' + detail);
setTimeout(() => {
player.destroy();
playWithMpegTS(url, isLive);
}, 2000);
});
return true;
}