增加随机时间戳防止测速缓存

This commit is contained in:
mtvpls
2026-01-22 14:26:51 +08:00
parent 8472685b81
commit e90fb5034b

View File

@@ -308,6 +308,14 @@ export async function getVideoResolutionFromM3u8(
}
});
// 为分片请求添加时间戳参数破除浏览器缓存
hls.config.xhrSetup = function(xhr: XMLHttpRequest, url: string) {
const urlWithTimestamp = url.includes('?')
? `${url}&_t=${Date.now()}`
: `${url}?_t=${Date.now()}`;
xhr.open('GET', urlWithTimestamp, true);
};
hls.loadSource(m3u8Url);
hls.attachMedia(video);