import { useCallback, useEffect, useRef, useState, type PointerEvent as ReactPointerEvent, type ReactNode } from 'react'; import { usePlayer } from './store'; import { useSession } from '../app/session'; import { useSettings, QUALITY_LABEL, UPSCALING, type Quality, type SubtitleBox, type Upscaling } from '../app/settings'; import { bitrate, channelLabel, clock, episodeLabel, resolutionLabel } from '../app/format'; import { Icon } from '../ui/Icon'; import { Facts, TitleArt } from '../ui/media'; import { Button, Spinner } from '../ui/primitives'; import { win, isNative } from '../platform/native'; import { WindowControls } from '../app/TopBar'; import { navigate } from '../app/router'; import { mpv } from './engine'; import { separateMini } from './miniWindow'; import { PREPARING_NOTICE_MS, UPSCALING_ORDER, hasFailed, readDiagnostics, requestEnhancement, tierAvailable, toggleBypass, type Diagnostics } from './enhance'; import { toast } from '../ui/overlays'; import type { Item } from '../plex/types'; import { PostPlay } from './PostPlay'; const HIDE_AFTER = 3000; /** * Controls show on pointer movement and hide after a few seconds of stillness, * or straight away when the pointer leaves the window. They stay while paused * (until the pointer leaves) and while a panel is open or the timeline is held. */ function useAutoHide(paused: boolean, pinned: boolean) { const [visible, setVisible] = useState(true); const timer = useRef | null>(null); const state = useRef({ paused, pinned }); state.current = { paused, pinned }; const poke = useCallback(() => { setVisible(true); if (timer.current) clearTimeout(timer.current); timer.current = null; if (!state.current.paused && !state.current.pinned) timer.current = setTimeout(() => setVisible(false), HIDE_AFTER); }, []); useEffect(() => { poke(); }, [paused, pinned, poke]); useEffect(() => { const leave = () => { if (state.current.pinned) return; if (timer.current) clearTimeout(timer.current); timer.current = null; setVisible(false); }; const root = document.documentElement; root.addEventListener('mouseleave', leave); return () => { root.removeEventListener('mouseleave', leave); if (timer.current) clearTimeout(timer.current); }; }, []); return { visible, poke }; } function Timeline({ onScrub }: { onScrub: (active: boolean) => void }) { const position = usePlayer((s) => s.position); const duration = usePlayer((s) => s.duration); const cacheTime = usePlayer((s) => s.cacheTime); const chapters = usePlayer((s) => s.chapters); const markers = usePlayer((s) => s.item?.markers ?? []); const seek = usePlayer((s) => s.seek); const previewAt = usePlayer((s) => s.previewAt); const ref = useRef(null); const [hover, setHover] = useState<{ x: number; t: number } | null>(null); const [drag, setDrag] = useState(null); const timeAt = (clientX: number) => { const r = ref.current!.getBoundingClientRect(); const f = Math.min(1, Math.max(0, (clientX - r.left) / r.width)); return { f, t: f * duration, x: clientX - r.left }; }; useEffect(() => { if (drag === null) return; const move = (e: PointerEvent) => { const { t, x } = timeAt(e.clientX); setDrag(t); setHover({ x, t }); }; const up = (e: PointerEvent) => { const { t } = timeAt(e.clientX); seek(t); setDrag(null); setHover(null); onScrub(false); }; window.addEventListener('pointermove', move); window.addEventListener('pointerup', up, { once: true }); return () => { window.removeEventListener('pointermove', move); window.removeEventListener('pointerup', up); }; }, [drag !== null]); const shown = drag ?? position; const pct = duration ? (shown / duration) * 100 : 0; const buffered = duration ? Math.min(100, (Math.max(cacheTime, position) / duration) * 100) : 0; const preview = hover ? previewAt(hover.t) : ''; const chapter = hover ? [...chapters].reverse().find((c) => c.time <= hover.t) : null; const width = ref.current?.clientWidth ?? 0; return (
{ if (drag === null && duration) { const { t, x } = timeAt(e.clientX); setHover({ x, t }); } }} onPointerLeave={() => drag === null && setHover(null)} onPointerDown={(e) => { if (!duration) return; e.preventDefault(); const { t, x } = timeAt(e.clientX); setDrag(t); setHover({ x, t }); onScrub(true); }} role="slider" aria-label="Seek" aria-valuemin={0} aria-valuemax={Math.round(duration)} aria-valuenow={Math.round(position)} >
{duration > 0 && markers .filter((m) => m.type === 'intro' || m.type === 'credits') .map((m) =>
)} {duration > 0 && chapters.slice(1).map((c) =>
)}
{hover && (
{preview && }
{chapter && chapters.length > 1 && {chapter.title}} {clock(hover.t, duration >= 3600)}
)}
); } function Panel({ title, onClose, onBack, children, className = '' }: { title: string; onClose: () => void; onBack?: () => void; children: ReactNode; className?: string }) { useEffect(() => { const onKey = (e: KeyboardEvent) => { if (e.key === 'Escape') { e.stopPropagation(); (onBack ?? onClose)(); } }; window.addEventListener('keydown', onKey, true); return () => window.removeEventListener('keydown', onKey, true); }, [onClose, onBack]); return (
e.stopPropagation()} onDoubleClick={(e) => e.stopPropagation()}>
{onBack && ( )} {title}
{children}
); } function Option({ selected, label, detail, disabled, onClick }: { selected: boolean; label: string; detail?: string; disabled?: boolean; onClick: () => void }) { return ( ); } function TracksPanel({ onClose }: { onClose: () => void }) { const st = usePlayer(); return (

Audio

{st.audioTracks.map((t) => (

Subtitles

); } function Stepper({ label, value, onChange }: { label: string; value: number; onChange: (v: number) => void }) { return (
{label} {value > 0 ? '+' : ''} {value.toFixed(1)}s
); } const SUB_SIZES = [ { value: 0.8, label: 'Small' }, { value: 1, label: 'Normal' }, { value: 1.25, label: 'Large' }, { value: 1.5, label: 'Extra large' }, ]; const SUB_BOXES: { value: SubtitleBox; label: string }[] = [ { value: 'none', label: 'None' }, { value: 'translucent', label: 'Translucent' }, { value: 'solid', label: 'Solid' }, ]; type SettingsView = 'main' | 'audio' | 'subtitles' | 'quality' | 'upscaling' | 'speed' | 'version' | 'chapters' | 'subSize' | 'subBox'; /** True once `flag` has stayed true for `ms` (a quick blip never shows). */ function useLasting(flag: boolean, ms: number) { const [on, setOn] = useState(false); useEffect(() => { if (!flag) return setOn(false); const t = setTimeout(() => setOn(true), ms); return () => clearTimeout(t); }, [flag, ms]); return on; } /** Polls what mpv's renderer is doing while a panel shows it. */ function useDiagnostics(enabled: boolean) { const [d, setD] = useState(null); useEffect(() => { if (!enabled || !isNative) return; let alive = true; const tick = () => readDiagnostics().then((x) => alive && setD(x), () => {}); tick(); const t = setInterval(tick, 1000); return () => { alive = false; clearInterval(t); }; }, [enabled]); return d; } /** Requested vs running tier, for the panel row. */ function upscalingValue(requested: Upscaling, active: Upscaling, bypass: boolean) { if (bypass) return 'Off (comparing)'; return active === requested ? UPSCALING[requested].label : `${UPSCALING[active].label} (${UPSCALING[requested].label} failed)`; } function SettingsPanel({ onClose }: { onClose: () => void }) { const st = usePlayer(); const prefs = useSettings(); const [view, setView] = useState('main'); const diag = useDiagnostics(view === 'main' || view === 'upscaling'); const speeds = [0.5, 0.75, 1, 1.25, 1.5, 1.75, 2]; const media = st.item?.media ?? []; const source = media[st.mediaIndex]; const local = st.delivery?.mode === 'local'; const back = () => setView('main'); const audio = st.audioTracks.find((t) => t.key === st.audioKey); const sub = st.subTracks.find((t) => t.key === st.subKey); const qualityLabel = (q: Quality) => (q === 'original' ? `Original${source?.bitrate ? ` · ${bitrate(source.bitrate)}` : ''}` : QUALITY_LABEL[q]); if (view === 'audio') return ( {st.audioTracks.map((t) => ( ); if (view === 'subtitles') return ( ); if (view === 'quality') return ( {(Object.keys(QUALITY_LABEL) as Quality[]).map((q) => ( ); if (view === 'upscaling') return ( {UPSCALING_ORDER.map((m) => ( ); if (view === 'speed') return ( {speeds.map((s) => ( ); if (view === 'version') return ( {media.map((m, i) => ( ); if (view === 'chapters') return ( {st.chapters.map((c, i) => ( ); if (view === 'subSize') return ( {SUB_SIZES.map((o) => ( ); if (view === 'subBox') return ( {SUB_BOXES.map((o) => ( ); const row = (label: string, value: string, go: () => void, disabled = false) => ( ); const v = st.video; const stats: [string, string][] = [ ['Playback', st.delivery?.mode === 'direct' ? 'Direct play' : st.delivery?.mode === 'transcode' ? `Converting to ${QUALITY_LABEL[st.quality]}` : local ? 'Downloaded file' : ''], ]; if (v && v.width > 0) stats.push(['Video', [`${v.width}×${v.height}`, v.codec.toUpperCase(), source?.dynamicRange, v.hwdec && v.hwdec !== 'no' ? 'Hardware decoding' : 'Software decoding'].filter(Boolean).join(' · ')]); if (audio) stats.push(['Audio', [audio.label, audio.detail].filter(Boolean).join(' · ')]); if (diag && st.enhance.active !== 'off' && !st.enhance.bypass) stats.push(['Upscaling', [...diag.stages, `${diag.gpuMs.toFixed(1)} ms`].join(' · ')]); if (source?.bitrate && !local) stats.push(['Bitrate', st.delivery?.mode === 'transcode' ? `${bitrate(source.bitrate)} source` : bitrate(source.bitrate)]); if (source?.container) stats.push(['Container', source.container.toUpperCase()]); return ( {row('Audio', audio ? audio.label : st.audioTracks.length ? 'Choose' : 'None', () => setView('audio'), !st.audioTracks.length)} {row('Subtitles', sub ? sub.label : 'Off', () => setView('subtitles'))} {!local && row('Quality', qualityLabel(st.quality), () => setView('quality'))} {row('Upscaling', upscalingValue(prefs.upscaling, st.enhance.active, st.enhance.bypass), () => setView('upscaling'))} {row('Speed', st.speed === 1 ? 'Normal' : `${st.speed}×`, () => setView('speed'))} {media.length > 1 && !local && row('Version', `${st.mediaIndex + 1} of ${media.length}`, () => setView('version'))} {st.chapters.length > 1 && row('Chapters', `${st.chapters.length}`, () => setView('chapters'))} {row('Subtitle size', SUB_SIZES.find((o) => o.value === prefs.subtitleScale)?.label ?? 'Custom', () => setView('subSize'))} {row('Subtitle background', SUB_BOXES.find((o) => o.value === prefs.subtitleBox)?.label ?? '', () => setView('subBox'))}
{stats.map(([k, val]) => (
{k} {val}
))}
); } function Volume() { const volume = usePlayer((s) => s.volume); const muted = usePlayer((s) => s.muted); const setVolume = usePlayer((s) => s.setVolume); const toggleMute = usePlayer((s) => s.toggleMute); const icon = muted || volume === 0 ? 'mute' : volume < 50 ? 'volumeLow' : 'volume'; return (
setVolume(Number(e.target.value))} style={{ ['--v' as string]: `${muted ? 0 : Math.min(100, volume)}%` }} aria-label="Volume" />
); } /** A seek that lands inside a marker this recently means the viewer chose to be there. */ const SEEK_GRACE_MS = 1500; const MODIFIER_KEYS = new Set(['Shift', 'Control', 'Alt', 'Meta', 'AltGraph', 'CapsLock']); /** * Skip intro / Skip credits. With "Skip automatically" the button counts down for the * chosen delay, filling as it goes, then skips. Pausing, seeking or pressing a key * before then keeps watching: the button stays as a plain skip for the rest of the marker. */ function SkipButton() { const item = usePlayer((s) => s.item); const position = usePlayer((s) => s.position); const seek = usePlayer((s) => s.seek); const countdown = usePlayer((s) => s.countdown); const postPlayDismissed = usePlayer((s) => s.postPlayDismissed); const paused = usePlayer((s) => s.paused); const ready = usePlayer((s) => s.firstFrame); const lastSeek = usePlayer((s) => s.lastSeek); const skipIntro = useSettings((s) => s.skipIntro); const skipCredits = useSettings((s) => s.skipCredits); const delay = useSettings((s) => s.autoSkipDelay); // Markers already skipped, or whose automatic skip was cancelled, don't count down again. const settled = useRef(new Set()); const [pending, setPending] = useState<{ key: string; from: number } | null>(null); const ms = position * 1000; const marker = item?.markers.find((m) => (m.type === 'intro' || m.type === 'credits') && ms >= m.start && ms < m.end - 1000); const key = item && marker ? `${item.id}:${marker.type}:${marker.start}` : ''; const episodeCredits = marker?.type === 'credits' && item?.type === 'episode'; const mode = marker?.type === 'intro' ? skipIntro : episodeCredits ? 'button' : skipCredits; const auto = !!marker && !episodeCredits && mode === 'auto'; const counting = pending && pending.key === key ? pending : null; const skip = () => { if (!marker) return; settled.current.add(key); setPending(null); if (marker.type === 'credits' && item?.type === 'episode') usePlayer.getState().showPostPlay(); else seek(marker.end / 1000); }; const cancel = () => { if (!pending) return; settled.current.add(pending.key); setPending(null); }; // Start counting once an automatic marker is playing. useEffect(() => { if (!auto || !ready || paused || settled.current.has(key) || pending?.key === key) return; if (Date.now() - usePlayer.getState().lastSeek < SEEK_GRACE_MS) { settled.current.add(key); return; } if (delay <= 0) return skip(); setPending({ key, from: usePlayer.getState().position }); }, [key, auto, ready, paused, delay]); // Count playback time, so buffering doesn't eat into the delay. useEffect(() => { if (counting && position - counting.from >= delay) skip(); else if (pending && !counting) setPending(null); }, [position, key]); // Pausing or seeking means the viewer is watching. useEffect(() => { if (paused) cancel(); }, [paused]); useEffect(cancel, [lastSeek]); useEffect(() => { if (!counting) return; const onKey = (e: KeyboardEvent) => { if (!MODIFIER_KEYS.has(e.key)) cancel(); }; window.addEventListener('keydown', onKey, true); return () => window.removeEventListener('keydown', onKey, true); }, [counting]); if (!marker || (episodeCredits && !postPlayDismissed) || mode === 'off' || countdown !== null) return null; const what = marker.type === 'intro' ? 'intro' : 'credits'; const elapsed = counting ? Math.max(0, position - counting.from) : 0; return ( ); } /** The title opens its show or movie page, with playback moving to the miniplayer. */ function openFromPlayer(id: string | undefined) { if (!id) return; usePlayer.getState().minimize(); navigate({ name: 'item', id }); } function TitleBlock({ item }: { item: Item }) { const linkable = item.type === 'movie' || item.type === 'episode'; const art = i.type === 'clearLogo')?.url ?? '' } : item} maxWidth={240} maxHeight={60} as="h2" />; return (
{linkable ? ( ) : ( art )} {item.type === 'episode' && ( )} {item.type !== 'clip' && }
); } /** Where the miniplayer was dragged to: its distance from the window's right and bottom edges. */ type MiniPos = { x: number; y: number }; const MINI_POS_KEY = 'kaleido.miniPosition'; const MINI_MARGIN = 8; let miniPos: MiniPos | null | undefined; function savedMiniPos(): MiniPos | null { if (miniPos === undefined) { try { const p = JSON.parse(localStorage.getItem(MINI_POS_KEY) ?? 'null'); miniPos = p && Number.isFinite(p.x) && Number.isFinite(p.y) ? p : null; } catch { miniPos = null; } } return miniPos ?? null; } /** Keeps the whole box inside the window. */ function clampMini(el: HTMLElement, pos: MiniPos): MiniPos { const cs = getComputedStyle(el); const maxX = window.innerWidth - parseFloat(cs.width) - MINI_MARGIN; const maxY = window.innerHeight - parseFloat(cs.height) - MINI_MARGIN; return { x: Math.round(Math.max(MINI_MARGIN, Math.min(maxX, pos.x))), y: Math.round(Math.max(MINI_MARGIN, Math.min(maxY, pos.y))) }; } /** The box and the page's hole for the video (base.css) both follow these. */ function applyMiniPos(pos: MiniPos | null) { const root = document.documentElement.style; if (!pos) { root.removeProperty('--mini-x'); root.removeProperty('--mini-y'); return; } root.setProperty('--mini-x', `${pos.x}px`); root.setProperty('--mini-y', `${pos.y}px`); } /** * Playing in the corner while browsing, and draggable anywhere in the window. * The native video is drawn into this box's rectangle and the page has a * matching hole (see `html.player-mini`). */ function MiniPlayer() { const st = usePlayer(); const box = useRef(null); const placeVideo = useRef(() => {}); useEffect(() => { const el = box.current; if (!el) return; let frame = 0; const fit = () => { const saved = savedMiniPos(); applyMiniPos(saved && clampMini(el, saved)); }; const place = () => { cancelAnimationFrame(frame); frame = requestAnimationFrame(() => { // The layout box, not getBoundingClientRect: transforms (an entrance // animation) must not move the video away from the page's hole. const cs = getComputedStyle(el); const width = parseFloat(cs.width); const height = parseFloat(cs.height); const x = window.innerWidth - parseFloat(cs.right) - width; const y = window.innerHeight - parseFloat(cs.bottom) - height; const dpr = window.devicePixelRatio || 1; // A pixel of overdraw on each side keeps the hole covered at any scale. if (isNative) mpv.rect({ x: x * dpr - 1, y: y * dpr - 1, width: width * dpr + 2, height: height * dpr + 2 }).catch(() => {}); }); }; placeVideo.current = place; const onResize = () => { fit(); place(); }; onResize(); const ro = new ResizeObserver(place); ro.observe(el); window.addEventListener('resize', onResize); return () => { cancelAnimationFrame(frame); ro.disconnect(); window.removeEventListener('resize', onResize); }; }, []); const startDrag = (e: ReactPointerEvent) => { const el = box.current; if (e.button !== 0 || !el) return; const cs = getComputedStyle(el); const start = { px: e.clientX, py: e.clientY, x: parseFloat(cs.right), y: parseFloat(cs.bottom) }; let dragging = false; const move = (ev: PointerEvent) => { const dx = ev.clientX - start.px; const dy = ev.clientY - start.py; if (!dragging && Math.hypot(dx, dy) < 5) return; dragging = true; el.classList.add('dragging'); miniPos = clampMini(el, { x: start.x - dx, y: start.y - dy }); applyMiniPos(miniPos); placeVideo.current(); }; const up = () => { window.removeEventListener('pointermove', move); window.removeEventListener('pointerup', up); window.removeEventListener('pointercancel', up); if (!dragging) return; el.classList.remove('dragging'); localStorage.setItem(MINI_POS_KEY, JSON.stringify(miniPos)); // Letting go after a drag isn't a click on the button under the pointer. const swallow = (c: MouseEvent) => { c.stopPropagation(); c.preventDefault(); }; window.addEventListener('click', swallow, { capture: true, once: true }); setTimeout(() => window.removeEventListener('click', swallow, { capture: true }), 0); }; window.addEventListener('pointermove', move); window.addEventListener('pointerup', up); window.addEventListener('pointercancel', up); }; if (!st.item) return null; const item = st.item; const loading = !st.firstFrame && !st.error; const pct = st.duration ? Math.min(100, (st.position / st.duration) * 100) : 0; return (
st.expand()}>
{(loading || st.buffering) && !st.error ? ( ) : st.error ? ( Playback stopped ) : ( <> )}
{item.type === 'episode' ? item.grandparentTitle : item.title} {item.type === 'episode' && ( {episodeLabel(item)} · {item.title} )}
); } export function PlayerOverlay() { const st = usePlayer(); const server = useSession((s) => s.server); const [panel, setPanel] = useState<'' | 'tracks' | 'settings'>(''); const [scrubbing, setScrubbing] = useState(false); const [flash, setFlash] = useState<{ icon: string; key: number } | null>(null); const { visible, poke } = useAutoHide(st.paused || st.ended, !!panel || scrubbing || st.countdown !== null); const clickTimer = useRef | null>(null); const seekStep = useSettings((s) => s.seekStep); const preparing = useLasting(st.enhance.preparing, PREPARING_NOTICE_MS); const showFlash = (icon: string) => setFlash({ icon, key: Date.now() }); useEffect(() => { if (!st.open || st.mini) setPanel(''); }, [st.open, st.mini]); useEffect(() => { if (!st.open || st.mini) return; const onKey = async (e: KeyboardEvent) => { // Up Next owns Tab, Space/Enter and Escape; player shortcuts must not // seek or change volume while a viewer is browsing its episode rows. if (usePlayer.getState().postPlay) return; if ((e.target as HTMLElement)?.tagName === 'INPUT' && (e.target as HTMLInputElement).type !== 'range') return; const p = usePlayer.getState(); let handled = true; switch (e.key) { case ' ': case 'k': case 'K': p.togglePause(); showFlash(p.paused ? 'play' : 'pause'); break; case 'ArrowLeft': case 'j': case 'J': p.seekBy(e.shiftKey ? -60 : e.key === 'ArrowLeft' ? -seekStep : -10); showFlash('replay10'); break; case 'ArrowRight': case 'l': case 'L': p.seekBy(e.shiftKey ? 60 : e.key === 'ArrowRight' ? seekStep : 10); showFlash('forward10'); break; case 'ArrowUp': p.setVolume(p.volume + 5); break; case 'ArrowDown': p.setVolume(p.volume - 5); break; case 'm': case 'M': p.toggleMute(); break; case 'f': case 'F': case 'F11': p.toggleFullscreen(); break; case 'n': case 'N': if (e.shiftKey && p.nextUp) p.playNext(); else handled = false; break; case 'p': case 'P': if (e.shiftKey && p.prevUp) p.playPrevious(); else handled = false; break; case 'u': case 'U': { const prefs = useSettings.getState(); const tiers = UPSCALING_ORDER.filter(tierAvailable); const next = tiers[(tiers.indexOf(prefs.upscaling) + 1) % tiers.length]; prefs.set('upscaling', next); // Confirm what is actually running once it's applied. requestEnhancement().then(() => { if (useSettings.getState().upscaling === next) toast(`Upscaling: ${upscalingValue(next, usePlayer.getState().enhance.active, false)}`); }); break; } case 'b': case 'B': toggleBypass(); break; case 'c': case 'C': { const subs = p.subTracks; const i = subs.findIndex((t) => t.key === p.subKey); p.selectSubtitle(i + 1 < subs.length ? subs[i + 1].key : ''); break; } case 'Escape': { const fs = await win.isFullscreen().catch(() => false); if (fs) p.toggleFullscreen(); else p.minimize(); break; } case 'Backspace': p.minimize(); break; case 'Home': p.seek(0); break; default: if (/^[0-9]$/.test(e.key) && p.duration) p.seek((Number(e.key) / 10) * p.duration); else handled = false; } if (handled) { e.preventDefault(); e.stopPropagation(); poke(); } }; window.addEventListener('keydown', onKey); return () => window.removeEventListener('keydown', onKey); }, [st.open, st.mini, seekStep, poke]); // The macOS traffic lights fade with the rest of the player's chrome. const chromeHidden = st.open && !st.mini && !st.postPlay && !visible && st.firstFrame && !st.error; useEffect(() => { if (!chromeHidden) return; win.setButtonsVisible(false); return () => void win.setButtonsVisible(true); }, [chromeHidden]); if (!st.open || !st.item) return null; // On Windows the miniplayer is a window of its own (miniWindow.ts). if (st.mini) return separateMini ? null : ; if (st.postPlay && !st.error) return ; const item = st.item; const loading = !st.firstFrame && !st.error; const art = item.type === 'episode' ? item.grandparentArt || item.art : item.art; const hideChrome = !visible && !loading && !st.error; return (
{ if (panel) return setPanel(''); if (clickTimer.current) return; clickTimer.current = setTimeout(() => { clickTimer.current = null; if (!loading && !st.error) { st.togglePause(); showFlash(st.paused ? 'play' : 'pause'); } }, 220); }} onDoubleClick={() => { if (clickTimer.current) clearTimeout(clickTimer.current); clickTimer.current = null; st.toggleFullscreen(); }} onWheel={(e) => st.setVolume(st.volume + (e.deltaY < 0 ? 5 : -5))} > {(loading || st.error) && server && (
{art && }
)}
e.stopPropagation()} onDoubleClick={(e) => e.stopPropagation()}> {!st.fullscreen && }
{(loading || st.buffering || st.seeking || preparing) && !st.error && (
{preparing && (

Preparing {UPSCALING[st.enhance.active].label} upscaling First time on this computer only

)}
)} {flash && !loading && (
)} {st.error && (
e.stopPropagation()}>

Playback stopped

{st.error}

{st.terminated ? ( ) : ( <> )}
)} {!st.error && (
e.stopPropagation()} onDoubleClick={(e) => e.stopPropagation()}>
{st.delivery?.mode === 'transcode' ? st.delivery.label : st.delivery?.mode === 'local' ? 'Offline' : ''}
{clock(st.position, st.duration >= 3600)} / {clock(st.duration, st.duration >= 3600)}
{/* Both episode buttons stay for episodes (dimmed at either end) so play/pause holds its place. */} {item.type === 'episode' && ( )} {item.type === 'episode' && ( )}
{panel === 'tracks' && setPanel('')} />} {panel === 'settings' && setPanel('')} />}
)}
); }