mirror of
https://github.com/MoonTechLab/LunaTV.git
synced 2026-05-20 04:47:30 +08:00
fix: try to fix stall
This commit is contained in:
@@ -1195,24 +1195,6 @@ function PlayPageClient() {
|
|||||||
// 调用父类构造函数
|
// 调用父类构造函数
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
super(config);
|
super(config);
|
||||||
|
|
||||||
// 监听 Hls 错误事件,捕获 bufferStalledError 并尝试跳过
|
|
||||||
this.on(Hls.Events.ERROR, (_evt: any, data: any) => {
|
|
||||||
if (
|
|
||||||
data?.details === Hls.ErrorDetails.BUFFER_STALLED_ERROR ||
|
|
||||||
data?.details === Hls.ErrorDetails.BUFFER_SEEK_OVER_HOLE
|
|
||||||
) {
|
|
||||||
try {
|
|
||||||
const media = (this as any).media as HTMLMediaElement | undefined;
|
|
||||||
if (media && !media.seeking) {
|
|
||||||
// 前跳 1 秒,跳过当前卡顿的分片
|
|
||||||
media.currentTime = media.currentTime + 1;
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.warn('尝试跳过卡顿分片失败:', err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
attachMedia(media: HTMLMediaElement): void {
|
attachMedia(media: HTMLMediaElement): void {
|
||||||
|
|||||||
Reference in New Issue
Block a user