bug处理

This commit is contained in:
truewhile
2026-09-07 23:21:24 +08:00
parent c4b8114115
commit 5a47e6f52d
7 changed files with 108 additions and 21 deletions
+5 -2
View File
@@ -148,8 +148,11 @@ export function streamURL(mediaId: string): string {
// hlsURL returns the m3u8 playlist URL fed into hls.js.
// startSec > 0 asks the server to (re)start ffmpeg from that source offset.
export function hlsURL(mediaId: string, startSec = 0): string {
const start = startSec > 0.05 ? `&start=${encodeURIComponent(String(Math.floor(startSec * 1000) / 1000))}` : ''
return `/api/hls/${encodeURIComponent(mediaId)}/index.m3u8?${tokenQuery()}${profileQuery()}${start}`
const start =
startSec > 0.05 ? `&start=${encodeURIComponent(String(Math.round(startSec * 1000) / 1000))}` : ''
// Cache-bust so a seek restart cannot reuse a stale start=0 playlist from disk/browser.
const bust = startSec > 0.05 ? `&_seek=${Date.now()}` : ''
return `/api/hls/${encodeURIComponent(mediaId)}/index.m3u8?${tokenQuery()}${profileQuery()}${start}${bust}`
}
// imageURL converts a remote poster URL into a same-origin proxy URL so it
+14 -3
View File
@@ -575,9 +575,20 @@ export function PlayerPage() {
if (!video) return false
const target = Math.max(0, absoluteSec)
const local = target - hlsStartSec
const available = Number.isFinite(video.duration) ? video.duration : 0
// Stay inside the already-transcoded window of this HLS session.
if (local >= 0 && local <= Math.max(0, available - 0.5)) {
// Live/EVENT HLS during transcoding often reports duration=Infinity.
// Never treat that as "already buffered" or currentTime seeks reset to 0.
const finiteDuration = Number.isFinite(video.duration) ? video.duration : 0
let seekableEnd = 0
if (video.seekable && video.seekable.length > 0) {
try {
seekableEnd = video.seekable.end(video.seekable.length - 1)
} catch {
seekableEnd = 0
}
}
if (!Number.isFinite(seekableEnd)) seekableEnd = 0
const windowEnd = Math.max(finiteDuration, seekableEnd)
if (local >= 0 && windowEnd > 0.5 && local <= windowEnd - 0.5) {
video.currentTime = local
return true
}