Compare commits
2 commits
be865fa992
...
5a0f2ed907
| Author | SHA1 | Date | |
|---|---|---|---|
| 5a0f2ed907 | |||
| 43c168da95 |
40 changed files with 1779 additions and 333 deletions
19
CHANGELOG.md
19
CHANGELOG.md
|
|
@ -1,5 +1,24 @@
|
|||
# Changelog
|
||||
|
||||
## 0.1.0-beta.2
|
||||
|
||||
Second beta: fixes and changes from testing the first.
|
||||
|
||||
- New startup animation: the iris opens and the view flies through the aperture, as on Kaleido for TV.
|
||||
- Miniplayer: the player's back arrow (or Esc) keeps the video playing in the corner while you browse.
|
||||
- Window controls stay available in the player, and its controls also hide when the pointer leaves the window.
|
||||
- Playback options now include audio and subtitle tracks, audio sync, the source bitrate for Original quality, subtitle size and background, and playback details.
|
||||
- Subtitle styling in Settings (size, colour, edge, background, bold, position) with a live preview.
|
||||
- Categories replace Collections in Movies and TV Shows: genre tiles with artwork that open a filtered library.
|
||||
- Smoother scrolling: per-card and scrolling backdrop blurs were re-rendering every frame.
|
||||
- The artwork colour wash is visible again and carries down the page.
|
||||
- The volume slider follows loudness (halfway is about half as loud), and theme music is much quieter and follows the player volume.
|
||||
- Search keeps results on screen while you type; the A–Z rail is easier to see and magnifies under the pointer; long descriptions expand when clicked.
|
||||
- Featured titles rotate faster and preload their artwork; hovering Continue Watching shows a preview.
|
||||
- Downloads: Remove all (everything, a show, or all movies) and a simpler page.
|
||||
- Removed: the five-star rating, the duplicate Settings entry in the profile menu and the server settings' Show advanced switch (everything is shown).
|
||||
- Fixed: double focus ring in search, a stray dot under the navigation, and overlapping text on the TV Shows header.
|
||||
|
||||
## 0.1.0-beta.1
|
||||
|
||||
First beta of Kaleido for Windows.
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ src/ Shared interface (all platforms)
|
|||
plex/ Plex client: account (plex.tv), library API, admin, playback, parsing
|
||||
player/ Playback controller (store.ts), mpv bridge, player overlay
|
||||
downloads/ Download catalog and actions
|
||||
screens/ Home, Movies/TV (Discover/Library/Collections), title pages,
|
||||
screens/ Home, Movies/TV (Discover/Library/Categories), title pages,
|
||||
search, people, downloads, settings, dialogs
|
||||
ui/ Design system: primitives, menus/dialogs/toasts, cards, hero
|
||||
styles/ Tokens and styles (base, ui, app, screens, player)
|
||||
|
|
@ -37,14 +37,14 @@ Each exposes the same items:
|
|||
|
||||
| Item | Windows implementation |
|
||||
| --- | --- |
|
||||
| `VideoSurface` | mpv renders with `d3d11-output-mode=composition`; its swapchain (`display-swapchain`) is set as the content of a DirectComposition visual targeted at the window with `topmost = false`, i.e. behind the web view's child windows. |
|
||||
| `VideoSurface` | mpv renders with `d3d11-output-mode=composition`; its swapchain (`display-swapchain`) is set as the content of a DirectComposition visual targeted at the window with `topmost = false`, i.e. behind the web view's child windows. For the miniplayer the visual is offset and mpv's composition size shrunk to a corner rectangle (`player_rect`). |
|
||||
| `MPV_LIBRARIES` | `libmpv-2.dll` |
|
||||
| `hold_awake` | `SetThreadExecutionState` while video plays |
|
||||
|
||||
macOS and Linux currently provide stubs for `VideoSurface` (browsing, downloads,
|
||||
settings and updates work; playback reports that it is unavailable). To add playback
|
||||
there, render through mpv's render API into a layer beneath the web view and implement
|
||||
the same five methods. Per-OS bundling (libmpv, targets, dependencies) lives in
|
||||
the same methods (`set_rect` places the video in part of the window for the miniplayer). Per-OS bundling (libmpv, targets, dependencies) lives in
|
||||
`tauri.macos.conf.json` and `tauri.linux.conf.json`. Credentials use the platform's
|
||||
keychain through the `keyring` crate with per-OS features in `Cargo.toml`.
|
||||
|
||||
|
|
@ -67,6 +67,9 @@ transparent only while video is visible (`html.video-active`), so browsing is op
|
|||
timestamps kept absolute. If direct play fails, playback retries through Plex once.
|
||||
Plex streams are matched to mpv tracks by stream index; external subtitles are added
|
||||
on demand. Timeline reports every 10 seconds make the session appear in Plex, and the
|
||||
title is marked watched at the configured percentage.
|
||||
title is marked watched at the configured percentage. The player's back arrow (or Esc)
|
||||
shrinks playback into a miniplayer: the video is drawn in a corner rectangle and the
|
||||
interface stays visible around it, with a matching hole masked out of the page
|
||||
(`html.player-mini`).
|
||||
- **Updates**: `app/updater.ts` checks the signed feed on start; installs need the
|
||||
user's confirmation and then relaunch.
|
||||
|
|
|
|||
4
package-lock.json
generated
4
package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "kaleido-desktop",
|
||||
"version": "0.1.0-beta.1",
|
||||
"version": "0.1.0-beta.2",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "kaleido-desktop",
|
||||
"version": "0.1.0-beta.1",
|
||||
"version": "0.1.0-beta.2",
|
||||
"dependencies": {
|
||||
"@fontsource-variable/inter": "^5.3.0",
|
||||
"@tanstack/react-query": "^5.105.0",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "kaleido-desktop",
|
||||
"private": true,
|
||||
"version": "0.1.0-beta.1",
|
||||
"version": "0.1.0-beta.2",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
|
|
|||
2
src-tauri/Cargo.lock
generated
2
src-tauri/Cargo.lock
generated
|
|
@ -2173,7 +2173,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "kaleido"
|
||||
version = "0.1.0-beta.1"
|
||||
version = "0.1.0-beta.2"
|
||||
dependencies = [
|
||||
"fs2",
|
||||
"futures-util",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "kaleido"
|
||||
version = "0.1.0-beta.1"
|
||||
version = "0.1.0-beta.2"
|
||||
description = "Kaleido — a Plex client for Windows"
|
||||
authors = ["Elijah"]
|
||||
edition = "2021"
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ pub fn run() {
|
|||
.invoke_handler(tauri::generate_handler![
|
||||
player::player_init,
|
||||
player::player_show,
|
||||
player::player_rect,
|
||||
player::player_command,
|
||||
player::player_set,
|
||||
player::player_get,
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ impl VideoSurface {
|
|||
pub fn on_property(&mut self, _: &str, _: &serde_json::Value) {}
|
||||
pub fn show(&mut self, _: bool) {}
|
||||
pub fn fit<R: Runtime>(&mut self, _: &WebviewWindow<R>, _: Option<&Mpv>) {}
|
||||
pub fn set_rect<R: Runtime>(&mut self, _: &WebviewWindow<R>, _: Option<&Mpv>, _: Option<(i32, i32, i32, i32)>) {}
|
||||
}
|
||||
|
||||
pub fn hold_awake(rx: std::sync::mpsc::Receiver<()>) {
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ impl VideoSurface {
|
|||
pub fn on_property(&mut self, _: &str, _: &serde_json::Value) {}
|
||||
pub fn show(&mut self, _: bool) {}
|
||||
pub fn fit<R: Runtime>(&mut self, _: &WebviewWindow<R>, _: Option<&Mpv>) {}
|
||||
pub fn set_rect<R: Runtime>(&mut self, _: &WebviewWindow<R>, _: Option<&Mpv>, _: Option<(i32, i32, i32, i32)>) {}
|
||||
}
|
||||
|
||||
pub fn hold_awake(rx: std::sync::mpsc::Receiver<()>) {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
//! Each platform file exposes the same items:
|
||||
//!
|
||||
//! - `VideoSurface`: composes mpv's output beneath the web view
|
||||
//! (`create`, `mpv_options`, `on_property`, `show`, `fit`).
|
||||
//! (`create`, `mpv_options`, `on_property`, `show`, `fit`, `set_rect`).
|
||||
//! - `SURFACE_PROPERTIES`: mpv properties the surface observes.
|
||||
//! - `MPV_LIBRARIES`: libmpv file names to look for.
|
||||
//! - `hold_awake`: prevents display sleep until the receiver closes.
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ pub struct VideoSurface {
|
|||
_target: IDCompositionTarget,
|
||||
root: IDCompositionVisual,
|
||||
visible: bool,
|
||||
/// Where the video is drawn, in client pixels; `None` fills the window.
|
||||
rect: Option<(i32, i32, i32, i32)>,
|
||||
pub width: i32,
|
||||
pub height: i32,
|
||||
}
|
||||
|
|
@ -49,6 +51,7 @@ impl VideoSurface {
|
|||
_target: target,
|
||||
root,
|
||||
visible: false,
|
||||
rect: None,
|
||||
width,
|
||||
height,
|
||||
})
|
||||
|
|
@ -102,9 +105,20 @@ impl VideoSurface {
|
|||
}
|
||||
}
|
||||
|
||||
/// Matches mpv's composition size and the visual's position to the
|
||||
/// window's client area, or to the miniplayer rectangle when one is set.
|
||||
pub fn fit<R: Runtime>(&mut self, window: &WebviewWindow<R>, mpv: Option<&Mpv>) {
|
||||
let Ok(h) = window.hwnd() else { return };
|
||||
let (w, h) = client_size(HWND(h.0 as _));
|
||||
let (cw, ch) = client_size(HWND(h.0 as _));
|
||||
let (x, y, w, h) = match self.rect {
|
||||
Some((x, y, w, h)) => (x, y, w.max(16), h.max(16)),
|
||||
None => (0, 0, cw, ch),
|
||||
};
|
||||
unsafe {
|
||||
let _ = self.root.SetOffsetX2(x as f32);
|
||||
let _ = self.root.SetOffsetY2(y as f32);
|
||||
let _ = self.device.Commit();
|
||||
}
|
||||
if (w, h) == (self.width, self.height) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -114,6 +128,11 @@ impl VideoSurface {
|
|||
let _ = mpv.set_property("d3d11-composition-size", &serde_json::Value::String(format!("{w}x{h}")));
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_rect<R: Runtime>(&mut self, window: &WebviewWindow<R>, mpv: Option<&Mpv>, rect: Option<(i32, i32, i32, i32)>) {
|
||||
self.rect = rect;
|
||||
self.fit(window, mpv);
|
||||
}
|
||||
}
|
||||
|
||||
/// mpv properties the surface needs to observe.
|
||||
|
|
|
|||
|
|
@ -180,6 +180,28 @@ pub async fn player_show<R: Runtime>(app: AppHandle<R>, window: WebviewWindow<R>
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct VideoRect {
|
||||
x: f64,
|
||||
y: f64,
|
||||
width: f64,
|
||||
height: f64,
|
||||
}
|
||||
|
||||
/// Draws the video in a rectangle of the window (physical pixels), for the
|
||||
/// miniplayer; `None` fills the window again.
|
||||
#[tauri::command]
|
||||
pub async fn player_rect<R: Runtime>(app: AppHandle<R>, window: WebviewWindow<R>, rect: Option<VideoRect>) -> Result<(), String> {
|
||||
let state = app.state::<PlayerState>();
|
||||
let mpv = state.mpv.lock().clone();
|
||||
let mut surface = state.surface.lock();
|
||||
if let Some(surface) = surface.as_mut() {
|
||||
let rect = rect.map(|r| (r.x.round() as i32, r.y.round() as i32, r.width.round() as i32, r.height.round() as i32));
|
||||
surface.set_rect(&window, mpv.as_deref(), rect);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn player_command<R: Runtime>(app: AppHandle<R>, args: Vec<String>) -> Result<(), String> {
|
||||
player(&app)?.command(&args)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"$schema": "https://schema.tauri.app/config/2",
|
||||
"productName": "Kaleido",
|
||||
"version": "0.1.0-beta.1",
|
||||
"version": "0.1.0-beta.2",
|
||||
"identifier": "tv.kaleido.desktop",
|
||||
"build": {
|
||||
"beforeDevCommand": "npm run dev",
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ function Screen({ route }: { route: Route }) {
|
|||
case 'home':
|
||||
return <Home />;
|
||||
case 'section':
|
||||
return <SectionScreen kind={route.kind} tab={route.tab} />;
|
||||
return <SectionScreen kind={route.kind} tab={route.tab} genre={route.genre} genreTitle={route.genreTitle} />;
|
||||
case 'item':
|
||||
return <ItemScreen id={route.id} />;
|
||||
case 'person':
|
||||
|
|
@ -94,8 +94,9 @@ function Page({ onScrolled }: { onScrolled: (top: number) => void }) {
|
|||
function useGlobalShortcuts() {
|
||||
useEffect(() => {
|
||||
const isTyping = (t: EventTarget | null) => t instanceof HTMLElement && (t.isContentEditable || ['INPUT', 'TEXTAREA', 'SELECT'].includes(t.tagName));
|
||||
const playerFull = () => usePlayer.getState().open && !usePlayer.getState().mini;
|
||||
const onKey = (e: KeyboardEvent) => {
|
||||
if (usePlayer.getState().open) return;
|
||||
if (playerFull()) return;
|
||||
if ((e.ctrlKey || e.metaKey) && (e.key === 'k' || e.key === 'f')) {
|
||||
e.preventDefault();
|
||||
navigate({ name: 'search' });
|
||||
|
|
@ -118,7 +119,7 @@ function useGlobalShortcuts() {
|
|||
};
|
||||
// Mouse back/forward buttons.
|
||||
const onMouse = (e: MouseEvent) => {
|
||||
if (usePlayer.getState().open) return;
|
||||
if (playerFull()) return;
|
||||
if (e.button === 3) {
|
||||
e.preventDefault();
|
||||
useRouter.getState().back();
|
||||
|
|
@ -144,7 +145,7 @@ function useLibrarySync() {
|
|||
let last = '';
|
||||
let stopped = false;
|
||||
const tick = async () => {
|
||||
if (stopped || document.hidden || usePlayer.getState().open) return;
|
||||
if (stopped || document.hidden || (usePlayer.getState().open && !usePlayer.getState().mini)) return;
|
||||
try {
|
||||
const rev = await libraryRevision(server);
|
||||
if (last && rev !== last) invalidateLibrary();
|
||||
|
|
@ -167,7 +168,7 @@ function useLibrarySync() {
|
|||
|
||||
function Shell() {
|
||||
const [scrolled, setScrolled] = useState(false);
|
||||
const playerOpen = usePlayer((s) => s.open);
|
||||
const playerOpen = usePlayer((s) => s.open && !s.mini);
|
||||
const startPage = useSettings.getState().startPage;
|
||||
useGlobalShortcuts();
|
||||
useLibrarySync();
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ const NAV = [
|
|||
{ id: 'downloads', label: 'Downloads', route: { name: 'downloads' } as const },
|
||||
];
|
||||
|
||||
function WindowControls() {
|
||||
export function WindowControls() {
|
||||
const [maximized, setMaximized] = useState(false);
|
||||
useEffect(() => {
|
||||
if (!isNative) return;
|
||||
|
|
@ -67,11 +67,8 @@ function Avatar() {
|
|||
submenu: home.users.map((u) => ({ label: u.title, checked: u.uuid === user?.uuid, onSelect: () => home.switchTo(u) })),
|
||||
});
|
||||
}
|
||||
items.push(
|
||||
{ divider: true },
|
||||
{ label: 'Settings', icon: 'settings', onSelect: () => navigate({ name: 'settings', mode: 'app', tab: 'general' }) },
|
||||
);
|
||||
if (server?.owned) items.push({ label: 'Server dashboard', icon: 'activity', onSelect: () => navigate({ name: 'settings', mode: 'server', tab: 'dashboard' }) });
|
||||
// Settings has its own button in the bar; the menu keeps account actions.
|
||||
if (server?.owned) items.push({ divider: true }, { label: 'Server dashboard', icon: 'activity', onSelect: () => navigate({ name: 'settings', mode: 'server', tab: 'dashboard' }) });
|
||||
items.push({ divider: true }, { label: 'Sign out', icon: 'logout', onSelect: signOut });
|
||||
openMenu(items, el, { align: 'end', minWidth: 250 });
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import { create } from 'zustand';
|
||||
|
||||
export type SectionKind = 'movie' | 'show';
|
||||
export type SectionTab = 'discover' | 'library' | 'collections';
|
||||
export type SectionTab = 'discover' | 'library' | 'categories';
|
||||
|
||||
export type Route =
|
||||
| { name: 'home' }
|
||||
| { name: 'section'; kind: SectionKind; tab: SectionTab }
|
||||
| { name: 'section'; kind: SectionKind; tab: SectionTab; genre?: string; genreTitle?: string }
|
||||
| { name: 'item'; id: string; title?: string }
|
||||
| { name: 'person'; id: string; title: string; thumb?: string }
|
||||
| { name: 'hub'; key: string; title: string }
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@ import { persist } from 'zustand/middleware';
|
|||
export type Quality = 'original' | '2160' | '1080' | '720' | '480';
|
||||
export type SkipMode = 'off' | 'button' | 'auto';
|
||||
export type SubtitleMode = 'auto' | 'always' | 'forced' | 'off';
|
||||
export type SubtitleEdge = 'outline' | 'shadow' | 'raised' | 'none';
|
||||
export type SubtitleBox = 'none' | 'translucent' | 'solid';
|
||||
export type SubtitlePosition = 'low' | 'normal' | 'high';
|
||||
|
||||
export interface Preferences {
|
||||
// Playback
|
||||
|
|
@ -20,7 +23,11 @@ export interface Preferences {
|
|||
subtitleMode: SubtitleMode;
|
||||
subtitleLanguage: string;
|
||||
subtitleScale: number;
|
||||
subtitleBackground: boolean;
|
||||
subtitleColor: string;
|
||||
subtitleEdge: SubtitleEdge;
|
||||
subtitleBox: SubtitleBox;
|
||||
subtitleBold: boolean;
|
||||
subtitlePosition: SubtitlePosition;
|
||||
volume: number;
|
||||
seekStep: number;
|
||||
// Interface
|
||||
|
|
@ -54,7 +61,11 @@ export const defaults: Preferences = {
|
|||
subtitleMode: 'auto',
|
||||
subtitleLanguage: '',
|
||||
subtitleScale: 1,
|
||||
subtitleBackground: false,
|
||||
subtitleColor: '#FFFFFF',
|
||||
subtitleEdge: 'outline',
|
||||
subtitleBox: 'none',
|
||||
subtitleBold: false,
|
||||
subtitlePosition: 'normal',
|
||||
volume: 100,
|
||||
seekStep: 10,
|
||||
startPage: 'home',
|
||||
|
|
@ -82,7 +93,19 @@ export const useSettings = create<SettingsState>()(
|
|||
set: (key, value) => set({ [key]: value } as Partial<SettingsState>),
|
||||
reset: () => set({ ...defaults }),
|
||||
}),
|
||||
{ name: 'kaleido.settings', version: 1 },
|
||||
{
|
||||
name: 'kaleido.settings',
|
||||
version: 2,
|
||||
migrate: (persisted, version) => {
|
||||
const p = (persisted ?? {}) as Record<string, unknown>;
|
||||
// 1 → 2: the subtitle background switch became a box style.
|
||||
if (version < 2 && 'subtitleBackground' in p) {
|
||||
p.subtitleBox = p.subtitleBackground ? 'translucent' : 'none';
|
||||
delete p.subtitleBackground;
|
||||
}
|
||||
return p as unknown as SettingsState;
|
||||
},
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
|
|
@ -100,3 +123,15 @@ export const QUALITY_PROFILE: Record<Exclude<Quality, 'original'>, { kbps: numbe
|
|||
'720': { kbps: 4000, width: 1280, height: 720 },
|
||||
'480': { kbps: 1500, width: 854, height: 480 },
|
||||
};
|
||||
|
||||
export const SUBTITLE_COLORS: { value: string; label: string }[] = [
|
||||
{ value: '#FFFFFF', label: 'White' },
|
||||
{ value: '#FFE14D', label: 'Yellow' },
|
||||
{ value: '#7FE3F0', label: 'Cyan' },
|
||||
{ value: '#9BE58A', label: 'Green' },
|
||||
{ value: '#F4A6D7', label: 'Pink' },
|
||||
{ value: '#BFC5CA', label: 'Grey' },
|
||||
];
|
||||
|
||||
/** Bottom margin in mpv's scaled pixels (720 = window height). */
|
||||
export const SUBTITLE_MARGIN: Record<SubtitlePosition, number> = { low: 14, normal: 34, high: 80 };
|
||||
|
|
|
|||
|
|
@ -12,8 +12,9 @@ import { useSession } from './app/session';
|
|||
import { useRouter } from './app/router';
|
||||
import { usePlayer } from './player/store';
|
||||
import { useSettings } from './app/settings';
|
||||
import { useDownloads } from './downloads/store';
|
||||
|
||||
if (import.meta.env.DEV) (window as any).__kaleido = { useSession, useRouter, usePlayer, useSettings };
|
||||
if (import.meta.env.DEV) (window as any).__kaleido = { useSession, useRouter, usePlayer, useSettings, useDownloads };
|
||||
|
||||
// No browser context menu or text-selection chrome outside inputs: this is an app.
|
||||
window.addEventListener('contextmenu', (e) => {
|
||||
|
|
|
|||
|
|
@ -1,30 +1,51 @@
|
|||
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 { useSettings, QUALITY_LABEL, type Quality, type SubtitleBox } 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 { mpv } from './engine';
|
||||
import type { Item } from '../plex/types';
|
||||
|
||||
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<ReturnType<typeof setTimeout> | null>(null);
|
||||
const state = useRef({ paused, pinned });
|
||||
state.current = { paused, pinned };
|
||||
const poke = useCallback(() => {
|
||||
setVisible(true);
|
||||
if (timer.current) clearTimeout(timer.current);
|
||||
timer.current = setTimeout(() => setVisible(false), HIDE_AFTER);
|
||||
timer.current = null;
|
||||
if (!state.current.paused && !state.current.pinned) timer.current = setTimeout(() => setVisible(false), HIDE_AFTER);
|
||||
}, []);
|
||||
useEffect(() => {
|
||||
if (paused || pinned) {
|
||||
if (timer.current) clearTimeout(timer.current);
|
||||
setVisible(true);
|
||||
} else poke();
|
||||
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 };
|
||||
}
|
||||
|
||||
|
|
@ -123,20 +144,27 @@ function Timeline({ onScrub }: { onScrub: (active: boolean) => void }) {
|
|||
);
|
||||
}
|
||||
|
||||
function Panel({ title, onClose, children, className = '' }: { title: string; onClose: () => void; children: ReactNode; className?: string }) {
|
||||
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();
|
||||
onClose();
|
||||
(onBack ?? onClose)();
|
||||
}
|
||||
};
|
||||
window.addEventListener('keydown', onKey, true);
|
||||
return () => window.removeEventListener('keydown', onKey, true);
|
||||
}, [onClose]);
|
||||
}, [onClose, onBack]);
|
||||
return (
|
||||
<div className={`player-panel ${className}`} onClick={(e) => e.stopPropagation()} onDoubleClick={(e) => e.stopPropagation()}>
|
||||
<div className="player-panel-title">{title}</div>
|
||||
<div className="player-panel-title">
|
||||
{onBack && (
|
||||
<button className="panel-back" onClick={onBack} aria-label="Back">
|
||||
<Icon name="back" size={15} />
|
||||
</button>
|
||||
)}
|
||||
{title}
|
||||
</div>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
|
|
@ -172,58 +200,145 @@ function TracksPanel({ onClose }: { onClose: () => void }) {
|
|||
{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>
|
||||
)}
|
||||
{st.subKey && st.delivery?.mode !== 'transcode' && <Stepper label="Timing" value={st.subDelay} onChange={st.setSubDelay} />}
|
||||
</div>
|
||||
</div>
|
||||
</Panel>
|
||||
);
|
||||
}
|
||||
|
||||
function Stepper({ label, value, onChange }: { label: string; value: number; onChange: (v: number) => void }) {
|
||||
return (
|
||||
<div className="panel-delay">
|
||||
<span>{label}</span>
|
||||
<button onClick={() => onChange(Math.round((value - 0.1) * 10) / 10)} aria-label={`${label} earlier`}>
|
||||
−
|
||||
</button>
|
||||
<b>
|
||||
{value > 0 ? '+' : ''}
|
||||
{value.toFixed(1)}s
|
||||
</b>
|
||||
<button onClick={() => onChange(Math.round((value + 0.1) * 10) / 10)} aria-label={`${label} later`}>
|
||||
+
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
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' | 'speed' | 'version' | 'chapters' | 'subSize' | 'subBox';
|
||||
|
||||
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 prefs = useSettings();
|
||||
const [view, setView] = useState<SettingsView>('main');
|
||||
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 (
|
||||
<Panel title="Audio" onClose={onClose} onBack={back}>
|
||||
{st.audioTracks.map((t) => (
|
||||
<Option key={t.key} selected={t.key === st.audioKey} label={t.label} detail={t.detail} onClick={() => (st.selectAudio(t.key), back())} />
|
||||
))}
|
||||
{!st.audioTracks.length && <div className="panel-empty">No audio tracks</div>}
|
||||
{st.delivery?.mode !== 'transcode' && <Stepper label="Audio sync" value={st.audioDelay} onChange={st.setAudioDelay} />}
|
||||
</Panel>
|
||||
);
|
||||
if (view === 'subtitles')
|
||||
return (
|
||||
<Panel title="Subtitles" onClose={onClose} onBack={back}>
|
||||
<Option selected={!st.subKey} label="Off" onClick={() => (st.selectSubtitle(''), back())} />
|
||||
{st.subTracks.map((t) => (
|
||||
<Option key={t.key} selected={t.key === st.subKey} label={t.label} detail={t.detail} onClick={() => (st.selectSubtitle(t.key), back())} />
|
||||
))}
|
||||
{st.subKey && st.delivery?.mode !== 'transcode' && <Stepper label="Subtitle timing" value={st.subDelay} onChange={st.setSubDelay} />}
|
||||
</Panel>
|
||||
);
|
||||
if (view === 'quality')
|
||||
return (
|
||||
<Panel title="Quality" onClose={onClose}>
|
||||
<Panel title="Quality" onClose={onClose} onBack={back}>
|
||||
{(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())} />
|
||||
<Option
|
||||
key={q}
|
||||
selected={st.quality === q}
|
||||
label={qualityLabel(q)}
|
||||
detail={q === 'original' ? [resolutionLabel(source), source?.videoCodec.toUpperCase(), 'Direct play of the source file'].filter(Boolean).join(' · ') : 'Converted by your Plex server'}
|
||||
onClick={() => (st.setQuality(q), onClose())}
|
||||
/>
|
||||
))}
|
||||
</Panel>
|
||||
);
|
||||
if (view === 'speed')
|
||||
return (
|
||||
<Panel title="Playback speed" onClose={onClose}>
|
||||
<Panel title="Playback speed" onClose={onClose} onBack={back}>
|
||||
{speeds.map((s) => (
|
||||
<Option key={s} selected={Math.abs(st.speed - s) < 0.01} label={s === 1 ? 'Normal' : `${s}×`} onClick={() => (st.setSpeed(s), onClose())} />
|
||||
<Option key={s} selected={Math.abs(st.speed - s) < 0.01} label={s === 1 ? 'Normal' : `${s}×`} onClick={() => (st.setSpeed(s), back())} />
|
||||
))}
|
||||
</Panel>
|
||||
);
|
||||
if (view === 'version')
|
||||
return (
|
||||
<Panel title="Version" onClose={onClose}>
|
||||
<Panel title="Version" onClose={onClose} onBack={back}>
|
||||
{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())} />
|
||||
<Option
|
||||
key={m.id}
|
||||
selected={st.mediaIndex === i}
|
||||
label={m.title || [resolutionLabel(m), m.videoCodec.toUpperCase()].filter(Boolean).join(' ')}
|
||||
detail={[m.container.toUpperCase(), bitrate(m.bitrate), [m.audioCodec.toUpperCase(), channelLabel(m.audioChannels)].filter(Boolean).join(' ')].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 title="Chapters" onClose={onClose} onBack={back} className="chapters">
|
||||
{st.chapters.map((c, i) => (
|
||||
<Option
|
||||
key={c.time}
|
||||
selected={st.position >= c.time && st.position < (st.chapters[i + 1]?.time ?? Infinity)}
|
||||
label={c.title}
|
||||
detail={clock(c.time)}
|
||||
onClick={() => (st.seek(c.time), onClose())}
|
||||
/>
|
||||
))}
|
||||
</Panel>
|
||||
);
|
||||
if (view === 'subSize')
|
||||
return (
|
||||
<Panel title="Subtitle size" onClose={onClose} onBack={back}>
|
||||
{SUB_SIZES.map((o) => (
|
||||
<Option key={o.value} selected={prefs.subtitleScale === o.value} label={o.label} onClick={() => (prefs.set('subtitleScale', o.value), back())} />
|
||||
))}
|
||||
</Panel>
|
||||
);
|
||||
if (view === 'subBox')
|
||||
return (
|
||||
<Panel title="Subtitle background" onClose={onClose} onBack={back}>
|
||||
{SUB_BOXES.map((o) => (
|
||||
<Option key={o.value} selected={prefs.subtitleBox === o.value} label={o.label} onClick={() => (prefs.set('subtitleBox', o.value), back())} />
|
||||
))}
|
||||
</Panel>
|
||||
);
|
||||
|
||||
const row = (label: string, value: string, go: () => void, disabled = false) => (
|
||||
<button className="panel-row" onClick={go} disabled={disabled}>
|
||||
<span>{label}</span>
|
||||
|
|
@ -231,19 +346,33 @@ function SettingsPanel({ onClose }: { onClose: () => void }) {
|
|||
<Icon name="next" size={14} />
|
||||
</button>
|
||||
);
|
||||
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 (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 (
|
||||
<Panel title="Playback" onClose={onClose}>
|
||||
{!local && row('Quality', QUALITY_LABEL[st.quality], () => setView('quality'))}
|
||||
{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('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' : ''}
|
||||
{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'))}
|
||||
<div className="panel-stats">
|
||||
{stats.map(([k, val]) => (
|
||||
<div key={k}>
|
||||
<span>{k}</span>
|
||||
<b>{val}</b>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</Panel>
|
||||
);
|
||||
|
|
@ -350,6 +479,93 @@ function TitleBlock({ item }: { item: Item }) {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Playing in the corner while browsing. 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<HTMLDivElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const el = box.current;
|
||||
if (!el) return;
|
||||
let frame = 0;
|
||||
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(() => {});
|
||||
});
|
||||
};
|
||||
place();
|
||||
const ro = new ResizeObserver(place);
|
||||
ro.observe(el);
|
||||
window.addEventListener('resize', place);
|
||||
return () => {
|
||||
cancelAnimationFrame(frame);
|
||||
ro.disconnect();
|
||||
window.removeEventListener('resize', place);
|
||||
};
|
||||
}, []);
|
||||
|
||||
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 (
|
||||
<div ref={box} className={`mini-player${loading || st.error ? ' loading' : ''}`} onDoubleClick={() => st.expand()}>
|
||||
<div className="mini-scrim" />
|
||||
<div className="mini-top">
|
||||
<button className="mini-icon" aria-label="Back to full screen player" title="Expand" onClick={() => st.expand()}>
|
||||
<Icon name="expand" size={17} />
|
||||
</button>
|
||||
<button className="mini-icon" aria-label="Stop playback" title="Close" onClick={() => st.close()}>
|
||||
<Icon name="x" size={18} />
|
||||
</button>
|
||||
</div>
|
||||
<div className="mini-center">
|
||||
{(loading || st.buffering) && !st.error ? (
|
||||
<Spinner size={30} />
|
||||
) : st.error ? (
|
||||
<span className="mini-error">Playback stopped</span>
|
||||
) : (
|
||||
<>
|
||||
<button className="mini-icon" aria-label="Back 10 seconds" onClick={() => st.seekBy(-10)}>
|
||||
<Icon name="replay10" size={22} />
|
||||
</button>
|
||||
<button className="mini-icon big" aria-label={st.paused ? 'Play' : 'Pause'} onClick={() => st.togglePause()}>
|
||||
<Icon name={st.paused || st.ended ? 'play' : 'pause'} size={26} />
|
||||
</button>
|
||||
<button className="mini-icon" aria-label="Forward 10 seconds" onClick={() => st.seekBy(10)}>
|
||||
<Icon name="forward10" size={22} />
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
<div className="mini-caption">
|
||||
<b>{item.type === 'episode' ? item.grandparentTitle : item.title}</b>
|
||||
{item.type === 'episode' && (
|
||||
<span>
|
||||
{episodeLabel(item)} · {item.title}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<div className="mini-progress">
|
||||
<i style={{ width: `${pct}%` }} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function PlayerOverlay() {
|
||||
const st = usePlayer();
|
||||
const server = useSession((s) => s.server);
|
||||
|
|
@ -363,11 +579,11 @@ export function PlayerOverlay() {
|
|||
const showFlash = (icon: string) => setFlash({ icon, key: Date.now() });
|
||||
|
||||
useEffect(() => {
|
||||
if (!st.open) setPanel('');
|
||||
}, [st.open]);
|
||||
if (!st.open || st.mini) setPanel('');
|
||||
}, [st.open, st.mini]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!st.open) return;
|
||||
if (!st.open || st.mini) return;
|
||||
const onKey = async (e: KeyboardEvent) => {
|
||||
if ((e.target as HTMLElement)?.tagName === 'INPUT' && (e.target as HTMLInputElement).type !== 'range') return;
|
||||
const p = usePlayer.getState();
|
||||
|
|
@ -421,11 +637,11 @@ export function PlayerOverlay() {
|
|||
case 'Escape': {
|
||||
const fs = await win.isFullscreen().catch(() => false);
|
||||
if (fs) p.toggleFullscreen();
|
||||
else p.close();
|
||||
else p.minimize();
|
||||
break;
|
||||
}
|
||||
case 'Backspace':
|
||||
p.close();
|
||||
p.minimize();
|
||||
break;
|
||||
case 'Home':
|
||||
p.seek(0);
|
||||
|
|
@ -442,9 +658,10 @@ export function PlayerOverlay() {
|
|||
};
|
||||
window.addEventListener('keydown', onKey);
|
||||
return () => window.removeEventListener('keydown', onKey);
|
||||
}, [st.open, seekStep, poke]);
|
||||
}, [st.open, st.mini, seekStep, poke]);
|
||||
|
||||
if (!st.open || !st.item) return null;
|
||||
if (st.mini) return <MiniPlayer />;
|
||||
const item = st.item;
|
||||
const loading = !st.firstFrame && !st.error;
|
||||
const art = item.type === 'episode' ? item.grandparentArt || item.art : item.art;
|
||||
|
|
@ -482,9 +699,10 @@ export function PlayerOverlay() {
|
|||
<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">
|
||||
<button className="player-back" onClick={() => st.minimize()} aria-label="Back to browsing" title="Keep playing in the corner">
|
||||
<Icon name="arrowLeft" size={22} />
|
||||
</button>
|
||||
{!st.fullscreen && <WindowControls />}
|
||||
</div>
|
||||
|
||||
{(loading || st.buffering || st.seeking) && !st.error && (
|
||||
|
|
|
|||
|
|
@ -39,5 +39,7 @@ export const mpv = {
|
|||
set: (name: string, value: unknown) => invoke<void>('player_set', { name, value }),
|
||||
get: <T = any>(name: string) => invoke<T>('player_get', { name }),
|
||||
show: (visible: boolean) => invoke<void>('player_show', { visible }),
|
||||
/** Draws the video in part of the window (physical pixels), or all of it with null. */
|
||||
rect: (rect: { x: number; y: number; width: number; height: number } | null) => invoke<void>('player_rect', { rect }),
|
||||
on: (handler: (e: MpvEvent) => void) => listen<MpvEvent>('mpv', handler),
|
||||
};
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import * as api from '../plex/api';
|
|||
import { directUrl, previewUrl, reportTimeline, stopTranscode, transcodeUrl, type Delivery } from '../plex/playback';
|
||||
import type { Item, Stream } from '../plex/types';
|
||||
import { useSession } from '../app/session';
|
||||
import { useSettings, type Quality } from '../app/settings';
|
||||
import { useSettings, SUBTITLE_MARGIN, type Preferences, type Quality } from '../app/settings';
|
||||
import { channelLabel } from '../app/format';
|
||||
import { invalidateLibrary } from '../app/queries';
|
||||
import { keepAwake, isNative, win } from '../platform/native';
|
||||
|
|
@ -61,6 +61,9 @@ interface PlayerState {
|
|||
countdown: number | null;
|
||||
postPlayDismissed: boolean;
|
||||
fullscreen: boolean;
|
||||
/** Playing in the corner while browsing. */
|
||||
mini: boolean;
|
||||
audioDelay: number;
|
||||
|
||||
play(item: Item, opts?: PlayOptions): Promise<void>;
|
||||
close(): Promise<void>;
|
||||
|
|
@ -71,6 +74,9 @@ interface PlayerState {
|
|||
toggleMute(): void;
|
||||
setSpeed(s: number): void;
|
||||
setSubDelay(s: number): void;
|
||||
setAudioDelay(s: number): void;
|
||||
minimize(): Promise<void>;
|
||||
expand(): void;
|
||||
selectAudio(key: string): Promise<void>;
|
||||
selectSubtitle(key: string): Promise<void>;
|
||||
setQuality(q: Quality): Promise<void>;
|
||||
|
|
@ -94,6 +100,14 @@ let pendingExternal: Track | null = null;
|
|||
|
||||
const server = () => useSession.getState().server;
|
||||
|
||||
/**
|
||||
* mpv applies its volume on a cubic curve, so halfway on a linear slider was
|
||||
* only an eighth of the amplitude. The slider follows a square law instead
|
||||
* (halfway is about -12 dB, close to how loud it sounds).
|
||||
*/
|
||||
export const sliderToMpv = (v: number) => 100 * Math.pow(Math.max(0, v) / 100, 2 / 3);
|
||||
const mpvToSlider = (v: number) => 100 * Math.pow(Math.max(0, v) / 100, 3 / 2);
|
||||
|
||||
function languageName(code: string, fallback: string) {
|
||||
if (!code) return fallback;
|
||||
try {
|
||||
|
|
@ -147,6 +161,48 @@ function mpvTrackLabel(t: MpvTrack): Track {
|
|||
};
|
||||
}
|
||||
|
||||
/** Sets the first property name this libmpv knows (some were renamed in 0.38). */
|
||||
async function setAny(names: string[], value: unknown) {
|
||||
for (const name of names) {
|
||||
try {
|
||||
await mpv.set(name, value);
|
||||
return true;
|
||||
} catch {
|
||||
/* try the older name */
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** mpv colours are #AARRGGBB. */
|
||||
const mpvColor = (hex: string, alpha = 1) => `#${Math.round(alpha * 255).toString(16).padStart(2, '0')}${hex.replace('#', '')}`.toUpperCase();
|
||||
|
||||
/** Applies the text subtitle look from preferences (image subtitles keep their own). */
|
||||
async function applySubtitleStyle(prefs: Preferences = useSettings.getState()) {
|
||||
const edge = prefs.subtitleEdge;
|
||||
await mpv.set('sub-scale', prefs.subtitleScale).catch(() => {});
|
||||
await mpv.set('sub-color', mpvColor(prefs.subtitleColor)).catch(() => {});
|
||||
await mpv.set('sub-bold', prefs.subtitleBold).catch(() => {});
|
||||
await mpv.set('sub-margin-y', SUBTITLE_MARGIN[prefs.subtitlePosition]).catch(() => {});
|
||||
await setAny(['sub-outline-color', 'sub-border-color'], '#FF000000');
|
||||
await setAny(['sub-outline-size', 'sub-border-size'], edge === 'outline' ? 1.8 : edge === 'raised' ? 1.3 : 0);
|
||||
await mpv.set('sub-shadow-offset', edge === 'shadow' ? 2.2 : edge === 'raised' ? 1.6 : 0).catch(() => {});
|
||||
await mpv.set('sub-shadow-color', '#B4000000').catch(() => {});
|
||||
if (prefs.subtitleBox === 'none') {
|
||||
await mpv.set('sub-border-style', 'outline-and-shadow').catch(() => {});
|
||||
await mpv.set('sub-back-color', '#B4000000').catch(() => {});
|
||||
return;
|
||||
}
|
||||
const box = prefs.subtitleBox === 'solid' ? '#FF000000' : '#A0000000';
|
||||
await mpv.set('sub-back-color', box).catch(() => {});
|
||||
if (!(await setAny(['sub-border-style'], 'background-box'))) {
|
||||
// Before background-box, an opaque box is drawn in the outline colour.
|
||||
await mpv.set('sub-border-style', 'opaque-box').catch(() => {});
|
||||
await setAny(['sub-outline-color', 'sub-border-color'], box);
|
||||
await setAny(['sub-outline-size', 'sub-border-size'], 3);
|
||||
}
|
||||
}
|
||||
|
||||
function report(state: 'playing' | 'paused' | 'buffering' | 'stopped') {
|
||||
const s = server();
|
||||
const { item, position, delivery } = usePlayer.getState();
|
||||
|
|
@ -313,7 +369,7 @@ function onEvent(e: MpvEvent) {
|
|||
if (typeof v === 'number') usePlayer.setState({ cacheTime: v });
|
||||
break;
|
||||
case 'volume':
|
||||
if (typeof v === 'number') usePlayer.setState({ volume: v });
|
||||
if (typeof v === 'number') usePlayer.setState({ volume: Math.round(mpvToSlider(v)) });
|
||||
break;
|
||||
case 'mute':
|
||||
usePlayer.setState({ muted: !!v });
|
||||
|
|
@ -324,6 +380,9 @@ function onEvent(e: MpvEvent) {
|
|||
case 'sub-delay':
|
||||
if (typeof v === 'number') usePlayer.setState({ subDelay: v });
|
||||
break;
|
||||
case 'audio-delay':
|
||||
if (typeof v === 'number') usePlayer.setState({ audioDelay: v });
|
||||
break;
|
||||
case 'chapter-list':
|
||||
if (Array.isArray(v) && v.length > 1 && !st.chapters.length)
|
||||
usePlayer.setState({ chapters: v.map((c: any, i: number) => ({ title: c.title && !/^\d\d:\d\d/.test(c.title) ? c.title : `Chapter ${i + 1}`, time: c.time })) });
|
||||
|
|
@ -432,6 +491,8 @@ export const usePlayer = create<PlayerState>((set, get) => ({
|
|||
countdown: null,
|
||||
postPlayDismissed: false,
|
||||
fullscreen: false,
|
||||
mini: false,
|
||||
audioDelay: 0,
|
||||
|
||||
async play(input, opts = {}) {
|
||||
const token = ++loadToken;
|
||||
|
|
@ -473,8 +534,8 @@ export const usePlayer = create<PlayerState>((set, get) => ({
|
|||
subKey: '__init',
|
||||
video: null,
|
||||
fullscreen: wasFullscreenBeforePlay,
|
||||
mini: false,
|
||||
});
|
||||
document.documentElement.classList.add('player-open');
|
||||
|
||||
try {
|
||||
// Full metadata: streams, markers and chapters.
|
||||
|
|
@ -525,11 +586,10 @@ export const usePlayer = create<PlayerState>((set, get) => ({
|
|||
if (!unlisten) unlisten = await mpv.on(onEvent);
|
||||
if (token !== loadToken) return;
|
||||
await mpv.set('mute', false);
|
||||
await mpv.set('volume', prefs.volume);
|
||||
await mpv.set('volume', sliderToMpv(prefs.volume));
|
||||
await mpv.set('speed', 1);
|
||||
await mpv.set('sub-scale', prefs.subtitleScale);
|
||||
await mpv.set('sub-back-color', prefs.subtitleBackground ? '#C0000000' : '#00000000');
|
||||
await mpv.set('sub-border-style', prefs.subtitleBackground ? 'opaque-box' : 'outline-and-shadow');
|
||||
await mpv.set('audio-delay', 0);
|
||||
await applySubtitleStyle(prefs);
|
||||
await mpv.set('force-media-title', item.type === 'episode' ? `${item.grandparentTitle} — ${item.title}` : item.title);
|
||||
await mpv.show(true);
|
||||
const fileOpts = [
|
||||
|
|
@ -565,8 +625,7 @@ export const usePlayer = create<PlayerState>((set, get) => ({
|
|||
await mpv.command('stop').catch(() => {});
|
||||
await mpv.show(false).catch(() => {});
|
||||
}
|
||||
document.documentElement.classList.remove('player-open', 'video-active');
|
||||
set({ open: false, item: null, delivery: null, error: '', countdown: null, nextUp: null, firstFrame: false });
|
||||
set({ open: false, mini: false, item: null, delivery: null, error: '', countdown: null, nextUp: null, firstFrame: false });
|
||||
const fs = await win.isFullscreen().catch(() => false);
|
||||
if (fs && !wasFullscreenBeforePlay) win.setFullscreen(false);
|
||||
if (st.item) invalidateLibrary();
|
||||
|
|
@ -601,7 +660,7 @@ export const usePlayer = create<PlayerState>((set, get) => ({
|
|||
const volume = Math.max(0, Math.min(150, Math.round(v)));
|
||||
set({ volume });
|
||||
useSettings.getState().set('volume', Math.min(100, volume));
|
||||
mpv.set('volume', volume).catch(() => {});
|
||||
mpv.set('volume', sliderToMpv(volume)).catch(() => {});
|
||||
if (get().muted && volume > 0) mpv.set('mute', false).catch(() => {});
|
||||
},
|
||||
|
||||
|
|
@ -617,6 +676,27 @@ export const usePlayer = create<PlayerState>((set, get) => ({
|
|||
mpv.set('sub-delay', delay).catch(() => {});
|
||||
},
|
||||
|
||||
setAudioDelay(delay) {
|
||||
mpv.set('audio-delay', delay).catch(() => {});
|
||||
},
|
||||
|
||||
async minimize() {
|
||||
const st = get();
|
||||
if (!st.open || st.mini) return;
|
||||
set({ mini: true });
|
||||
// Full screen was for the video; browsing goes back to the window.
|
||||
if (st.fullscreen && !wasFullscreenBeforePlay) {
|
||||
await win.setFullscreen(false).catch(() => {});
|
||||
set({ fullscreen: false });
|
||||
}
|
||||
},
|
||||
|
||||
expand() {
|
||||
if (!get().mini) return;
|
||||
set({ mini: false });
|
||||
if (isNative) mpv.rect(null).catch(() => {});
|
||||
},
|
||||
|
||||
async selectAudio(key) {
|
||||
const st = get();
|
||||
const t = st.audioTracks.find((x) => x.key === key);
|
||||
|
|
@ -685,9 +765,21 @@ export const usePlayer = create<PlayerState>((set, get) => ({
|
|||
},
|
||||
}));
|
||||
|
||||
/** Shown once the first frame is ready, the page turns transparent over the video. */
|
||||
/**
|
||||
* Shown once the first frame is ready, the page turns transparent over the
|
||||
* video. In the miniplayer the interface stays, with a hole for the video.
|
||||
*/
|
||||
usePlayer.subscribe((st, prev) => {
|
||||
if (st.firstFrame !== prev.firstFrame || st.open !== prev.open || st.error !== prev.error) {
|
||||
document.documentElement.classList.toggle('video-active', st.open && st.firstFrame && !st.error);
|
||||
if (st.firstFrame !== prev.firstFrame || st.open !== prev.open || st.error !== prev.error || st.mini !== prev.mini) {
|
||||
const html = document.documentElement.classList;
|
||||
html.toggle('video-active', st.open && st.firstFrame && !st.error);
|
||||
html.toggle('player-open', st.open && !st.mini);
|
||||
html.toggle('player-mini', st.open && st.mini);
|
||||
}
|
||||
});
|
||||
|
||||
/** Subtitle look changes apply to the playing video straight away. */
|
||||
const SUBTITLE_PREFS = ['subtitleScale', 'subtitleColor', 'subtitleEdge', 'subtitleBox', 'subtitleBold', 'subtitlePosition'] as const;
|
||||
useSettings.subscribe((prefs, prev) => {
|
||||
if (isNative && usePlayer.getState().open && SUBTITLE_PREFS.some((k) => prefs[k] !== prev[k])) applySubtitleStyle(prefs);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ function fadeTo(target: number, done?: () => void) {
|
|||
if (fade) clearInterval(fade);
|
||||
const a = audio;
|
||||
fade = setInterval(() => {
|
||||
const step = 0.02;
|
||||
const step = Math.max(0.002, target / 25, a.volume / 25);
|
||||
if (Math.abs(a.volume - target) <= step) {
|
||||
a.volume = target;
|
||||
clearInterval(fade!);
|
||||
|
|
@ -21,17 +21,27 @@ function fadeTo(target: number, done?: () => void) {
|
|||
}, 40);
|
||||
}
|
||||
|
||||
/**
|
||||
* Theme songs are mastered far louder than a film's dialogue, so the setting
|
||||
* follows a square law and scales with the player's own volume: the default
|
||||
* 30% sits around -21 dB, under the show it introduces.
|
||||
*/
|
||||
function themeGain() {
|
||||
const { themeVolume, volume } = useSettings.getState();
|
||||
return Math.pow(themeVolume / 100, 2) * Math.pow(Math.min(100, volume) / 100, 2);
|
||||
}
|
||||
|
||||
export function playThemeMusic(path: string) {
|
||||
const prefs = useSettings.getState();
|
||||
const server = useSession.getState().server;
|
||||
if (!prefs.themeMusic || !path || !server || document.documentElement.classList.contains('player-open')) return;
|
||||
if (!prefs.themeMusic || !path || !server || /player-(open|mini)/.test(document.documentElement.className)) return;
|
||||
if (path === current && audio && !audio.paused) return;
|
||||
stopThemeMusic(true);
|
||||
current = path;
|
||||
audio = new Audio(server.signed(path));
|
||||
audio.volume = 0;
|
||||
audio.loop = false;
|
||||
audio.play().then(() => fadeTo(prefs.themeVolume / 100), () => {});
|
||||
audio.play().then(() => fadeTo(themeGain()), () => {});
|
||||
}
|
||||
|
||||
export function stopThemeMusic(immediate = false) {
|
||||
|
|
|
|||
|
|
@ -94,6 +94,10 @@ export async function firstCharacters(s: PlexServer, sectionId: string, params:
|
|||
return arr(mc.Directory).map((d: any) => ({ key: str(d.key), title: str(d.title), size: num(d.size) }));
|
||||
}
|
||||
|
||||
export async function genres(s: PlexServer, sectionId: string, type?: number): Promise<FilterOption[]> {
|
||||
return filterOptions(s, `/library/sections/${sectionId}/genre`, type);
|
||||
}
|
||||
|
||||
export async function collections(s: PlexServer, sectionId: string): Promise<Item[]> {
|
||||
const mc = await s.container(`/library/sections/${sectionId}/collections`, { includeCollections: 1, sort: 'titleSort:asc' });
|
||||
return items(mc);
|
||||
|
|
@ -221,10 +225,6 @@ export async function removeFromContinueWatching(s: PlexServer, id: string) {
|
|||
await s.send('PUT', '/actions/removeFromContinueWatching', { ratingKey: id });
|
||||
}
|
||||
|
||||
export async function rate(s: PlexServer, id: string, rating: number) {
|
||||
await s.send('PUT', '/:/rate', { key: id, identifier: 'com.plexapp.plugins.library', rating: rating < 0 ? -1 : rating });
|
||||
}
|
||||
|
||||
export async function selectStreams(s: PlexServer, partId: string, sel: { audioStreamID?: string; subtitleStreamID?: string }) {
|
||||
await s.send('PUT', `/library/parts/${partId}`, { allParts: 1, ...sel });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,6 +117,15 @@ export default function Downloads({ offline }: { offline?: boolean }) {
|
|||
const used = store.items.reduce((a, d) => a + (d.status === 'completed' ? d.total || d.received : d.received), 0);
|
||||
const movies = done.filter((d) => d.meta.raw?.type !== 'episode');
|
||||
const episodes = done.filter((d) => d.meta.raw?.type === 'episode');
|
||||
const removeMany = async (list: Download[], what: string) => {
|
||||
const ok = await confirmDialog({
|
||||
title: `Remove ${what}?`,
|
||||
message: `${list.length} download${list.length === 1 ? '' : 's'} will be deleted from this computer. ${list.length === 1 ? 'It stays' : 'They stay'} available on your Plex server.`,
|
||||
confirm: 'Remove',
|
||||
danger: true,
|
||||
});
|
||||
if (ok) await Promise.all(list.map((d) => store.remove(d.id)));
|
||||
};
|
||||
const shows = new Map<string, Download[]>();
|
||||
for (const e of episodes) {
|
||||
const k = e.meta.raw?.grandparentTitle ?? 'Episodes';
|
||||
|
|
@ -127,9 +136,14 @@ export default function Downloads({ offline }: { offline?: boolean }) {
|
|||
<div className={`downloads-page page-pad${offline ? '' : ' top'}`}>
|
||||
<div className="download-intro">
|
||||
<div>
|
||||
<div className="micro">Offline · This computer</div>
|
||||
<h1 className="page-title">Downloads</h1>
|
||||
<p className="page-subtitle">Movies and episodes saved to this computer play without a connection. Progress syncs to Plex when you’re back online.</p>
|
||||
{store.items.length > 0 && (
|
||||
<div className="actions download-intro-actions">
|
||||
<Button variant="ghost" size="sm" icon="trash" onClick={() => removeMany(store.items, 'all downloads')}>
|
||||
Remove all
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{isNative && (
|
||||
<div className="storage-card">
|
||||
|
|
@ -158,14 +172,16 @@ export default function Downloads({ offline }: { offline?: boolean }) {
|
|||
</div>
|
||||
|
||||
{!isNative && (
|
||||
<div className="downloads-empty">
|
||||
<EmptyState icon="download" title="Downloads need the desktop app">
|
||||
Install Kaleido for Windows to save movies and episodes for offline viewing.
|
||||
</EmptyState>
|
||||
</div>
|
||||
)}
|
||||
{isNative && !store.items.length && (
|
||||
<EmptyState icon="download" title="Nothing downloaded yet" action={!offline && <Button variant="ghost" icon="film" onClick={() => navigate({ name: 'section', kind: 'movie', tab: 'library' })}>Browse movies</Button>}>
|
||||
Choose Download on a movie or episode, or download a whole season from its page.
|
||||
</EmptyState>
|
||||
<div className="downloads-empty">
|
||||
<EmptyState icon="download" title="Nothing downloaded yet" />
|
||||
</div>
|
||||
)}
|
||||
|
||||
{active.length > 0 && (
|
||||
|
|
@ -197,6 +213,11 @@ export default function Downloads({ offline }: { offline?: boolean }) {
|
|||
<h2>
|
||||
Movies <small>{movies.length}</small>
|
||||
</h2>
|
||||
{movies.length > 1 && (
|
||||
<Button variant="text" onClick={() => removeMany(movies, 'all downloaded movies')}>
|
||||
Remove all
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
{movies.map((d) => (
|
||||
<DownloadRow key={d.id} d={d} />
|
||||
|
|
@ -209,6 +230,11 @@ export default function Downloads({ offline }: { offline?: boolean }) {
|
|||
<h2>
|
||||
{show} <small>{list.length} episode{list.length === 1 ? '' : 's'}</small>
|
||||
</h2>
|
||||
{list.length > 1 && (
|
||||
<Button variant="text" onClick={() => removeMany(list, `all ${show} episodes`)}>
|
||||
Remove all
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
{list
|
||||
.sort((a, b) => (a.meta.raw.parentIndex - b.meta.raw.parentIndex) * 1000 + (a.meta.raw.index - b.meta.raw.index))
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { useEffect, useMemo, useState, type ReactNode } from 'react';
|
||||
import * as api from '../plex/api';
|
||||
import type { Item } from '../plex/types';
|
||||
import { invalidateLibrary, useChildren, useItem, useRelated, useServerQuery } from '../app/queries';
|
||||
import { useChildren, useItem, useRelated, useServerQuery } from '../app/queries';
|
||||
import { useServer } from '../app/session';
|
||||
import { useSettings } from '../app/settings';
|
||||
import { goBack, navigate, useRouter } from '../app/router';
|
||||
|
|
@ -11,7 +11,7 @@ import { Backdrop } from '../ui/Backdrop';
|
|||
import { Facts, HubShelf, LandscapeCard, PersonCard, PosterCard, Shelf, TitleArt } from '../ui/media';
|
||||
import { Artwork, Button, EmptyState, ErrorState, IconButton, PageLoader, Select } from '../ui/primitives';
|
||||
import { Icon } from '../ui/Icon';
|
||||
import { openMenu, toastError } from '../ui/overlays';
|
||||
import { openMenu } from '../ui/overlays';
|
||||
import { useDownloads } from '../downloads/store';
|
||||
import { playThemeMusic, stopThemeMusic } from '../player/theme';
|
||||
|
||||
|
|
@ -40,24 +40,29 @@ export function ItemScreen({ id }: { id: string }) {
|
|||
|
||||
// —— Shared pieces ————————————————————————————————————————————————
|
||||
|
||||
function Synopsis({ item, text }: { item: Item; text: string }) {
|
||||
/** Long descriptions open in place when clicked, and close again the same way. */
|
||||
function Synopsis({ text }: { item: Item; text: string }) {
|
||||
const [clamped, setClamped] = useState(false);
|
||||
const [open, setOpen] = useState(false);
|
||||
useEffect(() => setOpen(false), [text]);
|
||||
if (!text) return null;
|
||||
const toggle = () => (clamped || open) && setOpen(!open);
|
||||
return (
|
||||
<div className="synopsis-wrap">
|
||||
<p
|
||||
className="synopsis"
|
||||
className={`synopsis${open ? ' open' : ''}${clamped || open ? ' expandable' : ''}`}
|
||||
role={clamped || open ? 'button' : undefined}
|
||||
tabIndex={clamped || open ? 0 : undefined}
|
||||
aria-expanded={clamped || open ? open : undefined}
|
||||
title={clamped && !open ? 'Show the full description' : undefined}
|
||||
onClick={toggle}
|
||||
onKeyDown={(e) => (e.key === 'Enter' || e.key === ' ') && (e.preventDefault(), toggle())}
|
||||
ref={(el) => {
|
||||
if (el) setClamped(el.scrollHeight > el.clientHeight + 2);
|
||||
if (el && !open) setClamped(el.scrollHeight > el.clientHeight + 2);
|
||||
}}
|
||||
>
|
||||
{text}
|
||||
</p>
|
||||
{clamped && (
|
||||
<button className="btn text synopsis-more" onClick={() => openDialog({ kind: 'synopsis', item })}>
|
||||
More
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -180,33 +185,6 @@ function RelatedRows({ item }: { item: Item }) {
|
|||
);
|
||||
}
|
||||
|
||||
function StarRating({ item }: { item: Item }) {
|
||||
const server = useServer();
|
||||
const [value, setValue] = useState(item.userRating);
|
||||
const [hover, setHover] = useState(0);
|
||||
useEffect(() => setValue(item.userRating), [item.userRating]);
|
||||
const set = async (stars: number) => {
|
||||
const rating = stars * 2 === value ? -1 : stars * 2;
|
||||
setValue(Math.max(0, rating));
|
||||
try {
|
||||
await api.rate(server, item.id, rating);
|
||||
invalidateLibrary();
|
||||
} catch (e) {
|
||||
toastError(e);
|
||||
}
|
||||
};
|
||||
const shown = hover || value / 2;
|
||||
return (
|
||||
<span className="star-rating" onMouseLeave={() => setHover(0)} aria-label="Your rating">
|
||||
{[1, 2, 3, 4, 5].map((n) => (
|
||||
<button key={n} onMouseEnter={() => setHover(n)} onClick={() => set(n)} aria-label={`${n} star${n > 1 ? 's' : ''}`}>
|
||||
<Icon name={n <= shown ? 'starFill' : 'star'} size={15} />
|
||||
</button>
|
||||
))}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
function AboutPanel({ item }: { item: Item }) {
|
||||
const m = item.media[0];
|
||||
const rows: [string, ReactNode][] = [];
|
||||
|
|
@ -248,7 +226,6 @@ function AboutPanel({ item }: { item: Item }) {
|
|||
<aside className="about-panel">
|
||||
<div className="about-head">
|
||||
<h3>About</h3>
|
||||
{['movie', 'show', 'episode', 'season'].includes(item.type) && <StarRating item={item} />}
|
||||
</div>
|
||||
{item.tagline && <p className="about-tagline">“{item.tagline}”</p>}
|
||||
{rows.map(([k, v]) => (
|
||||
|
|
|
|||
|
|
@ -33,7 +33,8 @@ function useDebounced<T>(value: T, ms: number) {
|
|||
return v;
|
||||
}
|
||||
|
||||
export function LibraryBrowser({ section, kind }: { section: Section; kind: SectionKind }) {
|
||||
/** `lockedFilters` (e.g. a category's genre) always apply and aren't shown as removable. */
|
||||
export function LibraryBrowser({ section, kind, lockedFilters }: { section: Section; kind: SectionKind; lockedFilters?: Record<string, string> }) {
|
||||
const server = useServer();
|
||||
const type = kind === 'movie' ? 1 : 2;
|
||||
const views = useSettings((s) => s.libraryViews);
|
||||
|
|
@ -63,7 +64,7 @@ export function LibraryBrowser({ section, kind }: { section: Section; kind: Sect
|
|||
const openFilters = async (anchor: HTMLElement) => {
|
||||
const filters = meta.data?.filters ?? [];
|
||||
const bools = filters.filter((f) => f.type === 'boolean');
|
||||
const strings = filters.filter((f) => f.type !== 'boolean' && QUICK_FILTERS.includes(f.filter));
|
||||
const strings = filters.filter((f) => f.type !== 'boolean' && QUICK_FILTERS.includes(f.filter) && !lockedFilters?.[f.filter]);
|
||||
const options = await Promise.all(strings.map((f) => loadOptions(f).catch(() => [])));
|
||||
const items: MenuItem[] = [
|
||||
...bools.map((f) => ({
|
||||
|
|
@ -117,7 +118,8 @@ export function LibraryBrowser({ section, kind }: { section: Section; kind: Sect
|
|||
|
||||
if (meta.isError && !meta.data) return <ErrorState error={meta.error} onRetry={() => meta.refetch()} />;
|
||||
|
||||
const activeFilters = Object.entries(view.filters);
|
||||
const activeFilters = Object.entries(view.filters).filter(([k]) => !lockedFilters?.[k]);
|
||||
const gridFilters = { ...view.filters, ...lockedFilters };
|
||||
return (
|
||||
<div className="library">
|
||||
<div className="lib-toolbar">
|
||||
|
|
@ -182,7 +184,7 @@ export function LibraryBrowser({ section, kind }: { section: Section; kind: Sect
|
|||
</button>
|
||||
</div>
|
||||
)}
|
||||
<LibraryGrid key={`${section.id}|${view.sort}|${JSON.stringify(view.filters)}|${title}`} section={section} type={type} sort={view.sort} filters={view.filters} title={title} sortTitle={sortTitle} />
|
||||
<LibraryGrid key={`${section.id}|${view.sort}|${JSON.stringify(gridFilters)}|${title}`} section={section} type={type} sort={view.sort} filters={gridFilters} title={title} sortTitle={sortTitle} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -276,6 +278,22 @@ function LibraryGrid({ section, type, sort, filters, title, sortTitle }: { secti
|
|||
virtualizer.scrollToIndex(Math.floor(offset / cols), { align: 'start' });
|
||||
};
|
||||
|
||||
// The letter of the first title in view, highlighted on the rail.
|
||||
let current = '';
|
||||
if (alpha && letters.data && vrows.length) {
|
||||
const scrollTop = (scrollEl?.scrollTop ?? 0) - virtualizer.options.scrollMargin + 150;
|
||||
const firstRow = vrows.find((r) => r.end > scrollTop) ?? vrows[0];
|
||||
const list = sort.endsWith(':desc') ? [...letters.data].reverse() : letters.data;
|
||||
let offset = 0;
|
||||
for (const l of list) {
|
||||
offset += l.size;
|
||||
if (firstRow.index * cols < offset) {
|
||||
current = l.title;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (error && total === null) return <ErrorState error={error} onRetry={() => (setError(null), loadPage(0))} />;
|
||||
return (
|
||||
<div className="library-body">
|
||||
|
|
@ -314,7 +332,7 @@ function LibraryGrid({ section, type, sort, filters, title, sortTitle }: { secti
|
|||
{alpha && letters.data && letters.data.length > 3 && (
|
||||
<div className="alpha-rail" aria-label="Jump to letter">
|
||||
{letters.data.map((l) => (
|
||||
<button key={l.title} onClick={() => jump(l.title)} title={`${l.title} · ${l.size}`}>
|
||||
<button key={l.title} className={l.title === current ? 'current' : ''} onClick={() => jump(l.title)} title={`${l.title} · ${l.size}`}>
|
||||
{l.title}
|
||||
</button>
|
||||
))}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { useEffect, useRef, useState } from 'react';
|
||||
import { keepPreviousData } from '@tanstack/react-query';
|
||||
import * as api from '../plex/api';
|
||||
import { useServerQuery } from '../app/queries';
|
||||
import { navigate, useRouter } from '../app/router';
|
||||
|
|
@ -40,12 +41,12 @@ export default function Search({ initial }: { initial?: string }) {
|
|||
input.current?.focus();
|
||||
}, []);
|
||||
useEffect(() => {
|
||||
const t = setTimeout(() => setDebounced(query.trim()), 250);
|
||||
const t = setTimeout(() => setDebounced(query.trim()), 160);
|
||||
useRouter.getState().setState({ query });
|
||||
return () => clearTimeout(t);
|
||||
}, [query]);
|
||||
|
||||
const results = useServerQuery(['search', debounced], (s) => api.search(s, debounced), { enabled: debounced.length > 0, staleTime: 60_000 });
|
||||
const results = useServerQuery(['search', debounced], (s) => api.search(s, debounced), { enabled: debounced.length > 0, staleTime: 60_000, placeholderData: keepPreviousData });
|
||||
const recentlyAdded = useServerQuery(['homeHubs'], (s) => api.homeHubs(s), { enabled: !debounced });
|
||||
|
||||
const remember = (q: string) => {
|
||||
|
|
|
|||
|
|
@ -1,19 +1,22 @@
|
|||
import { useMemo } from 'react';
|
||||
import * as api from '../plex/api';
|
||||
import { useSectionFor, useServerQuery } from '../app/queries';
|
||||
import { navigate, type SectionKind, type SectionTab } from '../app/router';
|
||||
import { navigate, useRouter, type SectionKind, type SectionTab } from '../app/router';
|
||||
import { useSettings } from '../app/settings';
|
||||
import type { Section } from '../plex/types';
|
||||
import { Hero } from '../ui/Hero';
|
||||
import { HubShelf, PosterCard } from '../ui/media';
|
||||
import { EmptyState, ErrorState, PageLoader, Select } from '../ui/primitives';
|
||||
import { HubShelf } from '../ui/media';
|
||||
import { useServer } from '../app/session';
|
||||
import { Icon } from '../ui/Icon';
|
||||
import { categoryArtwork } from './categories';
|
||||
import { Artwork, EmptyState, ErrorState, PageLoader, Select } from '../ui/primitives';
|
||||
import { buildFeatures, HIDDEN_HUBS, recentSeasons } from './discover';
|
||||
import { LibraryBrowser } from './LibraryBrowser';
|
||||
|
||||
const TABS: { id: SectionTab; label: string }[] = [
|
||||
{ id: 'discover', label: 'Discover' },
|
||||
{ id: 'library', label: 'Library' },
|
||||
{ id: 'collections', label: 'Collections' },
|
||||
{ id: 'categories', label: 'Categories' },
|
||||
];
|
||||
|
||||
function SectionHeader({ kind, tab, section, all, overlay }: { kind: SectionKind; tab: SectionTab; section: Section; all: Section[]; overlay: boolean }) {
|
||||
|
|
@ -67,29 +70,65 @@ function Discover({ kind, section }: { kind: SectionKind; section: Section }) {
|
|||
);
|
||||
}
|
||||
|
||||
function Collections({ section }: { section: Section }) {
|
||||
const q = useServerQuery(['collections', section.id], (s) => api.collections(s, section.id));
|
||||
if (q.isError) return <ErrorState error={q.error} onRetry={() => q.refetch()} />;
|
||||
if (!q.data) return <PageLoader />;
|
||||
if (!q.data.length)
|
||||
/** Genres as artwork tiles, as on Kaleido for TV; each opens the library filtered to it. */
|
||||
function Categories({ kind, section }: { kind: SectionKind; section: Section }) {
|
||||
const server = useServer();
|
||||
const type = kind === 'movie' ? 1 : 2;
|
||||
const genres = useServerQuery(['genres', section.id, type], (s) => api.genres(s, section.id, type), { staleTime: 30 * 60_000 });
|
||||
const artwork = useServerQuery(['categoryArtwork', section.id, type, genres.data?.map((g) => g.key).join(',')], (s) => categoryArtwork(s, section.id, type, genres.data ?? []), {
|
||||
enabled: !!genres.data?.length,
|
||||
staleTime: 30 * 60_000,
|
||||
});
|
||||
if (genres.isError) return <ErrorState error={genres.error} onRetry={() => genres.refetch()} />;
|
||||
if (!genres.data) return <PageLoader />;
|
||||
if (!genres.data.length)
|
||||
return (
|
||||
<EmptyState icon="collection" title="No collections yet">
|
||||
Collections created in Plex for {section.title} appear here.
|
||||
<EmptyState icon="grid" title="No categories">
|
||||
{section.title} has no genres yet.
|
||||
</EmptyState>
|
||||
);
|
||||
return (
|
||||
<div className="page-pad">
|
||||
<div className="grid-count">{q.data.length.toLocaleString()} collections</div>
|
||||
<div className="poster-grid auto">
|
||||
{q.data.map((c) => (
|
||||
<PosterCard key={c.id} item={c} />
|
||||
))}
|
||||
<div className="category-grid">
|
||||
{genres.data.map((g) => {
|
||||
const path = artwork.data?.[g.key];
|
||||
return (
|
||||
<button key={g.key} className="category-tile" onClick={() => navigate({ name: 'section', kind, tab: 'categories', genre: g.key, genreTitle: g.title })}>
|
||||
{path && <Artwork src={server.image(path, 540, 304)} />}
|
||||
<span className="category-scrim" />
|
||||
<span className="category-title">{g.title}</span>
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function SectionScreen({ kind, tab }: { kind: SectionKind; tab: SectionTab }) {
|
||||
/** Back to the grid: pop the history entry when that's where the genre was opened from. */
|
||||
function backToCategories(kind: SectionKind) {
|
||||
const { entries, index, back } = useRouter.getState();
|
||||
const prev = entries[index - 1]?.route;
|
||||
if (prev?.name === 'section' && prev.tab === 'categories' && !prev.genre) back();
|
||||
else navigate({ name: 'section', kind, tab: 'categories' }, { replace: true });
|
||||
}
|
||||
|
||||
function CategoryLibrary({ kind, section, genre, title }: { kind: SectionKind; section: Section; genre: string; title: string }) {
|
||||
return (
|
||||
<>
|
||||
<div className="category-head">
|
||||
<button className="category-back" onClick={() => backToCategories(kind)}>
|
||||
<Icon name="back" size={16} />
|
||||
Categories
|
||||
</button>
|
||||
<h2>{title}</h2>
|
||||
</div>
|
||||
<LibraryBrowser section={section} kind={kind} lockedFilters={{ genre }} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export function SectionScreen({ kind, tab, genre, genreTitle }: { kind: SectionKind; tab: SectionTab; genre?: string; genreTitle?: string }) {
|
||||
const { section, all, loading } = useSectionFor(kind);
|
||||
if (loading) return <PageLoader />;
|
||||
if (!section)
|
||||
|
|
@ -105,7 +144,7 @@ export function SectionScreen({ kind, tab }: { kind: SectionKind; tab: SectionTa
|
|||
<SectionHeader kind={kind} tab={tab} section={section} all={all} overlay={tab === 'discover'} />
|
||||
{tab === 'discover' && <Discover kind={kind} section={section} />}
|
||||
{tab === 'library' && <LibraryBrowser section={section} kind={kind} />}
|
||||
{tab === 'collections' && <Collections section={section} />}
|
||||
{tab === 'categories' && (genre ? <CategoryLibrary kind={kind} section={section} genre={genre} title={genreTitle ?? ''} /> : <Categories kind={kind} section={section} />)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,44 +1,407 @@
|
|||
import { useEffect, useState } from 'react';
|
||||
import { useEffect, useRef } from 'react';
|
||||
import { useSettings } from '../app/settings';
|
||||
|
||||
const FACETS = [
|
||||
{ fill: '#C3E8D3', d: 'M33,4 L55.5,17 L42.5,24.5 L33,19 Z' },
|
||||
{ fill: '#71B9B0', d: 'M56.5,19 L56.5,45 L43.5,37.5 L43.5,26.5 Z' },
|
||||
{ fill: '#3D7C7B', d: 'M55.5,47 L33,60 L33,45 L42.5,39.5 Z' },
|
||||
{ fill: '#D0A977', d: 'M31,60 L8.5,47 L21.5,39.5 L31,45 Z' },
|
||||
{ fill: '#E9D8AE', d: 'M7.5,45 L7.5,19 L20.5,26.5 L20.5,37.5 Z' },
|
||||
{ fill: '#EEF2DD', d: 'M8.5,17 L31,4 L31,19 L21.5,24.5 Z' },
|
||||
];
|
||||
|
||||
/**
|
||||
* The cold-start aperture: the six facets twist open around the dark center,
|
||||
* hold until startup data is ready, then the view flies through the aperture.
|
||||
* The cold-start brand sequence, the same as Kaleido for TV: a closed iris lit
|
||||
* from behind twists open, light catches the facets and the wordmark slides out
|
||||
* of the mark. Once startup is ready the camera flies through the aperture's
|
||||
* dark centre, revealing the app drawn beneath (which settles from a slight
|
||||
* zoom, `html.splash-arrival`).
|
||||
*/
|
||||
|
||||
type Point = { x: number; y: number };
|
||||
|
||||
/** CSS-style cubic-bezier easing (x → y). */
|
||||
function bezier(x1: number, y1: number, x2: number, y2: number) {
|
||||
const cx = 3 * x1;
|
||||
const bx = 3 * (x2 - x1) - cx;
|
||||
const ax = 1 - cx - bx;
|
||||
const cy = 3 * y1;
|
||||
const by = 3 * (y2 - y1) - cy;
|
||||
const ay = 1 - cy - by;
|
||||
const sx = (t: number) => ((ax * t + bx) * t + cx) * t;
|
||||
const sy = (t: number) => ((ay * t + by) * t + cy) * t;
|
||||
const dx = (t: number) => (3 * ax * t + 2 * bx) * t + cx;
|
||||
return (x: number) => {
|
||||
if (x <= 0) return 0;
|
||||
if (x >= 1) return 1;
|
||||
let t = x;
|
||||
for (let i = 0; i < 8; i++) {
|
||||
const err = sx(t) - x;
|
||||
const d = dx(t);
|
||||
if (Math.abs(err) < 1e-5 || Math.abs(d) < 1e-6) break;
|
||||
t -= err / d;
|
||||
}
|
||||
t = Math.min(1, Math.max(0, t));
|
||||
return sy(t);
|
||||
};
|
||||
}
|
||||
|
||||
const Emphasized = bezier(0.2, 0, 0, 1);
|
||||
const EmphasizedDecelerate = bezier(0.05, 0.7, 0.1, 1);
|
||||
const Standard = bezier(0.4, 0, 0.2, 1);
|
||||
const InOut = bezier(0.45, 0, 0.55, 1);
|
||||
// A mechanical iris: the blades gather, snap open and overshoot slightly as they lock.
|
||||
const IrisOpen = bezier(0.55, 0, 0.15, 1);
|
||||
const IrisTwist = bezier(0.5, 0, 0.18, 1.1);
|
||||
// Applied in log space: a brief pull back, then an accelerating flight.
|
||||
const Flight = bezier(0.55, -0.06, 0.8, 0.36);
|
||||
|
||||
const phase = (time: number, start: number, end: number) => Math.min(1, Math.max(0, (time - start) / (end - start)));
|
||||
const mix = (from: number, to: number, amount: number) => from + (to - from) * amount;
|
||||
|
||||
// The brand mark's facets, centred on its 64-unit viewport, each with the
|
||||
// outward normal of its hexagon edge for the iris motion.
|
||||
const FACETS = (
|
||||
[
|
||||
[[33, 4, 55.5, 17, 42.5, 24.5, 33, 19], '#C3E8D3'],
|
||||
[[56.5, 19, 56.5, 45, 43.5, 37.5, 43.5, 26.5], '#71B9B0'],
|
||||
[[55.5, 47, 33, 60, 33, 45, 42.5, 39.5], '#3D7C7B'],
|
||||
[[31, 60, 8.5, 47, 21.5, 39.5, 31, 45], '#D0A977'],
|
||||
[[7.5, 45, 7.5, 19, 20.5, 26.5, 20.5, 37.5], '#E9D8AE'],
|
||||
[[8.5, 17, 31, 4, 31, 19, 21.5, 24.5], '#EEF2DD'],
|
||||
] as [number[], string][]
|
||||
).map(([pts, color], i) => {
|
||||
const angle = ((-60 + 60 * i) * Math.PI) / 180;
|
||||
const points: Point[] = [];
|
||||
for (let k = 0; k < pts.length; k += 2) points.push({ x: pts[k] - 32, y: pts[k + 1] - 32 });
|
||||
return { points, color, normal: { x: Math.cos(angle), y: Math.sin(angle) } };
|
||||
});
|
||||
|
||||
// The inner hexagon traced by the facets' inner edges: the aperture the exit flies through.
|
||||
const INNER_RADIUS = 13.6;
|
||||
const INNER_APOTHEM = 11.8;
|
||||
const INTRO_BOX = 132;
|
||||
// The settled lockup is the header brand scaled up, so it reads as the same mark.
|
||||
const LOCK_SCALE = 2.75;
|
||||
const LOCK_BOX = 29 * LOCK_SCALE;
|
||||
const LOCK_GAP = 7 * LOCK_SCALE;
|
||||
// Timeline (ms): held at GATHER_END until startup is ready (at most HOLD_MAX),
|
||||
// complete at INTRO_END; the slow settle runs on to TIMELINE_END.
|
||||
const GATHER_END = 260;
|
||||
const INTRO_END = 2260;
|
||||
const TIMELINE_END = 2900;
|
||||
const HOLD_MAX = 700;
|
||||
const EXIT_MS = 640;
|
||||
|
||||
const INK = '#090a0c';
|
||||
const WORDMARK = '#F1F1F1';
|
||||
const SEA_GLASS = [113, 185, 176];
|
||||
const rgba = (c: number[], a: number) => `rgba(${c[0]}, ${c[1]}, ${c[2]}, ${Math.max(0, a)})`;
|
||||
|
||||
interface Iris {
|
||||
inward: number;
|
||||
theta: number;
|
||||
grow: number;
|
||||
}
|
||||
function irisAt(time: number): Iris {
|
||||
const p = phase(time, 140, 1180);
|
||||
return { inward: INNER_APOTHEM * (1 - IrisOpen(p)), theta: ((-44 * (1 - IrisTwist(p))) * Math.PI) / 180, grow: mix(0.64, 1, Emphasized(p)) };
|
||||
}
|
||||
|
||||
function facetPath(ctx: CanvasRenderingContext2D, facet: (typeof FACETS)[number], iris: Iris, unit: number, o: Point) {
|
||||
const c = Math.cos(iris.theta);
|
||||
const s = Math.sin(iris.theta);
|
||||
const k = unit * iris.grow;
|
||||
facet.points.forEach((p, i) => {
|
||||
const x = p.x - facet.normal.x * iris.inward;
|
||||
const y = p.y - facet.normal.y * iris.inward;
|
||||
const px = o.x + (x * c - y * s) * k;
|
||||
const py = o.y + (x * s + y * c) * k;
|
||||
if (i === 0) ctx.moveTo(px, py);
|
||||
else ctx.lineTo(px, py);
|
||||
});
|
||||
ctx.closePath();
|
||||
}
|
||||
|
||||
function hexagon(ctx: CanvasRenderingContext2D, o: Point, radius: number) {
|
||||
for (let i = 0; i < 6; i++) {
|
||||
const a = ((-90 + 60 * i) * Math.PI) / 180;
|
||||
const x = o.x + Math.cos(a) * radius;
|
||||
const y = o.y + Math.sin(a) * radius;
|
||||
if (i === 0) ctx.moveTo(x, y);
|
||||
else ctx.lineTo(x, y);
|
||||
}
|
||||
ctx.closePath();
|
||||
}
|
||||
|
||||
interface Letters {
|
||||
font: string;
|
||||
chars: string[];
|
||||
x: number[];
|
||||
width: number;
|
||||
cap: number;
|
||||
}
|
||||
|
||||
function draw(ctx: CanvasRenderingContext2D, w: number, h: number, time: number, q: number, letters: Letters) {
|
||||
const center = { x: w / 2, y: h / 2 };
|
||||
ctx.clearRect(0, 0, w, h);
|
||||
const lockup = Emphasized(phase(time, 1250, 2000));
|
||||
const lockWidth = LOCK_BOX + LOCK_GAP + letters.width;
|
||||
const box = mix(INTRO_BOX, LOCK_BOX, lockup);
|
||||
// A slow push-in keeps the settled frame alive.
|
||||
const drift = 1 + 0.025 * InOut(phase(time, 1900, 2900));
|
||||
let cx = mix(center.x, center.x - lockWidth / 2 + LOCK_BOX / 2, lockup);
|
||||
let cy = center.y;
|
||||
let zoom = 1;
|
||||
let textAlpha = 1;
|
||||
let textShift = 0;
|
||||
let hole = 0;
|
||||
if (q > 0) {
|
||||
zoom = Math.exp(Math.log(52) * Flight(q));
|
||||
const recenter = Standard(Math.min(1, q / 0.75));
|
||||
cx = mix(cx, center.x, recenter);
|
||||
cy = mix(cy, center.y, recenter);
|
||||
textAlpha = 1 - Standard(phase(q, 0, 0.4));
|
||||
textShift = -14 * Standard(phase(q, 0, 0.4));
|
||||
hole = InOut(phase(q, 0.12, 0.5));
|
||||
}
|
||||
const unit = (box / 64) * drift * zoom;
|
||||
const o = { x: cx, y: cy };
|
||||
|
||||
// The surface: ink everywhere, with the aperture's centre cut away on exit.
|
||||
ctx.globalCompositeOperation = 'source-over';
|
||||
ctx.globalAlpha = 1;
|
||||
ctx.fillStyle = INK;
|
||||
ctx.beginPath();
|
||||
ctx.rect(0, 0, w, h);
|
||||
if (hole > 0) hexagon(ctx, o, INNER_RADIUS * unit);
|
||||
ctx.fill('evenodd');
|
||||
if (hole > 0 && hole < 1) {
|
||||
ctx.globalAlpha = 1 - hole;
|
||||
ctx.beginPath();
|
||||
hexagon(ctx, o, INNER_RADIUS * unit);
|
||||
ctx.fill();
|
||||
ctx.globalAlpha = 1;
|
||||
}
|
||||
|
||||
const iris = irisAt(time);
|
||||
const lightUp = EmphasizedDecelerate(phase(time, 0, 620));
|
||||
const light = lightUp * (1 - Standard(phase(time, 620, 1250)));
|
||||
const ambient = 0.03 * InOut(phase(time, 300, 900)) * (1 - Standard(phase(time, 1500, 2300)));
|
||||
// Light behind the blades: a soft bloom, a hot core, and rays leaking
|
||||
// through the six gaps while the iris turns.
|
||||
if (light > 0.001 || ambient > 0.001) {
|
||||
ctx.globalCompositeOperation = 'lighter';
|
||||
const bloom = 250;
|
||||
let g = ctx.createRadialGradient(o.x, o.y, 0, o.x, o.y, bloom);
|
||||
g.addColorStop(0, rgba(SEA_GLASS, 0.16 * light + ambient));
|
||||
g.addColorStop(0.45, rgba(SEA_GLASS, 0.04 * light + ambient * 0.3));
|
||||
g.addColorStop(1, rgba(SEA_GLASS, 0));
|
||||
ctx.fillStyle = g;
|
||||
ctx.beginPath();
|
||||
ctx.arc(o.x, o.y, bloom, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
if (light > 0.001) {
|
||||
const core = ((26 * unit) / 2.0625) * mix(0.6, 1, light);
|
||||
g = ctx.createRadialGradient(o.x, o.y, 0, o.x, o.y, core);
|
||||
g.addColorStop(0, `rgba(255, 250, 236, ${0.95 * light})`);
|
||||
g.addColorStop(0.35, `rgba(238, 242, 221, ${0.55 * light})`);
|
||||
g.addColorStop(1, 'rgba(238, 242, 221, 0)');
|
||||
ctx.fillStyle = g;
|
||||
ctx.beginPath();
|
||||
ctx.arc(o.x, o.y, core, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
const rays = light * Math.min(1, IrisOpen(phase(time, 140, 1180)) * 2.5);
|
||||
for (let i = 0; i < 6; i++) {
|
||||
const angle = ((-90 + 60 * i) * Math.PI) / 180 + iris.theta;
|
||||
const length = mix(40, 250, lightUp) * (0.75 + 0.25 * Math.sin(i * 2.1 + 1));
|
||||
const end = { x: o.x + Math.cos(angle) * length, y: o.y + Math.sin(angle) * length };
|
||||
g = ctx.createLinearGradient(o.x, o.y, end.x, end.y);
|
||||
g.addColorStop(0, `rgba(255, 248, 230, ${0.42 * rays})`);
|
||||
g.addColorStop(0.25, `rgba(214, 236, 226, ${0.12 * rays})`);
|
||||
g.addColorStop(1, 'rgba(214, 236, 226, 0)');
|
||||
ctx.fillStyle = g;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(o.x, o.y);
|
||||
ctx.lineTo(o.x + Math.cos(angle - 0.014) * length, o.y + Math.sin(angle - 0.014) * length);
|
||||
ctx.lineTo(o.x + Math.cos(angle + 0.014) * length, o.y + Math.sin(angle + 0.014) * length);
|
||||
ctx.closePath();
|
||||
ctx.fill();
|
||||
}
|
||||
}
|
||||
ctx.globalCompositeOperation = 'source-over';
|
||||
}
|
||||
|
||||
// Facets. Short echoes of earlier frames act as motion blur while the
|
||||
// blades turn; they disappear beneath the facets once the iris is still.
|
||||
const facetAlpha = (i: number) => EmphasizedDecelerate(phase(time, 40 + i * 34, 380 + i * 34));
|
||||
if (time < 1400) {
|
||||
for (const [delay, alpha] of [
|
||||
[84, 0.07],
|
||||
[56, 0.12],
|
||||
[28, 0.2],
|
||||
]) {
|
||||
const echo = irisAt(time - delay);
|
||||
FACETS.forEach((f, i) => {
|
||||
ctx.globalAlpha = alpha * facetAlpha(i);
|
||||
ctx.fillStyle = f.color;
|
||||
ctx.beginPath();
|
||||
facetPath(ctx, f, echo, unit, o);
|
||||
ctx.fill();
|
||||
});
|
||||
}
|
||||
}
|
||||
FACETS.forEach((f, i) => {
|
||||
ctx.globalAlpha = facetAlpha(i);
|
||||
ctx.fillStyle = f.color;
|
||||
ctx.beginPath();
|
||||
facetPath(ctx, f, iris, unit, o);
|
||||
ctx.fill();
|
||||
});
|
||||
ctx.globalAlpha = 1;
|
||||
|
||||
const sheen = phase(time, 980, 1560);
|
||||
if (light > 0.01 || (sheen > 0 && sheen < 1)) {
|
||||
ctx.save();
|
||||
ctx.beginPath();
|
||||
FACETS.forEach((f) => facetPath(ctx, f, iris, unit, o));
|
||||
ctx.clip();
|
||||
// Backlight tints the blades while the core is hot, so they read as glass.
|
||||
if (light > 0.01) {
|
||||
const radius = (36 * unit) / 2.0625;
|
||||
const g = ctx.createRadialGradient(o.x, o.y, 0, o.x, o.y, radius);
|
||||
g.addColorStop(0, `rgba(255, 252, 240, ${0.26 * light})`);
|
||||
g.addColorStop(1, 'rgba(255, 252, 240, 0)');
|
||||
ctx.fillStyle = g;
|
||||
ctx.fillRect(o.x - radius, o.y - radius, radius * 2, radius * 2);
|
||||
}
|
||||
// One diagonal band of light crosses the settled mark.
|
||||
if (sheen > 0 && sheen < 1) {
|
||||
const reach = 34 * unit;
|
||||
const a = (36 * Math.PI) / 180;
|
||||
const d = { x: Math.cos(a), y: Math.sin(a) };
|
||||
const pos = mix(-1.25, 1.25, InOut(sheen)) * reach;
|
||||
const width = 10 * unit;
|
||||
const peak = 0.42 * Math.sin(Math.min(1, sheen * 1.1) * Math.PI);
|
||||
const g = ctx.createLinearGradient(o.x + d.x * (pos - width), o.y + d.y * (pos - width), o.x + d.x * (pos + width), o.y + d.y * (pos + width));
|
||||
g.addColorStop(0, 'rgba(255, 255, 255, 0)');
|
||||
g.addColorStop(0.5, `rgba(255, 255, 255, ${peak})`);
|
||||
g.addColorStop(1, 'rgba(255, 255, 255, 0)');
|
||||
ctx.fillStyle = g;
|
||||
ctx.fillRect(o.x - reach, o.y - reach, reach * 2, reach * 2);
|
||||
}
|
||||
ctx.restore();
|
||||
}
|
||||
|
||||
// The wordmark slides out from behind the mark as it moves into the lockup.
|
||||
if (time >= 1400 && textAlpha > 0) {
|
||||
const scale = (box / LOCK_BOX) * drift;
|
||||
const textLeft = cx - (box * drift) / 2 + (LOCK_BOX + LOCK_GAP) * scale;
|
||||
const slide = EmphasizedDecelerate(phase(time, 1400, 2050));
|
||||
const baseline = cy + (letters.cap / 2) * scale;
|
||||
ctx.save();
|
||||
ctx.beginPath();
|
||||
const clipLeft = cx + 24.5 * unit + 2 * scale;
|
||||
ctx.rect(clipLeft, 0, w - clipLeft, h);
|
||||
ctx.clip();
|
||||
ctx.font = letters.font;
|
||||
ctx.fillStyle = WORDMARK;
|
||||
ctx.textBaseline = 'alphabetic';
|
||||
letters.chars.forEach((ch, i) => {
|
||||
const start = 1460 + i * 45;
|
||||
const reveal = Standard(phase(time, start, start + 320));
|
||||
if (reveal <= 0) return;
|
||||
ctx.save();
|
||||
ctx.globalAlpha = reveal * textAlpha;
|
||||
ctx.translate(textLeft + (letters.x[i] - (1 - slide) * letters.width * 0.42) * scale + textShift, baseline);
|
||||
ctx.scale(scale, scale);
|
||||
ctx.fillText(ch, 0, 0);
|
||||
ctx.restore();
|
||||
});
|
||||
ctx.restore();
|
||||
}
|
||||
}
|
||||
|
||||
async function measureLetters(): Promise<Letters> {
|
||||
const size = 19 * LOCK_SCALE;
|
||||
const font = `700 ${size}px 'Inter Variable', 'Segoe UI', sans-serif`;
|
||||
await document.fonts?.load(font).catch(() => {});
|
||||
const ctx = document.createElement('canvas').getContext('2d')!;
|
||||
ctx.font = font;
|
||||
const tracking = 1.4 * LOCK_SCALE;
|
||||
const chars = 'KALEIDO'.split('');
|
||||
const x: number[] = [];
|
||||
let at = 0;
|
||||
for (const ch of chars) {
|
||||
x.push(at);
|
||||
at += ctx.measureText(ch).width + tracking;
|
||||
}
|
||||
return { font, chars, x, width: at - tracking, cap: size * 0.711 };
|
||||
}
|
||||
|
||||
export function Splash({ ready, onDone }: { ready: boolean; onDone: () => void }) {
|
||||
const reduced = useSettings((s) => s.reducedMotion);
|
||||
const [phase, setPhase] = useState<'opening' | 'held' | 'leaving'>('opening');
|
||||
const canvas = useRef<HTMLCanvasElement>(null);
|
||||
const readyRef = useRef(ready);
|
||||
readyRef.current = ready;
|
||||
const done = useRef(onDone);
|
||||
done.current = onDone;
|
||||
|
||||
useEffect(() => {
|
||||
const t = setTimeout(() => setPhase('held'), reduced ? 0 : 1100);
|
||||
return () => clearTimeout(t);
|
||||
const el = canvas.current;
|
||||
if (!el) return;
|
||||
if (reduced) {
|
||||
// No sequence: wait for startup, then hand straight over.
|
||||
const t = setInterval(() => readyRef.current && (clearInterval(t), done.current()), 50);
|
||||
return () => clearInterval(t);
|
||||
}
|
||||
const ctx = el.getContext('2d')!;
|
||||
let raf = 0;
|
||||
let stopped = false;
|
||||
let letters: Letters | null = null;
|
||||
const size = () => {
|
||||
const dpr = window.devicePixelRatio || 1;
|
||||
el.width = Math.round(window.innerWidth * dpr);
|
||||
el.height = Math.round(window.innerHeight * dpr);
|
||||
ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
|
||||
};
|
||||
size();
|
||||
window.addEventListener('resize', size);
|
||||
|
||||
// Timeline time advances with the clock, except while held at GATHER_END.
|
||||
let last = 0;
|
||||
let time = 0;
|
||||
let held = 0;
|
||||
let exitStart = 0;
|
||||
const frame = (now: number) => {
|
||||
if (stopped) return;
|
||||
const dt = last ? Math.min(64, now - last) : 0;
|
||||
last = now;
|
||||
if (time < GATHER_END) time = Math.min(GATHER_END, time + dt);
|
||||
else if (time === GATHER_END && !readyRef.current && held < HOLD_MAX) held += dt;
|
||||
else time = Math.min(TIMELINE_END, time + dt);
|
||||
if (!exitStart && time >= INTRO_END && readyRef.current) {
|
||||
exitStart = now;
|
||||
document.documentElement.classList.add('splash-arrival');
|
||||
}
|
||||
const q = exitStart ? Math.min(1, (now - exitStart) / EXIT_MS) : 0;
|
||||
if (letters) draw(ctx, window.innerWidth, window.innerHeight, time, q, letters);
|
||||
if (q >= 1) {
|
||||
done.current();
|
||||
return;
|
||||
}
|
||||
raf = requestAnimationFrame(frame);
|
||||
};
|
||||
// Draw the first (dark) frame at once; start the clock once the wordmark's font is ready.
|
||||
ctx.fillStyle = INK;
|
||||
ctx.fillRect(0, 0, window.innerWidth, window.innerHeight);
|
||||
measureLetters().then((l) => {
|
||||
letters = l;
|
||||
if (!stopped) raf = requestAnimationFrame(frame);
|
||||
});
|
||||
return () => {
|
||||
stopped = true;
|
||||
cancelAnimationFrame(raf);
|
||||
window.removeEventListener('resize', size);
|
||||
// Let the arrival settle finish after the splash is gone.
|
||||
setTimeout(() => document.documentElement.classList.remove('splash-arrival'), 700);
|
||||
};
|
||||
}, [reduced]);
|
||||
useEffect(() => {
|
||||
if (phase === 'held' && ready) setPhase('leaving');
|
||||
}, [phase, ready]);
|
||||
useEffect(() => {
|
||||
if (phase !== 'leaving') return;
|
||||
const t = setTimeout(onDone, reduced ? 0 : 620);
|
||||
return () => clearTimeout(t);
|
||||
}, [phase]);
|
||||
|
||||
return (
|
||||
<div className={`splash ${phase}`} data-tauri-drag-region>
|
||||
<div className="splash-mark">
|
||||
<svg viewBox="0 0 64 64" width="92" height="92" aria-hidden="true">
|
||||
{FACETS.map((f, i) => (
|
||||
<path key={i} d={f.d} fill={f.fill} style={{ ['--i' as string]: i }} />
|
||||
))}
|
||||
</svg>
|
||||
<span className="splash-word">KALEIDO</span>
|
||||
</div>
|
||||
<div className="splash" data-tauri-drag-region aria-label="Kaleido starting" role="img">
|
||||
<canvas ref={canvas} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
78
src/screens/categories.ts
Normal file
78
src/screens/categories.ts
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
import * as api from '../plex/api';
|
||||
import type { PlexServer } from '../plex/client';
|
||||
import type { Item } from '../plex/types';
|
||||
|
||||
/** Plex timestamps or query strings don't make a refreshed image a different picture. */
|
||||
export function artworkIdentity(path: string): string {
|
||||
return path.split('?')[0].replace(/(\/(?:art|thumb))\/\d+$/, '$1');
|
||||
}
|
||||
|
||||
/**
|
||||
* Matches genres to distinct artwork, moving an earlier choice when a later
|
||||
* genre needs it (augmenting paths), so two tiles never share a picture.
|
||||
* Narrow genres choose first so a broad one can't take their only source.
|
||||
*/
|
||||
export function selectCategoryArtwork<T>(candidates: Map<string, T[]>, identity: (t: T) => string): Map<string, T> {
|
||||
const options = new Map<string, T[]>();
|
||||
for (const [genre, items] of candidates) {
|
||||
const seen = new Set<string>();
|
||||
options.set(
|
||||
genre,
|
||||
items.filter((i) => {
|
||||
const id = identity(i);
|
||||
if (!id || seen.has(id)) return false;
|
||||
seen.add(id);
|
||||
return true;
|
||||
}),
|
||||
);
|
||||
}
|
||||
const owners = new Map<string, string>();
|
||||
const selected = new Map<string, T>();
|
||||
const assign = (genre: string, visited: Set<string>): boolean => {
|
||||
const choices = options.get(genre) ?? [];
|
||||
const free = choices.find((i) => !owners.has(identity(i)) && !visited.has(identity(i)));
|
||||
if (free) {
|
||||
owners.set(identity(free), genre);
|
||||
selected.set(genre, free);
|
||||
return true;
|
||||
}
|
||||
for (const item of choices) {
|
||||
const key = identity(item);
|
||||
if (visited.has(key)) continue;
|
||||
visited.add(key);
|
||||
const previous = owners.get(key);
|
||||
if (previous && assign(previous, visited)) {
|
||||
owners.set(key, genre);
|
||||
selected.set(genre, item);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
[...options.keys()].sort((a, b) => options.get(a)!.length - options.get(b)!.length).forEach((g) => assign(g, new Set()));
|
||||
return selected;
|
||||
}
|
||||
|
||||
const backdropOf = (i: Item) => i.art || i.thumb;
|
||||
|
||||
/** One distinct, well-liked title's artwork per genre, fetched a few genres at a time. */
|
||||
export async function categoryArtwork(s: PlexServer, sectionId: string, type: number, genres: { key: string; title: string }[]): Promise<Record<string, string>> {
|
||||
const candidates = new Map<string, Item[]>();
|
||||
const queue = [...genres];
|
||||
const worker = async () => {
|
||||
for (let g = queue.shift(); g; g = queue.shift()) {
|
||||
const page = await api
|
||||
.libraryPage(s, sectionId, { type, sort: 'audienceRating:desc', filters: { genre: g.key }, start: 0, size: 24 })
|
||||
.catch(() => api.libraryPage(s, sectionId, { type, filters: { genre: g.key }, start: 0, size: 24 }))
|
||||
.catch(() => null);
|
||||
candidates.set(g.key, (page?.items ?? []).filter((i) => i.art));
|
||||
}
|
||||
};
|
||||
await Promise.all(Array.from({ length: 4 }, worker));
|
||||
const chosen = selectCategoryArtwork(candidates, (i) => artworkIdentity(backdropOf(i)));
|
||||
const out: Record<string, string> = {};
|
||||
for (const [genre, item] of chosen) out[genre] = backdropOf(item);
|
||||
// Genres whose only titles were all taken still get a picture.
|
||||
for (const [genre, items] of candidates) if (!out[genre] && items[0]) out[genre] = backdropOf(items[0]);
|
||||
return out;
|
||||
}
|
||||
|
|
@ -1,11 +1,13 @@
|
|||
import { useEffect, useState } from 'react';
|
||||
import { useSettings, QUALITY_LABEL, type Quality, type SkipMode, type SubtitleMode } from '../../app/settings';
|
||||
import { useSettings, QUALITY_LABEL, SUBTITLE_COLORS, SUBTITLE_MARGIN, type Preferences, type Quality, type SkipMode, type SubtitleBox, type SubtitleEdge, type SubtitleMode, type SubtitlePosition } from '../../app/settings';
|
||||
import { useSession } from '../../app/session';
|
||||
import { useSections } from '../../app/queries';
|
||||
import { useSections, useServerQuery } from '../../app/queries';
|
||||
import * as api from '../../plex/api';
|
||||
import { art } from '../../app/format';
|
||||
import { useDownloads } from '../../downloads/store';
|
||||
import { appInfo, isNative, openExternal, pickFolder, revealPath, type AppInfo } from '../../platform/native';
|
||||
import { checkForUpdate, installUpdate, useUpdater } from '../../app/updater';
|
||||
import { Button, Select, Switch } from '../../ui/primitives';
|
||||
import { Button, Segmented, Select, Switch } from '../../ui/primitives';
|
||||
import { confirmDialog } from '../../ui/overlays';
|
||||
import { Pref, SettingsSection } from './parts';
|
||||
import { KaleidoMark } from '../../ui/primitives';
|
||||
|
|
@ -61,10 +63,45 @@ const SHORTCUTS: [string, string][][] = [
|
|||
['C', 'Next subtitle track'],
|
||||
['Shift + N', 'Next episode'],
|
||||
['0–9', 'Jump to 0–90%'],
|
||||
['Esc', 'Exit full screen, then the player'],
|
||||
['Esc or Backspace', 'Exit full screen, then keep playing in the corner'],
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* A frame from the library with a sample line drawn the way mpv will draw it:
|
||||
* sizes are in mpv's scaled pixels, where the frame height is 720.
|
||||
*/
|
||||
function SubtitlePreview({ prefs }: { prefs: Preferences }) {
|
||||
const session = useSession();
|
||||
const cw = useServerQuery(['continue'], (srv) => api.continueWatching(srv), { enabled: !!session.server, staleTime: 15_000 });
|
||||
const still = cw.data?.find((i) => art.backdrop(i));
|
||||
const px = (n: number) => `calc(${n} / 720 * 100cqh)`;
|
||||
const edge = prefs.subtitleBox === 'none' ? prefs.subtitleEdge : 'none';
|
||||
const outline = edge === 'outline' ? 1.8 : edge === 'raised' ? 1.3 : 0;
|
||||
const shadow = edge === 'shadow' ? 2.2 : edge === 'raised' ? 1.6 : 0;
|
||||
return (
|
||||
<div className="subtitle-preview">
|
||||
{still && session.server && <img src={session.server.image(art.backdrop(still), 960, 540)} alt="" draggable={false} />}
|
||||
<div className="subtitle-preview-line" style={{ bottom: px(SUBTITLE_MARGIN[prefs.subtitlePosition]) }}>
|
||||
<span
|
||||
className={prefs.subtitleBox}
|
||||
style={{
|
||||
color: prefs.subtitleColor,
|
||||
fontSize: px(38 * prefs.subtitleScale),
|
||||
fontWeight: prefs.subtitleBold ? 700 : 400,
|
||||
WebkitTextStroke: outline ? `${px(outline * 2)} #000` : undefined,
|
||||
textShadow: shadow ? `${px(shadow)} ${px(shadow)} 0 rgba(0, 0, 0, 0.7)` : undefined,
|
||||
}}
|
||||
>
|
||||
The night is darkest just before the dawn.
|
||||
<br />
|
||||
And I promise you, the dawn is coming.
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function AppSettings({ tab }: { tab: string }) {
|
||||
const s = useSettings();
|
||||
const set = s.set;
|
||||
|
|
@ -190,6 +227,9 @@ export function AppSettings({ tab }: { tab: string }) {
|
|||
<Pref label="Subtitle language" description="Automatic uses the language of the audio track.">
|
||||
<Select value={s.subtitleLanguage} onChange={(v) => set('subtitleLanguage', v)} options={LANGUAGES.map(([value, label]) => ({ value, label }))} />
|
||||
</Pref>
|
||||
</SettingsSection>
|
||||
<SettingsSection title="Subtitle style" description="How text subtitles look. Image subtitles (Blu-ray, DVD) and styled ASS subtitles keep their own look. Changes apply to a playing video straight away.">
|
||||
<SubtitlePreview prefs={s} />
|
||||
<Pref label="Size">
|
||||
<Select
|
||||
value={s.subtitleScale}
|
||||
|
|
@ -202,8 +242,58 @@ export function AppSettings({ tab }: { tab: string }) {
|
|||
]}
|
||||
/>
|
||||
</Pref>
|
||||
<Pref label="Background box" description="Draws text subtitles on a dark box for contrast.">
|
||||
<Switch checked={s.subtitleBackground} onChange={(v) => set('subtitleBackground', v)} />
|
||||
<Pref label="Text colour">
|
||||
<div className="swatches" role="radiogroup" aria-label="Text colour">
|
||||
{SUBTITLE_COLORS.map((c) => (
|
||||
<button
|
||||
key={c.value}
|
||||
role="radio"
|
||||
aria-checked={s.subtitleColor === c.value}
|
||||
aria-label={c.label}
|
||||
title={c.label}
|
||||
className={s.subtitleColor === c.value ? 'selected' : ''}
|
||||
style={{ background: c.value }}
|
||||
onClick={() => set('subtitleColor', c.value)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</Pref>
|
||||
<Pref label="Edge">
|
||||
<Segmented<SubtitleEdge>
|
||||
value={s.subtitleEdge}
|
||||
onChange={(v) => set('subtitleEdge', v)}
|
||||
options={[
|
||||
{ value: 'outline', label: 'Outline' },
|
||||
{ value: 'shadow', label: 'Shadow' },
|
||||
{ value: 'raised', label: 'Both' },
|
||||
{ value: 'none', label: 'None' },
|
||||
]}
|
||||
/>
|
||||
</Pref>
|
||||
<Pref label="Background">
|
||||
<Segmented<SubtitleBox>
|
||||
value={s.subtitleBox}
|
||||
onChange={(v) => set('subtitleBox', v)}
|
||||
options={[
|
||||
{ value: 'none', label: 'None' },
|
||||
{ value: 'translucent', label: 'Translucent' },
|
||||
{ value: 'solid', label: 'Solid' },
|
||||
]}
|
||||
/>
|
||||
</Pref>
|
||||
<Pref label="Bold">
|
||||
<Switch checked={s.subtitleBold} onChange={(v) => set('subtitleBold', v)} />
|
||||
</Pref>
|
||||
<Pref label="Position">
|
||||
<Segmented<SubtitlePosition>
|
||||
value={s.subtitlePosition}
|
||||
onChange={(v) => set('subtitlePosition', v)}
|
||||
options={[
|
||||
{ value: 'low', label: 'Low' },
|
||||
{ value: 'normal', label: 'Normal' },
|
||||
{ value: 'high', label: 'Raised' },
|
||||
]}
|
||||
/>
|
||||
</Pref>
|
||||
</SettingsSection>
|
||||
</>
|
||||
|
|
@ -214,7 +304,7 @@ export function AppSettings({ tab }: { tab: string }) {
|
|||
<Pref label="Artwork colour wash" description="Tints pages with colors from the title’s artwork.">
|
||||
<Switch checked={s.colorWash} onChange={(v) => set('colorWash', v)} />
|
||||
</Pref>
|
||||
<Pref label="Rotate featured titles" description="Cycles the featured title on Home and Discover every 12 seconds.">
|
||||
<Pref label="Rotate featured titles" description="Cycles the featured title on Home and Discover every 8 seconds.">
|
||||
<Switch checked={s.heroRotation} onChange={(v) => set('heroRotation', v)} />
|
||||
</Pref>
|
||||
<Pref label="Poster size" description="Card size in library grids.">
|
||||
|
|
|
|||
|
|
@ -57,14 +57,12 @@ function PrefsEditor({ tab }: { tab: string }) {
|
|||
const server = useServer();
|
||||
const cfg = GROUPS[tab];
|
||||
const q = useServerQuery(['serverPrefs'], (s) => admin.prefs(s), { staleTime: 0 });
|
||||
const [advanced, setAdvanced] = useState(false);
|
||||
const [edits, setEdits] = useState<Record<string, string | number | boolean>>({});
|
||||
const [busy, setBusy] = useState(false);
|
||||
const settings = useMemo(
|
||||
() => (q.data ?? []).filter((x) => cfg.groups.includes(x.group) && !x.hidden && (advanced || !x.advanced) && !(cfg.exclude && cfg.exclude.test(x.id))),
|
||||
[q.data, tab, advanced],
|
||||
() => (q.data ?? []).filter((x) => cfg.groups.includes(x.group) && !x.hidden && !(cfg.exclude && cfg.exclude.test(x.id))),
|
||||
[q.data, tab],
|
||||
);
|
||||
const advancedCount = (q.data ?? []).filter((x) => cfg.groups.includes(x.group) && !x.hidden && x.advanced).length;
|
||||
const dirty = Object.keys(edits).length > 0;
|
||||
|
||||
const save = async () => {
|
||||
|
|
@ -85,18 +83,7 @@ function PrefsEditor({ tab }: { tab: string }) {
|
|||
if (!q.data) return <PageLoader />;
|
||||
return (
|
||||
<>
|
||||
<SettingsSection
|
||||
title={cfg.title}
|
||||
description={cfg.description}
|
||||
actions={
|
||||
advancedCount > 0 && (
|
||||
<label className="inline-toggle">
|
||||
Show advanced
|
||||
<Switch checked={advanced} onChange={setAdvanced} />
|
||||
</label>
|
||||
)
|
||||
}
|
||||
>
|
||||
<SettingsSection title={cfg.title} description={cfg.description}>
|
||||
{settings.map((s) => (
|
||||
<Pref key={s.id} label={s.label} description={s.summary}>
|
||||
<SettingControl setting={s} value={s.id in edits ? edits[s.id] : s.value} onChange={(v) => setEdits((e) => (v === s.value ? (({ [s.id]: _, ...rest }) => rest)(e) : { ...e, [s.id]: v }))} />
|
||||
|
|
|
|||
|
|
@ -66,8 +66,7 @@
|
|||
gap: 20px;
|
||||
transition:
|
||||
background var(--t) var(--ease),
|
||||
box-shadow var(--t) var(--ease),
|
||||
backdrop-filter var(--t);
|
||||
box-shadow var(--t) var(--ease);
|
||||
}
|
||||
.topbar::before {
|
||||
content: '';
|
||||
|
|
@ -78,9 +77,9 @@
|
|||
z-index: -1;
|
||||
transition: opacity var(--t);
|
||||
}
|
||||
/* No backdrop blur: it re-renders the page behind the bar on every scroll frame. */
|
||||
.topbar.solid {
|
||||
background: rgba(11, 12, 14, 0.86);
|
||||
backdrop-filter: blur(22px) saturate(1.2);
|
||||
background: rgba(11, 12, 14, 0.95);
|
||||
box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05);
|
||||
}
|
||||
.topbar.solid::before {
|
||||
|
|
@ -163,19 +162,21 @@
|
|||
.nav-item::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
right: 50%;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 14px;
|
||||
height: 2px;
|
||||
border-radius: 2px;
|
||||
background: #e2e8e5;
|
||||
opacity: 0;
|
||||
transform: scaleX(0);
|
||||
transition:
|
||||
left var(--t) var(--ease-out),
|
||||
right var(--t) var(--ease-out);
|
||||
transform var(--t) var(--ease-out),
|
||||
opacity var(--t) var(--ease-out);
|
||||
}
|
||||
.nav-item.active::after {
|
||||
left: 0;
|
||||
right: 0;
|
||||
opacity: 1;
|
||||
transform: none;
|
||||
}
|
||||
.nav-count {
|
||||
min-width: 17px;
|
||||
|
|
@ -253,56 +254,31 @@
|
|||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 2000;
|
||||
background: radial-gradient(ellipse at 70% 20%, #16302c 0%, transparent 55%), radial-gradient(ellipse at 20% 90%, #2a2118 0%, transparent 50%), #08090b;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
transition:
|
||||
opacity 600ms var(--ease) 80ms,
|
||||
transform 640ms var(--ease);
|
||||
}
|
||||
.splash-mark {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 22px;
|
||||
.splash canvas {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
pointer-events: none;
|
||||
}
|
||||
.splash-mark path {
|
||||
transform-origin: 32px 32px;
|
||||
animation: facet-open 1000ms var(--ease-out) both;
|
||||
animation-delay: calc(var(--i) * 45ms);
|
||||
/* The app beneath settles from a slight zoom as the camera flies through the
|
||||
aperture (held for the first quarter of the exit, then decelerating). */
|
||||
html.splash-arrival .app-shell,
|
||||
html.splash-arrival .auth-screen {
|
||||
animation: splash-arrival 640ms linear both;
|
||||
}
|
||||
@keyframes facet-open {
|
||||
@keyframes splash-arrival {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: rotate(-44deg) scale(0.55);
|
||||
transform: scale(1.14);
|
||||
}
|
||||
70% {
|
||||
opacity: 1;
|
||||
transform: rotate(3deg) scale(1.03);
|
||||
25% {
|
||||
transform: scale(1.14);
|
||||
animation-timing-function: cubic-bezier(0.05, 0.7, 0.1, 1);
|
||||
}
|
||||
100% {
|
||||
transform: none;
|
||||
}
|
||||
}
|
||||
.splash-word {
|
||||
font-weight: 760;
|
||||
letter-spacing: 0.42em;
|
||||
font-size: 15px;
|
||||
color: #e9eeec;
|
||||
animation: rise-in 700ms 420ms var(--ease-out) both;
|
||||
margin-right: -0.42em;
|
||||
}
|
||||
.splash.leaving {
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
.splash.leaving .splash-mark {
|
||||
transform: scale(1.4);
|
||||
opacity: 0;
|
||||
transition:
|
||||
transform 600ms var(--ease),
|
||||
opacity 400ms var(--ease);
|
||||
}
|
||||
|
||||
/* —— Sign-in and server picker ———————————————————————————————— */
|
||||
.auth-screen {
|
||||
|
|
@ -526,15 +502,32 @@
|
|||
position: absolute;
|
||||
inset: 0;
|
||||
opacity: 0;
|
||||
transition: opacity 560ms var(--ease);
|
||||
transition: opacity 420ms var(--ease);
|
||||
}
|
||||
.backdrop-layer.ready {
|
||||
opacity: 1;
|
||||
}
|
||||
/* The colour wash lives outside the clipped backdrop so it can carry on down
|
||||
the page behind the rows, fading out as it goes. */
|
||||
.backdrop-tint {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: calc(100% + 70vh);
|
||||
z-index: -1;
|
||||
pointer-events: none;
|
||||
-webkit-mask-image: linear-gradient(180deg, #000 0%, rgba(0, 0, 0, 0.75) 45%, transparent 100%);
|
||||
mask-image: linear-gradient(180deg, #000 0%, rgba(0, 0, 0, 0.75) 45%, transparent 100%);
|
||||
}
|
||||
.backdrop-wash {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
opacity: 0.62;
|
||||
opacity: 0;
|
||||
transition: opacity 420ms var(--ease);
|
||||
}
|
||||
.backdrop-wash.ready {
|
||||
opacity: 0.5;
|
||||
}
|
||||
.backdrop-art {
|
||||
position: absolute;
|
||||
|
|
@ -565,20 +558,30 @@
|
|||
linear-gradient(90deg, rgba(9, 10, 12, 0.92) 0%, rgba(9, 10, 12, 0.6) 30%, rgba(9, 10, 12, 0.08) 62%, transparent 100%),
|
||||
linear-gradient(0deg, var(--bg) 0%, rgba(9, 10, 12, 0.6) 14%, transparent 40%);
|
||||
}
|
||||
/* With the wash, the art's own mask fades it into the tinted page; the scrim
|
||||
only keeps the copy legible instead of painting the page back to black. */
|
||||
.backdrop.washed .backdrop-scrim {
|
||||
background: linear-gradient(90deg, rgba(9, 10, 12, 0.55) 0%, rgba(9, 10, 12, 0.25) 34%, transparent 60%);
|
||||
}
|
||||
|
||||
/* —— Hero ———————————————————————————————————————————————————— */
|
||||
.hero {
|
||||
position: relative;
|
||||
height: clamp(430px, 64vh, 760px);
|
||||
/* A minimum, not a fixed height: long copy grows the hero instead of
|
||||
running up under the navigation. */
|
||||
min-height: clamp(430px, 64vh, 760px);
|
||||
padding-top: calc(var(--nav-h) + 36px);
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
isolation: isolate;
|
||||
}
|
||||
.hero.section {
|
||||
height: clamp(400px, 56vh, 660px);
|
||||
min-height: clamp(400px, 56vh, 660px);
|
||||
/* Clear of the overlaid section header (title and tabs). */
|
||||
padding-top: calc(var(--nav-h) + 96px);
|
||||
}
|
||||
.hero.empty {
|
||||
height: clamp(240px, 30vh, 320px);
|
||||
min-height: clamp(240px, 30vh, 320px);
|
||||
}
|
||||
.hero-content {
|
||||
position: relative;
|
||||
|
|
@ -659,7 +662,7 @@
|
|||
inset: 0;
|
||||
background: #eef3f1;
|
||||
transform-origin: left;
|
||||
animation: dot-fill 12s linear both;
|
||||
animation: dot-fill 8s linear both;
|
||||
}
|
||||
.hero-dots button.active:not(:has(.hero-dot-progress)) {
|
||||
background: #eef3f1;
|
||||
|
|
@ -966,9 +969,8 @@
|
|||
display: grid;
|
||||
place-items: center;
|
||||
color: #fff;
|
||||
background: rgba(30, 33, 36, 0.6);
|
||||
background: rgba(24, 27, 30, 0.78);
|
||||
box-shadow: inset 0 0 0 1.4px rgba(255, 255, 255, 0.45);
|
||||
backdrop-filter: blur(6px);
|
||||
margin-left: auto;
|
||||
}
|
||||
.card-more:hover {
|
||||
|
|
@ -1073,9 +1075,8 @@
|
|||
border-radius: 50%;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
background: rgba(20, 22, 24, 0.55);
|
||||
background: rgba(20, 22, 24, 0.72);
|
||||
box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.6);
|
||||
backdrop-filter: blur(6px);
|
||||
color: #fff;
|
||||
transition: transform var(--t-fast);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,6 +80,17 @@ html.video-active body {
|
|||
html.video-active .app-shell {
|
||||
visibility: hidden;
|
||||
}
|
||||
/* Miniplayer: the interface stays, with a rounded hole where the video is
|
||||
drawn beneath it (sized like .mini-player). */
|
||||
html.player-mini.video-active .app-shell {
|
||||
visibility: visible;
|
||||
-webkit-mask-image: linear-gradient(#000 0 0), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160 90'%3E%3Crect width='160' height='90' rx='3.6'/%3E%3C/svg%3E");
|
||||
-webkit-mask-size: 100% 100%, var(--mini-w) var(--mini-h);
|
||||
-webkit-mask-position: 0 0, right var(--mini-gap) bottom var(--mini-gap);
|
||||
-webkit-mask-repeat: no-repeat;
|
||||
-webkit-mask-composite: xor;
|
||||
mask-composite: exclude;
|
||||
}
|
||||
|
||||
button,
|
||||
input,
|
||||
|
|
@ -130,6 +141,12 @@ svg {
|
|||
border-radius: 4px;
|
||||
}
|
||||
|
||||
/* Text fields draw their own focus state (or their container does). */
|
||||
input:not([type='range'], [type='checkbox'], [type='radio']):focus-visible,
|
||||
textarea:focus-visible {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
::selection {
|
||||
background: rgba(169, 199, 192, 0.35);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,6 +68,18 @@
|
|||
padding: 0 28px;
|
||||
transition: opacity 400ms var(--ease);
|
||||
}
|
||||
/* The window's own buttons, top right, fading with the rest of the chrome. */
|
||||
.player-top .window-controls {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
height: 34px;
|
||||
margin: 0;
|
||||
}
|
||||
.player-top .window-controls button {
|
||||
height: 34px;
|
||||
color: #e4e8e9;
|
||||
}
|
||||
.player-back {
|
||||
width: 42px;
|
||||
height: 42px;
|
||||
|
|
@ -369,6 +381,9 @@
|
|||
width: min(620px, calc(100vw - 48px));
|
||||
}
|
||||
.player-panel-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 11px;
|
||||
font-weight: 750;
|
||||
letter-spacing: 0.12em;
|
||||
|
|
@ -376,6 +391,49 @@
|
|||
color: #9aa4a6;
|
||||
padding: 0 12px 10px;
|
||||
}
|
||||
.panel-back {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
margin: -4px 0 -4px -6px;
|
||||
border-radius: 6px;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
color: #c9d0d2;
|
||||
}
|
||||
.panel-back:hover {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
color: #fff;
|
||||
}
|
||||
.panel-stats {
|
||||
display: grid;
|
||||
gap: 5px;
|
||||
padding: 12px 12px 6px;
|
||||
margin-top: 6px;
|
||||
border-top: 1px solid rgba(255, 255, 255, 0.08);
|
||||
font-size: 11px;
|
||||
line-height: 1.45;
|
||||
}
|
||||
.panel-stats div {
|
||||
display: grid;
|
||||
grid-template-columns: 74px minmax(0, 1fr);
|
||||
gap: 10px;
|
||||
}
|
||||
.panel-stats span {
|
||||
color: #7f888b;
|
||||
}
|
||||
.panel-stats b {
|
||||
font-weight: 500;
|
||||
color: #c3cacc;
|
||||
}
|
||||
.panel-row:disabled {
|
||||
opacity: 0.45;
|
||||
}
|
||||
.panel-row b {
|
||||
max-width: 190px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.panel-columns {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
|
|
@ -601,3 +659,138 @@
|
|||
margin: 0 0 14px;
|
||||
line-height: 1.55;
|
||||
}
|
||||
|
||||
/* —— Miniplayer ————————————————————————————————————————————— */
|
||||
:root {
|
||||
--mini-w: clamp(300px, 26vw, 440px);
|
||||
--mini-h: calc(var(--mini-w) * 9 / 16);
|
||||
--mini-gap: 24px;
|
||||
}
|
||||
.mini-player {
|
||||
position: fixed;
|
||||
right: var(--mini-gap);
|
||||
bottom: var(--mini-gap);
|
||||
z-index: 600;
|
||||
width: var(--mini-w);
|
||||
height: var(--mini-h);
|
||||
border-radius: 10px;
|
||||
color: #fff;
|
||||
user-select: none;
|
||||
box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12);
|
||||
animation: mini-in 260ms var(--ease-out);
|
||||
}
|
||||
.mini-player.loading {
|
||||
background: #000;
|
||||
}
|
||||
/* Opacity only: the video beneath can't follow a transform. */
|
||||
@keyframes mini-in {
|
||||
from {
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
.mini-scrim {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
border-radius: inherit;
|
||||
background: linear-gradient(180deg, rgba(0, 0, 0, 0.55) 0%, rgba(0, 0, 0, 0.15) 40%, rgba(0, 0, 0, 0.2) 60%, rgba(0, 0, 0, 0.75) 100%);
|
||||
}
|
||||
.mini-scrim,
|
||||
.mini-top,
|
||||
.mini-center,
|
||||
.mini-caption {
|
||||
opacity: 0;
|
||||
transition: opacity var(--t);
|
||||
}
|
||||
.mini-player:hover .mini-scrim,
|
||||
.mini-player:hover .mini-top,
|
||||
.mini-player:hover .mini-center,
|
||||
.mini-player:hover .mini-caption,
|
||||
.mini-player.loading .mini-center,
|
||||
.mini-player:focus-within .mini-top,
|
||||
.mini-player:focus-within .mini-center {
|
||||
opacity: 1;
|
||||
}
|
||||
.mini-top {
|
||||
position: absolute;
|
||||
top: 6px;
|
||||
left: 6px;
|
||||
right: 6px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.mini-center {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 14px;
|
||||
pointer-events: none;
|
||||
}
|
||||
.mini-center > * {
|
||||
pointer-events: auto;
|
||||
}
|
||||
.mini-icon {
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
border-radius: 50%;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
color: #fff;
|
||||
transition: background var(--t-fast), transform var(--t-fast);
|
||||
}
|
||||
.mini-icon:hover {
|
||||
background: rgba(255, 255, 255, 0.16);
|
||||
}
|
||||
.mini-icon:active {
|
||||
transform: scale(0.92);
|
||||
}
|
||||
.mini-icon.big {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
background: rgba(0, 0, 0, 0.35);
|
||||
}
|
||||
.mini-error {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: #f2c4c3;
|
||||
}
|
||||
.mini-caption {
|
||||
position: absolute;
|
||||
left: 12px;
|
||||
right: 12px;
|
||||
bottom: 12px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1px;
|
||||
pointer-events: none;
|
||||
text-shadow: 0 1px 6px rgba(0, 0, 0, 0.7);
|
||||
}
|
||||
.mini-caption b,
|
||||
.mini-caption span {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.mini-caption b {
|
||||
font-size: 13px;
|
||||
}
|
||||
.mini-caption span {
|
||||
font-size: 11px;
|
||||
color: #d3d9db;
|
||||
}
|
||||
.mini-progress {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
height: 3px;
|
||||
border-radius: 0 0 10px 10px;
|
||||
overflow: hidden;
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
}
|
||||
.mini-progress i {
|
||||
display: block;
|
||||
height: 100%;
|
||||
background: #f1f4f3;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,28 +45,125 @@
|
|||
.section-tabs button::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
right: 50%;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
height: 2px;
|
||||
border-radius: 2px;
|
||||
background: #e2e8e5;
|
||||
opacity: 0;
|
||||
transform: scaleX(0);
|
||||
transition:
|
||||
left var(--t) var(--ease-out),
|
||||
right var(--t) var(--ease-out);
|
||||
transform var(--t) var(--ease-out),
|
||||
opacity var(--t) var(--ease-out);
|
||||
}
|
||||
.section-tabs button.active::after {
|
||||
left: 0;
|
||||
right: 0;
|
||||
opacity: 1;
|
||||
transform: none;
|
||||
}
|
||||
.section-picker {
|
||||
margin-left: auto;
|
||||
}
|
||||
.tab-library .section-header,
|
||||
.tab-collections .section-header {
|
||||
.tab-categories .section-header {
|
||||
padding-bottom: 18px;
|
||||
}
|
||||
|
||||
/* —— Categories ———————————————————————————————————————————— */
|
||||
.category-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
|
||||
gap: 14px;
|
||||
}
|
||||
.category-tile {
|
||||
position: relative;
|
||||
aspect-ratio: 16 / 9;
|
||||
border-radius: var(--r);
|
||||
overflow: hidden;
|
||||
background: #171717;
|
||||
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
|
||||
display: grid;
|
||||
place-items: center;
|
||||
isolation: isolate;
|
||||
}
|
||||
.category-tile .artwork {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: -2;
|
||||
filter: saturate(0.65);
|
||||
transition: transform 400ms var(--ease-out);
|
||||
}
|
||||
.category-scrim {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
z-index: -1;
|
||||
background: rgba(0, 0, 0, 0.62);
|
||||
transition: background var(--t);
|
||||
}
|
||||
.category-title {
|
||||
padding: 0 16px;
|
||||
font-size: 21px;
|
||||
line-height: 1.2;
|
||||
font-weight: 650;
|
||||
letter-spacing: -0.02em;
|
||||
text-align: center;
|
||||
text-shadow: 0 1px 5px #000;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
}
|
||||
.category-tile::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
border-radius: inherit;
|
||||
box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.9);
|
||||
opacity: 0;
|
||||
transition: opacity var(--t-fast);
|
||||
}
|
||||
.category-tile:hover .category-scrim,
|
||||
.category-tile:focus-visible .category-scrim {
|
||||
background: rgba(0, 0, 0, 0.46);
|
||||
}
|
||||
.category-tile:hover .artwork {
|
||||
transform: scale(1.04);
|
||||
}
|
||||
.category-tile:hover::after,
|
||||
.category-tile:focus-visible::after {
|
||||
opacity: 1;
|
||||
}
|
||||
.category-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
padding: 0 var(--gutter) 14px;
|
||||
}
|
||||
.category-head h2 {
|
||||
margin: 0;
|
||||
font-size: 22px;
|
||||
letter-spacing: -0.03em;
|
||||
}
|
||||
.category-back {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
height: 30px;
|
||||
padding: 0 12px 0 8px;
|
||||
border-radius: 15px;
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
color: var(--muted);
|
||||
background: rgba(255, 255, 255, 0.06);
|
||||
transition: color var(--t-fast), background var(--t-fast);
|
||||
}
|
||||
.category-back:hover {
|
||||
color: #fff;
|
||||
background: rgba(255, 255, 255, 0.11);
|
||||
}
|
||||
|
||||
/* —— Library ————————————————————————————————————————————————— */
|
||||
.library {
|
||||
padding: 0 var(--gutter);
|
||||
|
|
@ -82,8 +179,7 @@
|
|||
position: sticky;
|
||||
top: var(--nav-h);
|
||||
z-index: 20;
|
||||
background: linear-gradient(180deg, rgba(9, 10, 12, 0.96) 0%, rgba(9, 10, 12, 0.92) 100%);
|
||||
backdrop-filter: blur(18px);
|
||||
background: rgba(9, 10, 12, 0.97);
|
||||
padding-top: 12px;
|
||||
margin-top: -12px;
|
||||
}
|
||||
|
|
@ -213,23 +309,57 @@ button.chip:hover {
|
|||
align-self: flex-start;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-end;
|
||||
max-height: calc(100vh - var(--nav-h) - 110px);
|
||||
overflow-y: auto;
|
||||
scrollbar-width: none;
|
||||
margin-right: -10px;
|
||||
/* Room on the left for the magnified letter. */
|
||||
padding: 8px 4px 8px 26px;
|
||||
margin: 0 -14px 0 -18px;
|
||||
}
|
||||
.alpha-rail::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
width: 30px;
|
||||
border-radius: 15px;
|
||||
background: rgba(255, 255, 255, 0.055);
|
||||
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07);
|
||||
pointer-events: none;
|
||||
}
|
||||
.alpha-rail button {
|
||||
position: relative;
|
||||
width: 22px;
|
||||
height: 19px;
|
||||
font-size: 10.5px;
|
||||
font-weight: 650;
|
||||
color: #8a9196;
|
||||
border-radius: 4px;
|
||||
height: 20px;
|
||||
font-size: 11.5px;
|
||||
font-weight: 700;
|
||||
color: #b4bbbf;
|
||||
flex: none;
|
||||
transform-origin: 70% 50%;
|
||||
transition:
|
||||
transform 120ms var(--ease-out),
|
||||
color 120ms;
|
||||
}
|
||||
.alpha-rail button.current {
|
||||
color: var(--accent-strong);
|
||||
}
|
||||
/* The letter under the pointer grows, and its neighbours a little, like a dock. */
|
||||
.alpha-rail button:hover {
|
||||
color: #fff;
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
z-index: 2;
|
||||
transform: translateX(-10px) scale(1.9);
|
||||
}
|
||||
.alpha-rail button:has(+ button:hover),
|
||||
.alpha-rail button:hover + button {
|
||||
color: #e2e7e9;
|
||||
z-index: 1;
|
||||
transform: translateX(-5px) scale(1.35);
|
||||
}
|
||||
.alpha-rail button:has(+ button + button:hover),
|
||||
.alpha-rail button:hover + button + button {
|
||||
transform: translateX(-2px) scale(1.12);
|
||||
}
|
||||
|
||||
/* —— Detail pages ——————————————————————————————————————————— */
|
||||
|
|
@ -241,7 +371,10 @@ button.chip:hover {
|
|||
height: min(84vh, 900px);
|
||||
bottom: auto;
|
||||
}
|
||||
.detail-backdrop .backdrop-scrim {
|
||||
.backdrop-tint.detail-backdrop {
|
||||
height: calc(min(84vh, 900px) + 60vh);
|
||||
}
|
||||
.detail-backdrop:not(.washed) .backdrop-scrim {
|
||||
background:
|
||||
linear-gradient(90deg, rgba(9, 10, 12, 0.94) 0%, rgba(9, 10, 12, 0.7) 32%, rgba(9, 10, 12, 0.1) 66%, transparent 100%),
|
||||
linear-gradient(0deg, var(--bg) 0%, rgba(9, 10, 12, 0.7) 22%, transparent 55%);
|
||||
|
|
@ -311,9 +444,19 @@ button.chip:hover {
|
|||
overflow: hidden;
|
||||
text-shadow: 0 1px 12px rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
.synopsis-more {
|
||||
margin-top: 2px;
|
||||
padding-left: 0;
|
||||
.synopsis.expandable {
|
||||
cursor: pointer;
|
||||
border-radius: 6px;
|
||||
transition: color var(--t-fast);
|
||||
}
|
||||
.synopsis.expandable:hover {
|
||||
color: #fff;
|
||||
}
|
||||
.synopsis.open {
|
||||
display: block;
|
||||
white-space: pre-wrap;
|
||||
-webkit-line-clamp: unset;
|
||||
animation: fade-in 220ms var(--ease-out);
|
||||
}
|
||||
.synopsis-full {
|
||||
font-size: 14px;
|
||||
|
|
@ -381,8 +524,7 @@ button.chip:hover {
|
|||
top: calc(var(--nav-h) + 16px);
|
||||
padding: 20px;
|
||||
border-radius: 12px;
|
||||
background: rgba(23, 25, 28, 0.82);
|
||||
backdrop-filter: blur(16px);
|
||||
background: rgba(21, 23, 26, 0.93);
|
||||
box-shadow: inset 0 0 0 1px var(--line);
|
||||
}
|
||||
.about-head {
|
||||
|
|
@ -436,19 +578,6 @@ button.chip:hover {
|
|||
color: #fff;
|
||||
text-decoration-color: currentColor;
|
||||
}
|
||||
.star-rating {
|
||||
display: inline-flex;
|
||||
color: #e6c46e;
|
||||
}
|
||||
.star-rating button {
|
||||
padding: 2px;
|
||||
color: inherit;
|
||||
opacity: 0.9;
|
||||
}
|
||||
.star-rating button:hover {
|
||||
transform: scale(1.15);
|
||||
}
|
||||
|
||||
/* Episodes */
|
||||
.episodes {
|
||||
margin-bottom: 36px;
|
||||
|
|
@ -667,6 +796,26 @@ button.chip:hover {
|
|||
border-bottom: 1px solid var(--line);
|
||||
margin-bottom: 26px;
|
||||
}
|
||||
/* The page fills the window so an empty state can sit in the middle of it. */
|
||||
.downloads-page {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: calc(100vh - 80px);
|
||||
}
|
||||
.app-shell.offline .downloads-page {
|
||||
min-height: calc(100vh - 44px);
|
||||
}
|
||||
.downloads-empty {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
/* Sit at the window's centre rather than below the header's. */
|
||||
margin-top: -120px;
|
||||
}
|
||||
.download-intro-actions {
|
||||
margin-top: 14px;
|
||||
}
|
||||
.storage-card {
|
||||
padding: 18px 20px;
|
||||
border-radius: 12px;
|
||||
|
|
@ -938,6 +1087,65 @@ button.chip:hover {
|
|||
color: #868f94;
|
||||
word-break: break-word;
|
||||
}
|
||||
.subtitle-preview {
|
||||
position: relative;
|
||||
container-type: size;
|
||||
aspect-ratio: 16 / 9;
|
||||
max-height: 340px;
|
||||
margin: 4px 0 14px;
|
||||
border-radius: var(--r-lg);
|
||||
overflow: hidden;
|
||||
background: linear-gradient(160deg, #36404a 0%, #1b2024 55%, #0e1012 100%);
|
||||
box-shadow: inset 0 0 0 1px var(--line);
|
||||
}
|
||||
.subtitle-preview img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
.subtitle-preview-line {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
text-align: center;
|
||||
font-family: Arial, 'Segoe UI', sans-serif;
|
||||
line-height: 1.22;
|
||||
pointer-events: none;
|
||||
}
|
||||
.subtitle-preview-line span {
|
||||
paint-order: stroke fill;
|
||||
-webkit-box-decoration-break: clone;
|
||||
box-decoration-break: clone;
|
||||
padding: 0 0.2em;
|
||||
}
|
||||
.subtitle-preview-line span.translucent {
|
||||
background: rgba(0, 0, 0, 0.63);
|
||||
}
|
||||
.subtitle-preview-line span.solid {
|
||||
background: #000;
|
||||
}
|
||||
.swatches {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
.swatches button {
|
||||
width: 26px;
|
||||
height: 26px;
|
||||
border-radius: 50%;
|
||||
box-shadow:
|
||||
inset 0 0 0 1px rgba(0, 0, 0, 0.25),
|
||||
0 0 0 2px transparent;
|
||||
transition: box-shadow var(--t-fast), transform var(--t-fast);
|
||||
}
|
||||
.swatches button:hover {
|
||||
transform: scale(1.08);
|
||||
}
|
||||
.swatches button.selected {
|
||||
box-shadow:
|
||||
inset 0 0 0 1px rgba(0, 0, 0, 0.25),
|
||||
0 0 0 2px var(--bg),
|
||||
0 0 0 4px #e8eeec;
|
||||
}
|
||||
.pref-control {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ interface Layer {
|
|||
/**
|
||||
* Artwork-led page background. The image sits top-right and fades into the
|
||||
* page toward its left and bottom edges; the UltraBlur colour wash tints the
|
||||
* page beneath. Changes crossfade; the outgoing layer stays until the new
|
||||
* image has decoded.
|
||||
* page beneath it and carries on down behind the rows. Changes crossfade; the
|
||||
* outgoing layer stays until the new image has decoded.
|
||||
*/
|
||||
export function Backdrop({ item, className = '', width = 1600, height = 900, wash: forceWash }: { item: Item | null | undefined; className?: string; width?: number; height?: number; wash?: Item['ultraBlur'] }) {
|
||||
const server = useServer();
|
||||
|
|
@ -44,19 +44,25 @@ export function Backdrop({ item, className = '', width = 1600, height = 900, was
|
|||
if (idx < 0) return prev;
|
||||
const next = prev.map((l) => (l.key === key ? { ...l, ready: true } : l));
|
||||
// Drop older layers once the newest is visible (after its fade).
|
||||
setTimeout(() => setLayers((p) => (p.length > 1 && p[p.length - 1].key === key ? p.slice(-1) : p)), 700);
|
||||
setTimeout(() => setLayers((p) => (p.length > 1 && p[p.length - 1].key === key ? p.slice(-1) : p)), 500);
|
||||
return next;
|
||||
});
|
||||
|
||||
return (
|
||||
<div className={`backdrop ${className}`} aria-hidden="true">
|
||||
<>
|
||||
{colorWash && (
|
||||
<div className={`backdrop-tint ${className}`} aria-hidden="true">
|
||||
{layers.map((l) => l.wash && <div key={l.key} className={`backdrop-wash${l.ready ? ' ready' : ''}`} style={{ background: l.wash }} />)}
|
||||
</div>
|
||||
)}
|
||||
<div className={`backdrop ${className}${colorWash ? ' washed' : ''}`} aria-hidden="true">
|
||||
{layers.map((l) => (
|
||||
<div key={l.key} className={`backdrop-layer${l.ready ? ' ready' : ''}`}>
|
||||
{l.wash && <div className="backdrop-wash" style={{ background: l.wash }} />}
|
||||
{l.src && <img className="backdrop-art" src={l.src} alt="" draggable={false} decoding="async" onLoad={() => onReady(l.key)} onError={() => onReady(l.key)} />}
|
||||
</div>
|
||||
))}
|
||||
<div className="backdrop-scrim" />
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,11 @@ import { Backdrop } from './Backdrop';
|
|||
import { Facts, TitleArt } from './media';
|
||||
import { Button, IconButton } from './primitives';
|
||||
import { openMenu } from './overlays';
|
||||
import { episodeLabel } from '../app/format';
|
||||
import { art, episodeLabel } from '../app/format';
|
||||
import { useServer } from '../app/session';
|
||||
|
||||
/** How long each feature shows; the dot progress animation matches it. */
|
||||
const ROTATE_MS = 8000;
|
||||
|
||||
export interface Feature {
|
||||
item: Item;
|
||||
|
|
@ -15,7 +19,7 @@ export interface Feature {
|
|||
|
||||
/**
|
||||
* The cinematic feature at the top of Home and the Discover pages. Features
|
||||
* rotate every 12 seconds while the pointer is away, crossfading artwork
|
||||
* rotate every 8 seconds while the pointer is away, crossfading artwork
|
||||
* while the copy lifts out and rises into place.
|
||||
*/
|
||||
export function Hero({ features, variant = 'home' }: { features: Feature[]; variant?: 'home' | 'section' }) {
|
||||
|
|
@ -27,10 +31,22 @@ export function Hero({ features, variant = 'home' }: { features: Feature[]; vari
|
|||
const root = useRef<HTMLElement>(null);
|
||||
const count = features.length;
|
||||
const feature = features[Math.min(index, count - 1)];
|
||||
const server = useServer();
|
||||
|
||||
// Decode the next feature's artwork ahead of time so the swap is immediate.
|
||||
const upcoming = count > 1 ? features[(index + 1) % count]?.item : undefined;
|
||||
useEffect(() => {
|
||||
const path = upcoming ? art.backdrop(upcoming) : '';
|
||||
if (!path) return;
|
||||
const img = new Image();
|
||||
img.decoding = 'async';
|
||||
img.src = server.image(path, 1600, 900);
|
||||
img.decode?.().catch(() => {});
|
||||
}, [upcoming?.id]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!rotate || reduced || count < 2 || hover) return;
|
||||
const t = setTimeout(() => go(index + 1), 12000);
|
||||
const t = setTimeout(() => go(index + 1), ROTATE_MS);
|
||||
return () => clearTimeout(t);
|
||||
}, [index, rotate, reduced, count, hover]);
|
||||
|
||||
|
|
|
|||
|
|
@ -11,12 +11,13 @@ import { Ratings } from './media';
|
|||
* A quiet preview shown after the pointer rests on a poster: artwork, facts
|
||||
* and synopsis, without opening the title. It never captures the pointer.
|
||||
*/
|
||||
const usePreview = create<{ item: Item | null; rect: DOMRect | null; anchor: HTMLElement | null; show(item: Item, anchor: HTMLElement): void; hide(): void }>((set) => ({
|
||||
const usePreview = create<{ item: Item | null; rect: DOMRect | null; anchor: HTMLElement | null; show(item: Item, anchor: HTMLElement): void; hide(): void }>((set, get) => ({
|
||||
item: null,
|
||||
rect: null,
|
||||
anchor: null,
|
||||
show: (item, anchor) => set({ item, anchor, rect: anchor.getBoundingClientRect() }),
|
||||
hide: () => set({ item: null, rect: null, anchor: null }),
|
||||
// Called on every wheel event; only notify when something was showing.
|
||||
hide: () => get().item && set({ item: null, rect: null, anchor: null }),
|
||||
}));
|
||||
|
||||
let timer: ReturnType<typeof setTimeout> | null = null;
|
||||
|
|
|
|||
|
|
@ -242,7 +242,7 @@ export const LandscapeCard = memo(function LandscapeCard({ item, continueWatchin
|
|||
? remaining(item)
|
||||
: [item.year, duration(item.duration)].filter(Boolean).join(' · ');
|
||||
return (
|
||||
<article className="card landscape" role="button" tabIndex={0} aria-label={title} {...handlers}>
|
||||
<article className="card landscape" role="button" tabIndex={0} aria-label={title} {...handlers} {...previewHandlers(item)}>
|
||||
<div className="card-cover">
|
||||
<Artwork src={server.image(path, 400, 225)} alt="" fallback={<span className="cover-fallback">{title}</span>} />
|
||||
{!isEp && item.logo && continueWatching && (
|
||||
|
|
@ -293,7 +293,10 @@ export function Shelf({ title, subtitle, onViewAll, children, className = '', ki
|
|||
const update = () => {
|
||||
const el = row.current;
|
||||
if (!el) return;
|
||||
setEdges({ start: el.scrollLeft < 8, end: el.scrollLeft + el.clientWidth >= el.scrollWidth - 8 });
|
||||
const start = el.scrollLeft < 8;
|
||||
const end = el.scrollLeft + el.clientWidth >= el.scrollWidth - 8;
|
||||
// Runs on every scroll event; re-render only when an edge changes.
|
||||
setEdges((prev) => (prev.start === start && prev.end === end ? prev : { start, end }));
|
||||
};
|
||||
useEffect(() => {
|
||||
update();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue