bug处理

This commit is contained in:
truewhile
2026-09-09 00:39:00 +08:00
parent ec5f81e6cb
commit 1ea29cca9e
6 changed files with 137 additions and 28 deletions
+4 -2
View File
@@ -13,9 +13,11 @@ export interface SubtitleTrack {
}
export const subtitlesAPI = {
list: (mediaId: string) =>
list: (mediaId: string, includeEmbedded = false) =>
api
.get<{ tracks: SubtitleTrack[] | null }>(`/media/${mediaId}/subtitles`)
.get<{ tracks: SubtitleTrack[] | null }>(`/media/${mediaId}/subtitles`, {
params: includeEmbedded ? { include_embedded: 'true' } : undefined,
})
.then((r) => r.data.tracks ?? []),
url: (mediaId: string, path: string) => {
+17 -6
View File
@@ -237,8 +237,22 @@ export function PlayerPage() {
// 404 / 无权限等:给出可见错误提示,避免永久「加载中」
setLoadError(`无法加载该媒体:${apiErrorMessage(err)}`)
})
return () => {
cancelled = true
}
}, [id, modeParam, directOnly])
// Wire up the actual <video> element when we know the mode.
// Depend on media.id (not the media object): refreshing duration after
// MANIFEST_PARSED must not remount HLS or it storms EnsureJob / DELETE.
const mediaId = media?.id
// 直连播放只发现外挂字幕;只有 HLS 模式需要探测可烧录的内嵌字幕。
useEffect(() => {
if (!mediaId) return
let cancelled = false
subtitlesAPI
.list(id)
.list(mediaId, mode === 'hls')
.then((tracks) => {
if (cancelled) return
const list = tracks ?? []
@@ -249,16 +263,13 @@ export function PlayerPage() {
.catch(() => {
if (cancelled) return
setSubs([])
setSubtitleIndex(-1)
})
return () => {
cancelled = true
}
}, [id, modeParam, directOnly])
}, [mediaId, mode])
// Wire up the actual <video> element when we know the mode.
// Depend on media.id (not the media object): refreshing duration after
// MANIFEST_PARSED must not remount HLS or it storms EnsureJob / DELETE.
const mediaId = media?.id
const selectedSubtitle = subtitleIndex >= 0 ? subs[subtitleIndex] : undefined
const burnedSubtitleStream =
selectedSubtitle?.delivery === 'burn' ? selectedSubtitle.stream_index : undefined