Create Kaleido Desktop, a cinematic Plex client for Windows
Tauri 2 shell with a React/TypeScript interface and libmpv playback composed beneath the web view (DirectComposition on Windows). Shared code with per-OS platform modules and configs so macOS and Linux can follow. - Plex sign-in (browser, plex.tv/link or manual), server selection, Plex Home - Home, Movies and TV Shows (Discover, Library, Collections), search, people - Title pages with logos, ratings, cast, extras, seasons and episodes - Direct play with Plex conversion fallback, tracks, markers, autoplay - Metadata editing, artwork, fix match, refresh, analyze and deletion - Resumable offline downloads - App settings and Plex server administration with a live dashboard - Signed updater feed and Forgejo CI Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
00d72e70f4
121 changed files with 25315 additions and 0 deletions
52
src/player/theme.ts
Normal file
52
src/player/theme.ts
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
/** Optional title theme music on detail pages, faded in and out. */
|
||||
import { useSession } from '../app/session';
|
||||
import { useSettings } from '../app/settings';
|
||||
|
||||
let audio: HTMLAudioElement | null = null;
|
||||
let current = '';
|
||||
let fade: ReturnType<typeof setInterval> | null = null;
|
||||
|
||||
function fadeTo(target: number, done?: () => void) {
|
||||
if (!audio) return;
|
||||
if (fade) clearInterval(fade);
|
||||
const a = audio;
|
||||
fade = setInterval(() => {
|
||||
const step = 0.02;
|
||||
if (Math.abs(a.volume - target) <= step) {
|
||||
a.volume = target;
|
||||
clearInterval(fade!);
|
||||
fade = null;
|
||||
done?.();
|
||||
} else a.volume += a.volume < target ? step : -step;
|
||||
}, 40);
|
||||
}
|
||||
|
||||
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 (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), () => {});
|
||||
}
|
||||
|
||||
export function stopThemeMusic(immediate = false) {
|
||||
current = '';
|
||||
if (!audio) return;
|
||||
const a = audio;
|
||||
audio = null;
|
||||
if (immediate) {
|
||||
a.pause();
|
||||
return;
|
||||
}
|
||||
const prev = audio;
|
||||
audio = a;
|
||||
fadeTo(0, () => {
|
||||
a.pause();
|
||||
if (audio === a) audio = prev;
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue