fix hdr playback, lint warnings

This commit is contained in:
2026-06-04 22:50:46 +03:00
parent 2fce5dfb59
commit 6756bf9d40
10 changed files with 144 additions and 72 deletions
+16 -11
View File
@@ -347,17 +347,19 @@ export default function PlayerPage() {
* the resume condition once per item, not re-trigger when item data
* refreshes or prefs change mid-playback. */
const resumePromptShownRef = useRef<string | null>(null)
const resumeItemId = item?.Id
const resumePositionTicks = item?.UserData?.PlaybackPositionTicks
useEffect(() => {
if (!item || resumePromptShownRef.current === item.Id) return
const pos = Number(item.UserData?.PlaybackPositionTicks ?? 0)
if (!resumeItemId || resumePromptShownRef.current === resumeItemId) return
const pos = Number(resumePositionTicks ?? 0)
const thresholdSec = usePreferencesStore.getState().resumeThresholdSec ?? 5
const threshold = thresholdSec * 10_000_000
const fromQueue = searchParams.get('resume') === 'true'
if (showResumePromptPref && !fromQueue && pos > threshold) {
setResumePromptOpen(true)
resumePromptShownRef.current = item.Id ?? null
resumePromptShownRef.current = resumeItemId
}
}, [item?.Id, searchParams, showResumePromptPref])
}, [resumeItemId, resumePositionTicks, searchParams, showResumePromptPref])
/* Auto-rewatch counter: when an already-played item starts playing
* again, record the rewatch. We trip it at most once per item-mount
@@ -645,23 +647,26 @@ export default function PlayerPage() {
const currentMarker: Marker | undefined = markers.find(
m => currentTime >= m.startSec && currentTime < m.endSec - 0.5,
)
const currentMarkerType = currentMarker?.type
const currentMarkerStartSec = currentMarker?.startSec
const currentMarkerEndSec = currentMarker?.endSec
/* Auto-skip when entering a marker AND the corresponding pref is on.
* Also accumulate the skipped seconds into the per-series tally so the
* detail page can surface a "you saved Xh Ym" badge. */
useEffect(() => {
if (!currentMarker || !playerRef.current) return
if (!currentMarkerType || currentMarkerEndSec == null || !playerRef.current) return
const p = playerRef.current
const from = p.currentTime
if (currentMarker.type === 'intro' && skipIntros) {
p.currentTime = currentMarker.endSec
if (seriesId) recordSkippedSeconds(seriesId, 'intro', currentMarker.endSec - from)
} else if (currentMarker.type === 'credits' && skipCredits && duration > 0) {
const target = Math.max(currentMarker.endSec, duration - 0.5)
if (currentMarkerType === 'intro' && skipIntros) {
p.currentTime = currentMarkerEndSec
if (seriesId) recordSkippedSeconds(seriesId, 'intro', currentMarkerEndSec - from)
} else if (currentMarkerType === 'credits' && skipCredits && duration > 0) {
const target = Math.max(currentMarkerEndSec, duration - 0.5)
p.currentTime = target
if (seriesId) recordSkippedSeconds(seriesId, 'credits', target - from)
}
}, [currentMarker?.type, currentMarker?.startSec, skipIntros, skipCredits, duration, seriesId])
}, [currentMarkerType, currentMarkerStartSec, currentMarkerEndSec, skipIntros, skipCredits, duration, seriesId])
/* Imperatively switch the active subtitle track. We use 'hidden' rather
* than 'showing' so the browser doesn't paint its own caption UI over our