Address the first beta's bugs and requested changes

Startup now uses the Android iris animation, and playback can continue
in a corner miniplayer while browsing (the video is drawn into a corner
rectangle beneath a matching hole in the page). The player keeps the
window controls, hides its chrome when the pointer leaves, and gains
audio/subtitle tracks, audio sync, source bitrate and playback details
in its options. Subtitles can be styled in Settings with a live preview.
Categories replace Collections, the A–Z rail magnifies, descriptions
expand in place, downloads can be removed in bulk, and search keeps its
results while typing.

Fixes scroll jank from per-card and scrolling backdrop blurs, the hidden
colour wash, the cubic volume curve, loud theme music, the search focus
ring, a stray nav indicator, Continue Watching previews and the TV Shows
header overlap. Removes the star rating, the duplicate Settings menu
entry and the server settings' Show advanced switch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Elijah 2026-10-30 18:06:54 -07:00
parent be865fa992
commit 43c168da95
35 changed files with 1771 additions and 327 deletions

View file

@ -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);
});