From e90fb5034b98433321c4a73a69fdab6d8cbbd09d Mon Sep 17 00:00:00 2001 From: mtvpls Date: Thu, 22 Jan 2026 14:26:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=9A=8F=E6=9C=BA=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E6=88=B3=E9=98=B2=E6=AD=A2=E6=B5=8B=E9=80=9F=E7=BC=93?= =?UTF-8?q?=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/utils.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/lib/utils.ts b/src/lib/utils.ts index 9064315..b43c9cc 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -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);