Create Kaleido Desktop, a cinematic Plex client for Windows
Tauri 2 shell with a React/TypeScript interface and libmpv playback composed beneath the web view (DirectComposition on Windows). Shared code with per-OS platform modules and configs so macOS and Linux can follow. - Plex sign-in (browser, plex.tv/link or manual), server selection, Plex Home - Home, Movies and TV Shows (Discover, Library, Collections), search, people - Title pages with logos, ratings, cast, extras, seasons and episodes - Direct play with Plex conversion fallback, tracks, markers, autoplay - Metadata editing, artwork, fix match, refresh, analyze and deletion - Resumable offline downloads - App settings and Plex server administration with a live dashboard - Signed updater feed and Forgejo CI Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
00d72e70f4
121 changed files with 25315 additions and 0 deletions
566
src/player/PlayerOverlay.tsx
Normal file
566
src/player/PlayerOverlay.tsx
Normal file
|
|
@ -0,0 +1,566 @@
|
|||
import { useCallback, useEffect, useRef, useState, type ReactNode } from 'react';
|
||||
import { usePlayer } from './store';
|
||||
import { useSession } from '../app/session';
|
||||
import { useSettings, QUALITY_LABEL, type Quality } from '../app/settings';
|
||||
import { clock, episodeLabel } 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 type { Item } from '../plex/types';
|
||||
|
||||
const HIDE_AFTER = 3000;
|
||||
|
||||
function useAutoHide(paused: boolean, pinned: boolean) {
|
||||
const [visible, setVisible] = useState(true);
|
||||
const timer = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||
const poke = useCallback(() => {
|
||||
setVisible(true);
|
||||
if (timer.current) clearTimeout(timer.current);
|
||||
timer.current = setTimeout(() => setVisible(false), HIDE_AFTER);
|
||||
}, []);
|
||||
useEffect(() => {
|
||||
if (paused || pinned) {
|
||||
if (timer.current) clearTimeout(timer.current);
|
||||
setVisible(true);
|
||||
} else poke();
|
||||
}, [paused, pinned, poke]);
|
||||
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<HTMLDivElement>(null);
|
||||
const [hover, setHover] = useState<{ x: number; t: number } | null>(null);
|
||||
const [drag, setDrag] = useState<number | null>(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 (
|
||||
<div
|
||||
className={`timeline${drag !== null ? ' dragging' : ''}`}
|
||||
ref={ref}
|
||||
onPointerMove={(e) => {
|
||||
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)}
|
||||
>
|
||||
<div className="timeline-track">
|
||||
<div className="timeline-buffered" style={{ width: `${buffered}%` }} />
|
||||
<div className="timeline-played" style={{ width: `${pct}%` }} />
|
||||
{duration > 0 &&
|
||||
markers
|
||||
.filter((m) => m.type === 'intro' || m.type === 'credits')
|
||||
.map((m) => <div key={m.id + m.start} className={`timeline-marker ${m.type}`} style={{ left: `${(m.start / 1000 / duration) * 100}%`, width: `${((m.end - m.start) / 1000 / duration) * 100}%` }} />)}
|
||||
{duration > 0 && chapters.slice(1).map((c) => <div key={c.time} className="timeline-chapter" style={{ left: `${(c.time / duration) * 100}%` }} />)}
|
||||
</div>
|
||||
<div className="timeline-thumb" style={{ left: `${pct}%` }} />
|
||||
{hover && (
|
||||
<div className="timeline-preview" style={{ left: Math.min(Math.max(hover.x, 110), width - 110) }}>
|
||||
{preview && <img src={preview} alt="" draggable={false} />}
|
||||
<div className="timeline-preview-text">
|
||||
{chapter && chapters.length > 1 && <span>{chapter.title}</span>}
|
||||
<b>{clock(hover.t, duration >= 3600)}</b>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function Panel({ title, onClose, children, className = '' }: { title: string; onClose: () => void; children: ReactNode; className?: string }) {
|
||||
useEffect(() => {
|
||||
const onKey = (e: KeyboardEvent) => {
|
||||
if (e.key === 'Escape') {
|
||||
e.stopPropagation();
|
||||
onClose();
|
||||
}
|
||||
};
|
||||
window.addEventListener('keydown', onKey, true);
|
||||
return () => window.removeEventListener('keydown', onKey, true);
|
||||
}, [onClose]);
|
||||
return (
|
||||
<div className={`player-panel ${className}`} onClick={(e) => e.stopPropagation()} onDoubleClick={(e) => e.stopPropagation()}>
|
||||
<div className="player-panel-title">{title}</div>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function Option({ selected, label, detail, onClick }: { selected: boolean; label: string; detail?: string; onClick: () => void }) {
|
||||
return (
|
||||
<button className={`panel-option${selected ? ' selected' : ''}`} onClick={onClick}>
|
||||
<span className="panel-check">{selected && <Icon name="check" size={16} />}</span>
|
||||
<span className="panel-label">
|
||||
{label}
|
||||
{detail && <small>{detail}</small>}
|
||||
</span>
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
function TracksPanel({ onClose }: { onClose: () => void }) {
|
||||
const st = usePlayer();
|
||||
return (
|
||||
<Panel title="Audio & Subtitles" onClose={onClose} className="tracks">
|
||||
<div className="panel-columns">
|
||||
<div>
|
||||
<h4>Audio</h4>
|
||||
{st.audioTracks.map((t) => (
|
||||
<Option key={t.key} selected={t.key === st.audioKey} label={t.label} detail={t.detail} onClick={() => st.selectAudio(t.key)} />
|
||||
))}
|
||||
{!st.audioTracks.length && <div className="panel-empty">No audio tracks</div>}
|
||||
</div>
|
||||
<div>
|
||||
<h4>Subtitles</h4>
|
||||
<Option selected={!st.subKey} label="Off" onClick={() => st.selectSubtitle('')} />
|
||||
{st.subTracks.map((t) => (
|
||||
<Option key={t.key} selected={t.key === st.subKey} label={t.label} detail={t.detail} onClick={() => st.selectSubtitle(t.key)} />
|
||||
))}
|
||||
{st.subKey && st.delivery?.mode !== 'transcode' && (
|
||||
<div className="panel-delay">
|
||||
<span>Timing</span>
|
||||
<button onClick={() => st.setSubDelay(st.subDelay - 0.1)}>−</button>
|
||||
<b>{st.subDelay > 0 ? '+' : ''}{st.subDelay.toFixed(1)}s</b>
|
||||
<button onClick={() => st.setSubDelay(st.subDelay + 0.1)}>+</button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</Panel>
|
||||
);
|
||||
}
|
||||
|
||||
function SettingsPanel({ onClose }: { onClose: () => void }) {
|
||||
const st = usePlayer();
|
||||
const [view, setView] = useState<'main' | 'quality' | 'speed' | 'version' | 'chapters'>('main');
|
||||
const speeds = [0.5, 0.75, 1, 1.25, 1.5, 2];
|
||||
const media = st.item?.media ?? [];
|
||||
const local = st.delivery?.mode === 'local';
|
||||
if (view === 'quality')
|
||||
return (
|
||||
<Panel title="Quality" onClose={onClose}>
|
||||
{(Object.keys(QUALITY_LABEL) as Quality[]).map((q) => (
|
||||
<Option key={q} selected={st.quality === q} label={QUALITY_LABEL[q]} detail={q === 'original' ? 'Direct play of the source file' : 'Converted by your Plex server'} onClick={() => (st.setQuality(q), onClose())} />
|
||||
))}
|
||||
</Panel>
|
||||
);
|
||||
if (view === 'speed')
|
||||
return (
|
||||
<Panel title="Playback speed" onClose={onClose}>
|
||||
{speeds.map((s) => (
|
||||
<Option key={s} selected={Math.abs(st.speed - s) < 0.01} label={s === 1 ? 'Normal' : `${s}×`} onClick={() => (st.setSpeed(s), onClose())} />
|
||||
))}
|
||||
</Panel>
|
||||
);
|
||||
if (view === 'version')
|
||||
return (
|
||||
<Panel title="Version" onClose={onClose}>
|
||||
{media.map((m, i) => (
|
||||
<Option key={m.id} selected={st.mediaIndex === i} label={m.title || `${m.videoResolution.toUpperCase()} ${m.videoCodec.toUpperCase()}`} detail={[m.container.toUpperCase(), m.bitrate ? `${Math.round(m.bitrate / 1000)} Mbps` : ''].filter(Boolean).join(' · ')} onClick={() => (st.selectVersion(i), onClose())} />
|
||||
))}
|
||||
</Panel>
|
||||
);
|
||||
if (view === 'chapters')
|
||||
return (
|
||||
<Panel title="Chapters" onClose={onClose} className="chapters">
|
||||
{st.chapters.map((c) => (
|
||||
<Option key={c.time} selected={false} label={c.title} detail={clock(c.time)} onClick={() => (st.seek(c.time), onClose())} />
|
||||
))}
|
||||
</Panel>
|
||||
);
|
||||
const row = (label: string, value: string, go: () => void, disabled = false) => (
|
||||
<button className="panel-row" onClick={go} disabled={disabled}>
|
||||
<span>{label}</span>
|
||||
<b>{value}</b>
|
||||
<Icon name="next" size={14} />
|
||||
</button>
|
||||
);
|
||||
return (
|
||||
<Panel title="Playback" onClose={onClose}>
|
||||
{!local && row('Quality', QUALITY_LABEL[st.quality], () => setView('quality'))}
|
||||
{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'))}
|
||||
<div className="panel-info">
|
||||
{st.delivery?.mode === 'direct' && 'Direct play'}
|
||||
{st.delivery?.mode === 'transcode' && `Converting to ${st.delivery.label}`}
|
||||
{st.delivery?.mode === 'local' && 'Playing from this computer'}
|
||||
{st.video && st.video.width > 0 && ` · ${st.video.width}×${st.video.height}`}
|
||||
{st.video?.codec && ` · ${st.video.codec.toUpperCase()}`}
|
||||
{st.video?.hwdec && st.video.hwdec !== 'no' ? ' · Hardware decoding' : ''}
|
||||
</div>
|
||||
</Panel>
|
||||
);
|
||||
}
|
||||
|
||||
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 (
|
||||
<div className="volume">
|
||||
<button className="player-icon" aria-label={muted ? 'Unmute' : 'Mute'} onClick={toggleMute}>
|
||||
<Icon name={icon} size={22} />
|
||||
</button>
|
||||
<input
|
||||
type="range"
|
||||
min={0}
|
||||
max={100}
|
||||
value={muted ? 0 : Math.min(100, volume)}
|
||||
onChange={(e) => setVolume(Number(e.target.value))}
|
||||
style={{ ['--v' as string]: `${muted ? 0 : Math.min(100, volume)}%` }}
|
||||
aria-label="Volume"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function SkipButton() {
|
||||
const item = usePlayer((s) => s.item);
|
||||
const position = usePlayer((s) => s.position);
|
||||
const seek = usePlayer((s) => s.seek);
|
||||
const nextUp = usePlayer((s) => s.nextUp);
|
||||
const countdown = usePlayer((s) => s.countdown);
|
||||
const skipIntro = useSettings((s) => s.skipIntro);
|
||||
const skipCredits = useSettings((s) => s.skipCredits);
|
||||
const autoSkipped = useRef(new Set<string>());
|
||||
const ms = position * 1000;
|
||||
const marker = item?.markers.find((m) => (m.type === 'intro' || m.type === 'credits') && ms >= m.start && ms < m.end - 1000);
|
||||
const mode = marker?.type === 'intro' ? skipIntro : skipCredits;
|
||||
useEffect(() => {
|
||||
if (marker && mode === 'auto' && !autoSkipped.current.has(marker.id + marker.start) && !(marker.type === 'credits' && nextUp)) {
|
||||
autoSkipped.current.add(marker.id + marker.start);
|
||||
seek(marker.end / 1000);
|
||||
}
|
||||
}, [marker?.id, marker?.start, mode]);
|
||||
if (!marker || mode === 'off' || countdown !== null) return null;
|
||||
if (marker.type === 'credits' && nextUp) return null;
|
||||
return (
|
||||
<button className="skip-button" onClick={() => seek(marker.end / 1000)}>
|
||||
{marker.type === 'intro' ? 'Skip intro' : 'Skip credits'}
|
||||
<Icon name="skipNext" size={16} />
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
function PostPlay() {
|
||||
const server = useSession((s) => s.server);
|
||||
const nextUp = usePlayer((s) => s.nextUp);
|
||||
const countdown = usePlayer((s) => s.countdown);
|
||||
const playNext = usePlayer((s) => s.playNext);
|
||||
const cancel = usePlayer((s) => s.cancelCountdown);
|
||||
if (!nextUp || countdown === null || !server) return null;
|
||||
return (
|
||||
<div className="post-play" onClick={(e) => e.stopPropagation()} onDoubleClick={(e) => e.stopPropagation()}>
|
||||
<div className="post-play-art">
|
||||
<img src={server.image(nextUp.thumb, 360, 202)} alt="" draggable={false} />
|
||||
{countdown > 0 && (
|
||||
<svg className="post-play-ring" viewBox="0 0 40 40">
|
||||
<circle cx="20" cy="20" r="17" />
|
||||
</svg>
|
||||
)}
|
||||
</div>
|
||||
<div className="post-play-text">
|
||||
<span className="micro">Next episode{countdown > 0 ? ` in ${countdown}` : ''}</span>
|
||||
<b>
|
||||
{episodeLabel(nextUp)} · {nextUp.title}
|
||||
</b>
|
||||
<div className="actions">
|
||||
<Button variant="primary" size="sm" icon="play" onClick={playNext}>
|
||||
Play now
|
||||
</Button>
|
||||
<Button variant="ghost" size="sm" onClick={cancel}>
|
||||
{countdown > 0 ? 'Cancel' : 'Dismiss'}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function TitleBlock({ item }: { item: Item }) {
|
||||
return (
|
||||
<div className="player-title">
|
||||
<TitleArt item={item.type === 'episode' ? { ...item, logo: item.raw?.Image?.find?.((i: any) => i.type === 'clearLogo')?.url ?? '' } : item} maxWidth={240} maxHeight={60} as="h2" />
|
||||
{item.type === 'episode' && (
|
||||
<div className="player-episode">
|
||||
{episodeLabel(item)} · {item.title}
|
||||
</div>
|
||||
)}
|
||||
{item.type !== 'clip' && <Facts item={item} withFormats={false} episode={false} />}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
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<ReturnType<typeof setTimeout> | null>(null);
|
||||
const seekStep = useSettings((s) => s.seekStep);
|
||||
|
||||
const showFlash = (icon: string) => setFlash({ icon, key: Date.now() });
|
||||
|
||||
useEffect(() => {
|
||||
if (!st.open) setPanel('');
|
||||
}, [st.open]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!st.open) return;
|
||||
const onKey = async (e: KeyboardEvent) => {
|
||||
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 '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.close();
|
||||
break;
|
||||
}
|
||||
case 'Backspace':
|
||||
p.close();
|
||||
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, seekStep, poke]);
|
||||
|
||||
if (!st.open || !st.item) return null;
|
||||
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 (
|
||||
<div
|
||||
className={`player${hideChrome ? ' idle' : ''}${loading ? ' loading' : ''}`}
|
||||
onMouseMove={poke}
|
||||
onClick={() => {
|
||||
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 && (
|
||||
<div className="player-cover">
|
||||
{art && <img src={server.image(art, 1280, 720, { blur: 0 })} alt="" />}
|
||||
<div className="player-cover-scrim" />
|
||||
</div>
|
||||
)}
|
||||
<div className="player-gradient top" />
|
||||
<div className="player-gradient bottom" />
|
||||
|
||||
<div className="player-top" data-tauri-drag-region={isNative ? true : undefined} onClick={(e) => e.stopPropagation()} onDoubleClick={(e) => e.stopPropagation()}>
|
||||
<button className="player-back" onClick={() => st.close()} aria-label="Back">
|
||||
<Icon name="arrowLeft" size={22} />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{(loading || st.buffering || st.seeking) && !st.error && (
|
||||
<div className="player-center">
|
||||
<Spinner size={44} />
|
||||
</div>
|
||||
)}
|
||||
{flash && !loading && (
|
||||
<div className="player-flash" key={flash.key}>
|
||||
<Icon name={flash.icon} size={34} />
|
||||
</div>
|
||||
)}
|
||||
|
||||
{st.error && (
|
||||
<div className="player-error" onClick={(e) => e.stopPropagation()}>
|
||||
<Icon name="alert" size={28} />
|
||||
<h2>Playback stopped</h2>
|
||||
<p>{st.error}</p>
|
||||
<div className="actions">
|
||||
<Button variant="primary" icon="refresh" onClick={() => st.play(item, { offsetMs: st.position * 1000, quality: st.quality === 'original' ? '1080' : st.quality })}>
|
||||
Try converting
|
||||
</Button>
|
||||
<Button variant="ghost" onClick={() => st.close()}>
|
||||
Close
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<SkipButton />
|
||||
<PostPlay />
|
||||
|
||||
{!st.error && (
|
||||
<div className="player-bottom" onClick={(e) => e.stopPropagation()} onDoubleClick={(e) => e.stopPropagation()}>
|
||||
<div className="player-bottom-head">
|
||||
<TitleBlock item={item} />
|
||||
<div className="player-delivery">{st.delivery?.mode === 'transcode' ? st.delivery.label : st.delivery?.mode === 'local' ? 'Offline' : ''}</div>
|
||||
</div>
|
||||
<Timeline onScrub={setScrubbing} />
|
||||
<div className="player-controls">
|
||||
<div className="player-controls-left">
|
||||
<button className="player-icon big" aria-label={st.paused ? 'Play' : 'Pause'} onClick={() => st.togglePause()}>
|
||||
<Icon name={st.paused || st.ended ? 'play' : 'pause'} size={26} />
|
||||
</button>
|
||||
<button className="player-icon" aria-label="Back 10 seconds" onClick={() => st.seekBy(-10)}>
|
||||
<Icon name="replay10" size={24} />
|
||||
</button>
|
||||
<button className="player-icon" aria-label="Forward 10 seconds" onClick={() => st.seekBy(10)}>
|
||||
<Icon name="forward10" size={24} />
|
||||
</button>
|
||||
{st.nextUp && (
|
||||
<button className="player-icon" aria-label="Next episode" title={`Next: ${episodeLabel(st.nextUp)} ${st.nextUp.title}`} onClick={() => st.playNext()}>
|
||||
<Icon name="skipNext" size={22} />
|
||||
</button>
|
||||
)}
|
||||
<Volume />
|
||||
<span className="player-time">
|
||||
{clock(st.position, st.duration >= 3600)} <span className="dim">/ {clock(st.duration, st.duration >= 3600)}</span>
|
||||
</span>
|
||||
</div>
|
||||
<div className="player-controls-right">
|
||||
<button className={`player-icon${panel === 'tracks' ? ' on' : ''}${st.subKey ? ' lit' : ''}`} aria-label="Audio and subtitles" onClick={() => setPanel(panel === 'tracks' ? '' : 'tracks')}>
|
||||
<Icon name="captions" size={23} />
|
||||
</button>
|
||||
<button className={`player-icon${panel === 'settings' ? ' on' : ''}`} aria-label="Playback settings" onClick={() => setPanel(panel === 'settings' ? '' : 'settings')}>
|
||||
<Icon name="settings" size={22} />
|
||||
</button>
|
||||
<button className="player-icon" aria-label={st.fullscreen ? 'Exit full screen' : 'Full screen'} onClick={() => st.toggleFullscreen()}>
|
||||
<Icon name={st.fullscreen ? 'collapse' : 'expand'} size={21} />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{panel === 'tracks' && <TracksPanel onClose={() => setPanel('')} />}
|
||||
{panel === 'settings' && <SettingsPanel onClose={() => setPanel('')} />}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue