mirror of
https://github.com/truewhile/MeBox.git
synced 2026-09-29 11:36:36 +08:00
bug处理
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user