type pages and utilities

This commit is contained in:
2026-04-28 03:08:59 +03:00
parent 906120e6e6
commit 2589b695f1
17 changed files with 49 additions and 49 deletions
+19 -19
View File
@@ -247,7 +247,7 @@ export default function PlayerPage() {
} = usePlayerChrome(isPaused)
const subtitleStreams = item ? getSubtitleStreams(item) : []
const mediaSourceId = ((item as any)?.MediaSources?.[0]?.Id as string | undefined) || undefined
const mediaSourceId = item?.MediaSources?.[0]?.Id || undefined
const {
seriesId,
@@ -485,7 +485,7 @@ export default function PlayerPage() {
// on every meaningful state tick until the native volume actually
// matches the pref - that's the only reliable signal.
function getNativeVideo(): HTMLVideoElement | null {
const el = (player as any)?.el as HTMLElement | undefined
const el = (player as { el?: HTMLElement } | null)?.el
return (el?.querySelector('video') as HTMLVideoElement | null) || null
}
function applyVolume() {
@@ -594,7 +594,7 @@ export default function PlayerPage() {
// Fallback: chapters with intro/credits names
if (out.length === 0) {
const chapters = ((item as any)?.Chapters || []) as { Name?: string; StartPositionTicks?: number }[]
const chapters = (item?.Chapters || []) as { Name?: string; StartPositionTicks?: number }[]
if (chapters.length && duration) {
for (let i = 0; i < chapters.length; i++) {
const c = chapters[i]
@@ -670,7 +670,7 @@ export default function PlayerPage() {
}
// 2. Browser's native list on the underlying <video>
const el = (player as any).el as HTMLElement | undefined
const el = (player as { el?: HTMLElement } | null)?.el
const video = el?.querySelector?.('video') as HTMLVideoElement | null
if (video?.textTracks) {
for (let i = 0; i < video.textTracks.length; i++) {
@@ -749,13 +749,13 @@ export default function PlayerPage() {
/* ── Helpers: PiP, screenshot, theater, frame step, etc. ─── */
function togglePictureInPicture() {
const el = (playerRef.current as any)?.el as HTMLElement | undefined
const el = (playerRef.current as { el?: HTMLElement } | null)?.el
const video = el?.querySelector('video') as HTMLVideoElement | null
if (!video) return
if ((document as any).pictureInPictureElement === video) {
;(document as any).exitPictureInPicture?.().catch(() => {})
if (document.pictureInPictureElement === video) {
;document.exitPictureInPicture?.().catch(() => {})
} else {
;(video as any).requestPictureInPicture?.().catch(() => {})
;video.requestPictureInPicture?.().catch(() => {})
}
}
@@ -764,7 +764,7 @@ export default function PlayerPage() {
}
function takeScreenshot() {
const el = (playerRef.current as any)?.el as HTMLElement | undefined
const el = (playerRef.current as { el?: HTMLElement } | null)?.el
const video = el?.querySelector('video') as HTMLVideoElement | null
if (!video) return
try {
@@ -789,7 +789,7 @@ export default function PlayerPage() {
}
function getFps(): number {
const streams = ((item as any)?.MediaSources?.[0]?.MediaStreams || []) as any[]
const streams = item?.MediaSources?.[0]?.MediaStreams || []
const v = streams.find(s => s.Type === 'Video')
const fps = Number(v?.RealFrameRate ?? v?.AverageFrameRate ?? 0)
return Number.isFinite(fps) && fps > 1 ? fps : 24
@@ -819,13 +819,13 @@ export default function PlayerPage() {
try {
p.playbackRate = rate
} catch { /* not ready */ }
const el = (p as any)?.el as HTMLElement | undefined
const el = (p as { el?: HTMLElement } | null)?.el
const video = el?.querySelector('video') as HTMLVideoElement | null
if (video) {
video.playbackRate = rate
;(video as any).preservesPitch = preserveAudioPitch
;(video as any).mozPreservesPitch = preserveAudioPitch
;(video as any).webkitPreservesPitch = preserveAudioPitch
;video.preservesPitch = preserveAudioPitch
;video.mozPreservesPitch = preserveAudioPitch
;video.webkitPreservesPitch = preserveAudioPitch
}
}
@@ -970,7 +970,7 @@ export default function PlayerPage() {
/* Track lists from Jellyfin metadata */
const audioTracks = item ? getAudioStreams(item) : []
const videoStream = ((item as any)?.MediaSources?.[0]?.MediaStreams || []).find((s: any) => s.Type === 'Video')
const videoStream = (item?.MediaSources?.[0]?.MediaStreams || []).find((s: { Type?: string }) => s.Type === 'Video')
const videoWidth = videoStream?.Width || 1920
const videoHeight = videoStream?.Height || 1080
@@ -985,9 +985,9 @@ export default function PlayerPage() {
setAudioIndex(jfIndex)
if (jfIndex == null) return
if (resolvedSource?.SupportsDirectPlay) {
const el = (playerRef.current as any)?.el as HTMLElement | undefined
const el = (playerRef.current as { el?: HTMLElement } | null)?.el
const video = el?.querySelector('video') as HTMLVideoElement | null
const native = (video as any)?.audioTracks as { length: number; [i: number]: any } | undefined
const native = video.audioTracks as { length: number; [i: number]: { enabled: boolean } } | undefined
if (native && native.length > 1) {
const target = audioTracks.find(t => t.Index === jfIndex)
const targetLang = (target?.Language || '').toLowerCase()
@@ -1005,7 +1005,7 @@ export default function PlayerPage() {
setStreamAudioIndex(jfIndex)
}
const subtitleTracks = item ? getSubtitleStreams(item) : []
const chapters = (item?.Chapters || []) as any[]
const chapters = item?.Chapters || []
@@ -1200,7 +1200,7 @@ export default function PlayerPage() {
onClose={() => setEpisodesOpen(false)}
seriesId={seriesId}
currentItemId={id}
initialSeasonId={(item as any)?.SeasonId || undefined}
initialSeasonId={item?.SeasonId || undefined}
serverUrl={serverUrl}
/>
)}