Add player upscaling and fix miniplayer and scrub bar issues
Upscaling is chosen in the player (Playback options, or U): Performance uses spline36 scaling, debanding and AMD CAS sharpening; Balanced adds FSRCNNX neural luma upscaling and KrigBilateral chroma reconstruction. The shaders ship in src-tauri/shaders and their WHEN conditions decide whether they run for the current video and window size; HDR titles skip CAS, which assumes SDR gamma. The title above the scrub bar now opens its show, movie or episode page with playback moving to the miniplayer. Leaving the miniplayer any way (including starting another title, which left the app invisible) puts the video back over the whole window. The scrub bar separates played and buffered sections more clearly, and its preview keeps its size at the end of the bar. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
6be6633f64
commit
5dc18ff9e5
13 changed files with 1345 additions and 15 deletions
|
|
@ -1,14 +1,16 @@
|
|||
import { useCallback, useEffect, useRef, useState, type ReactNode } from 'react';
|
||||
import { usePlayer } from './store';
|
||||
import { useSession } from '../app/session';
|
||||
import { useSettings, QUALITY_LABEL, type Quality, type SubtitleBox } from '../app/settings';
|
||||
import { useSettings, QUALITY_LABEL, UPSCALING, type Quality, type SubtitleBox, type Upscaling } from '../app/settings';
|
||||
import { bitrate, channelLabel, clock, episodeLabel, resolutionLabel } from '../app/format';
|
||||
import { Icon } from '../ui/Icon';
|
||||
import { Facts, TitleArt } from '../ui/media';
|
||||
import { Button, Spinner } from '../ui/primitives';
|
||||
import { win, isNative } from '../platform/native';
|
||||
import { WindowControls } from '../app/TopBar';
|
||||
import { navigate } from '../app/router';
|
||||
import { mpv } from './engine';
|
||||
import { toast } from '../ui/overlays';
|
||||
import type { Item } from '../plex/types';
|
||||
|
||||
const HIDE_AFTER = 3000;
|
||||
|
|
@ -237,7 +239,23 @@ const SUB_BOXES: { value: SubtitleBox; label: string }[] = [
|
|||
{ value: 'solid', label: 'Solid' },
|
||||
];
|
||||
|
||||
type SettingsView = 'main' | 'audio' | 'subtitles' | 'quality' | 'speed' | 'version' | 'chapters' | 'subSize' | 'subBox';
|
||||
type SettingsView = 'main' | 'audio' | 'subtitles' | 'quality' | 'upscaling' | 'speed' | 'version' | 'chapters' | 'subSize' | 'subBox';
|
||||
|
||||
const UPSCALING_ORDER: Upscaling[] = ['off', 'performance', 'balanced'];
|
||||
|
||||
/** What the current tier is doing for this video at this size, for the details list. */
|
||||
function upscalingDetail(mode: Upscaling, video: { width: number; height: number } | null, hdr: boolean) {
|
||||
if (mode === 'off') return 'Off';
|
||||
const dpr = window.devicePixelRatio || 1;
|
||||
const factor = video && video.width ? Math.min((window.innerWidth * dpr) / video.width, (window.innerHeight * dpr) / video.height) : 1;
|
||||
const parts = [UPSCALING[mode].label];
|
||||
if (factor > 1.01) parts.push(`${factor.toFixed(1)}× ${mode === 'balanced' && factor > 1.3 ? 'neural upscale' : 'upscale'}`);
|
||||
else parts.push('native size');
|
||||
if (mode === 'balanced') parts.push('colour reconstruction');
|
||||
parts.push('debanding');
|
||||
if (!hdr) parts.push('sharpening');
|
||||
return parts.join(' · ');
|
||||
}
|
||||
|
||||
function SettingsPanel({ onClose }: { onClose: () => void }) {
|
||||
const st = usePlayer();
|
||||
|
|
@ -286,6 +304,14 @@ function SettingsPanel({ onClose }: { onClose: () => void }) {
|
|||
))}
|
||||
</Panel>
|
||||
);
|
||||
if (view === 'upscaling')
|
||||
return (
|
||||
<Panel title="Upscaling" onClose={onClose} onBack={back}>
|
||||
{UPSCALING_ORDER.map((m) => (
|
||||
<Option key={m} selected={prefs.upscaling === m} label={UPSCALING[m].label} detail={UPSCALING[m].detail} onClick={() => (prefs.set('upscaling', m), back())} />
|
||||
))}
|
||||
</Panel>
|
||||
);
|
||||
if (view === 'speed')
|
||||
return (
|
||||
<Panel title="Playback speed" onClose={onClose} onBack={back}>
|
||||
|
|
@ -353,6 +379,7 @@ function SettingsPanel({ onClose }: { onClose: () => void }) {
|
|||
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(' · ')]);
|
||||
stats.push(['Upscaling', upscalingDetail(prefs.upscaling, v, !!source?.dynamicRange)]);
|
||||
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()]);
|
||||
|
||||
|
|
@ -361,6 +388,7 @@ function SettingsPanel({ onClose }: { onClose: () => void }) {
|
|||
{row('Audio', audio ? audio.label : st.audioTracks.length ? 'Choose' : 'None', () => setView('audio'), !st.audioTracks.length)}
|
||||
{row('Subtitles', sub ? sub.label : 'Off', () => setView('subtitles'))}
|
||||
{!local && row('Quality', qualityLabel(st.quality), () => setView('quality'))}
|
||||
{row('Upscaling', UPSCALING[prefs.upscaling].label, () => setView('upscaling'))}
|
||||
{row('Speed', st.speed === 1 ? 'Normal' : `${st.speed}×`, () => setView('speed'))}
|
||||
{media.length > 1 && !local && row('Version', `${st.mediaIndex + 1} of ${media.length}`, () => setView('version'))}
|
||||
{st.chapters.length > 1 && row('Chapters', `${st.chapters.length}`, () => setView('chapters'))}
|
||||
|
|
@ -465,14 +493,29 @@ function PostPlay() {
|
|||
);
|
||||
}
|
||||
|
||||
/** The title opens its show or movie page, with playback moving to the miniplayer. */
|
||||
function openFromPlayer(id: string | undefined) {
|
||||
if (!id) return;
|
||||
usePlayer.getState().minimize();
|
||||
navigate({ name: 'item', id });
|
||||
}
|
||||
|
||||
function TitleBlock({ item }: { item: Item }) {
|
||||
const linkable = item.type === 'movie' || item.type === 'episode';
|
||||
const art = <TitleArt item={item.type === 'episode' ? { ...item, logo: item.raw?.Image?.find?.((i: any) => i.type === 'clearLogo')?.url ?? '' } : item} maxWidth={240} maxHeight={60} as="h2" />;
|
||||
return (
|
||||
<div className="player-title">
|
||||
<TitleArt item={item.type === 'episode' ? { ...item, logo: item.raw?.Image?.find?.((i: any) => i.type === 'clearLogo')?.url ?? '' } : item} maxWidth={240} maxHeight={60} as="h2" />
|
||||
{linkable ? (
|
||||
<button className="player-title-link" title={`Go to ${item.type === 'episode' ? item.grandparentTitle : item.title}`} onClick={() => openFromPlayer(item.type === 'episode' ? item.grandparentId : item.id)}>
|
||||
{art}
|
||||
</button>
|
||||
) : (
|
||||
art
|
||||
)}
|
||||
{item.type === 'episode' && (
|
||||
<div className="player-episode">
|
||||
<button className="player-episode" title="Go to this episode" onClick={() => openFromPlayer(item.id)}>
|
||||
{episodeLabel(item)} · {item.title}
|
||||
</div>
|
||||
</button>
|
||||
)}
|
||||
{item.type !== 'clip' && <Facts item={item} withFormats={false} episode={false} />}
|
||||
</div>
|
||||
|
|
@ -627,6 +670,14 @@ export function PlayerOverlay() {
|
|||
if (e.shiftKey && p.nextUp) p.playNext();
|
||||
else handled = false;
|
||||
break;
|
||||
case 'u':
|
||||
case 'U': {
|
||||
const prefs = useSettings.getState();
|
||||
const next = UPSCALING_ORDER[(UPSCALING_ORDER.indexOf(prefs.upscaling) + 1) % UPSCALING_ORDER.length];
|
||||
prefs.set('upscaling', next);
|
||||
toast(`Upscaling: ${UPSCALING[next].label}`);
|
||||
break;
|
||||
}
|
||||
case 'c':
|
||||
case 'C': {
|
||||
const subs = p.subTracks;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue