diff --git a/CHANGELOG.md b/CHANGELOG.md index 89d5b1c..4dc20e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,49 +1,5 @@ # Changelog -## 1.0.1 - -A quicker start, a Stop button, and recovery when the server drops out mid-video. - -- Kaleido starts faster: the opening animation is shorter, so you reach your library in about a second. -- The player has a Stop button, next to the forward controls, which closes the player completely instead of moving it to the miniplayer. -- If your Plex server goes down while you're watching, the player waits for it once the buffered video runs out, then carries on from the same spot when the server is back. Before, it treated the video as finished and Play started it again from the beginning. Pressing Play while it waits tries to reconnect straight away. - -## 1.0.0 - -Kaleido is out of beta. This release reworks the show and season pages and smooths out watching a series. - -- Season pages show their episodes as a grid of cards, each with its still, description and watched state, in place of the long episode list. -- Click the season's name under the show's logo to switch to another season. -- Show pages list seasons once, as a row of posters. A show with only one season shows its episodes directly. -- Episodes you've watched stay marked as watched when you rewatch them and stop partway through. The leftover position only shows on the episode you're up to. -- When the next episode plays, whether automatically or with Next, it starts from the beginning instead of near the end of an earlier viewing. -- Click a show's name under a Continue Watching card to go to the show. -- Continue Watching starts at the first title when something new is added, instead of scrolling it off the left edge. -- Season posters outside their show's page, such as New Seasons, are labelled with the show's name. -- Season pages show the year the season aired, and their Play button agrees with the show page about which episode is next. -- Movie and episode pages show the runtime in their details, with the time left on the Resume button. - -## 0.1.0-beta.19 - -Up Next fixes. - -- Up Next now opens every time the credits start: going back to the credits and seeking into the episode brings it back when they come round again, and it always opens when an episode reaches the end. -- The back arrow and a full-screen button are back at the top of Up Next, so you can return to browsing (playback continues in the miniplayer) or leave full screen. -- Click the show's logo to go to its page, with playback moving to the miniplayer. -- The Play next episode countdown fills smoothly. -- The episode rows are sized to fill the screen instead of leaving a gap at the bottom. -- The backdrop now shows the next episode, and its description is easier to read over bright artwork. - -## 0.1.0-beta.18 - -A rebuilt Up Next screen that looks and works like the rest of Kaleido. - -- Up Next now uses the same artwork backdrop, colour wash, buttons and cards as the title pages. The credits keep playing in the top-left corner beside the next episode, and the Play next episode button fills as the countdown runs. -- The Season and Related shows rows scroll with the side arrows, like every other row, instead of scrollbars. The season row starts at the episode you just watched. -- Click the video or press Esc to go back to the credits; at the end of an episode this no longer restarts it from the beginning. -- Up Next fits smaller windows, and the window buttons stay visible on Mac while it's open. -- Playback settings are a simple list again: Skip intros, Skip movie credits, Automatic skip delay and Autoplay next episode. - ## 0.1.0-beta.17 - Fix the Up Next countdown stalling when the native video has keyboard focus instead of the webview. Count elapsed time accurately through delayed timer callbacks, and keep the countdown independent of the video's pause state, as on Android TV. diff --git a/docs/development.md b/docs/development.md index dbf8d76..316d041 100644 --- a/docs/development.md +++ b/docs/development.md @@ -47,11 +47,15 @@ Playback tests change real Plex progress; resume an in-progress title near its s position, or restore it afterwards. Selecting audio or subtitle tracks is saved to Plex for that file. -Up Next (`player/PostPlay.tsx`) opens at an episode's first credits marker, or at the end -without markers. The video is drawn into its top-left frame (`player_rect`) behind a -matching hole in the page; check that the two line up after resizing, changing display -scale and returning to the video. In the browser, open it from the console by setting -`postPlay: true` (with `item`, `nextUp`, `episodeContextReady`) on `__kaleido.usePlayer`. +Up Next opens at the first Plex credits marker for an episode, including after a seek; +without markers it opens at EOF. Movie-credit skipping is independent. There is one +autoplay timer, measured by elapsed time without requiring webview keyboard focus. +Mouse movement, clicks, keypresses (including Tab), and scrolling cancel it. Esc or +clicking the video returns to playback; F/F11 toggles full screen. Video hover/focus +shows only a white outline. The play button's fill is the visible countdown. +The video rectangle must follow window resizes and DPI changes and return to the full +window on dismissal, episode changes, errors, and closing. Verify those native video +transitions on a GPU-equipped machine; browser layout checks cannot prove rendering. ## Diagnostics diff --git a/package-lock.json b/package-lock.json index a12cc89..5751ec6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "kaleido-desktop", - "version": "1.0.1", + "version": "0.1.0-beta.17", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "kaleido-desktop", - "version": "1.0.1", + "version": "0.1.0-beta.17", "dependencies": { "@fontsource-variable/inter": "^5.3.0", "@tanstack/react-query": "^5.105.0", diff --git a/package.json b/package.json index ffa1da4..ec1a7fc 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "kaleido-desktop", "private": true, - "version": "1.0.1", + "version": "0.1.0-beta.17", "type": "module", "scripts": { "dev": "vite", diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index fd8584e..49f2df2 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -2173,7 +2173,7 @@ dependencies = [ [[package]] name = "kaleido" -version = "1.0.1" +version = "0.1.0-beta.17" dependencies = [ "fs2", "futures-util", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index c879aaf..2f201f8 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "kaleido" -version = "1.0.1" +version = "0.1.0-beta.17" description = "Kaleido — a Plex client for Windows" authors = ["Elijah"] edition = "2021" diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index e6ecb1d..525d4f7 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "https://schema.tauri.app/config/2", "productName": "Kaleido", - "version": "1.0.1", + "version": "0.1.0-beta.17", "identifier": "tv.kaleido.desktop", "build": { "beforeDevCommand": "npm run dev", diff --git a/src/app/format.ts b/src/app/format.ts index e4a7ba9..a41b82d 100644 --- a/src/app/format.ts +++ b/src/app/format.ts @@ -36,19 +36,10 @@ export function progress(item: Item): number { return Math.min(1, Math.max(0, item.viewOffset / item.duration)); } -/** - * Watched once Plex has counted a full play. A rewatch left partway through keeps the - * title watched; its position only matters for resuming (`resumable`). - */ export function isWatched(item: Item, percent = 90): boolean { if (item.type === 'show' || item.type === 'season') return item.leafCount > 0 && item.viewedLeafCount >= item.leafCount; - if (item.viewCount > 0) return true; - return item.viewOffset > 0 && item.duration > 0 && item.viewOffset / item.duration >= percent / 100; -} - -/** Has a saved position worth resuming from (not one at the very end). */ -export function resumable(item: Item): boolean { - return item.viewOffset > 0 && item.duration > 0 && item.viewOffset < item.duration * 0.97; + if (item.viewOffset > 0 && item.duration > 0) return item.viewCount > 0 && item.viewOffset / item.duration >= percent / 100; + return item.viewCount > 0; } export function remainingEpisodes(item: Item): number { diff --git a/src/app/keyboardNav.ts b/src/app/keyboardNav.ts index 4e01527..8a77535 100644 --- a/src/app/keyboardNav.ts +++ b/src/app/keyboardNav.ts @@ -1,9 +1,9 @@ /** * Arrow-key movement between titles, for keyboard users. Focus moves to the * nearest card in the pressed direction (by on-screen geometry), so it works - * the same across shelves, grids and people rows. + * the same across shelves, grids, episode lists and people rows. */ -const TARGETS = '.card, .person-card:not(:disabled), .shelf-title-link'; +const TARGETS = '.card, .person-card:not(:disabled), .episode-row, .shelf-title-link'; function center(r: DOMRect) { return { x: r.left + r.width / 2, y: r.top + r.height / 2 }; diff --git a/src/player/PlayerOverlay.tsx b/src/player/PlayerOverlay.tsx index 5094fb2..b917128 100644 --- a/src/player/PlayerOverlay.tsx +++ b/src/player/PlayerOverlay.tsx @@ -758,7 +758,7 @@ function MiniPlayer() {
- {(loading || st.buffering || st.reconnecting) && !st.error ? ( + {(loading || st.buffering) && !st.error ? ( ) : st.error ? ( Playback stopped @@ -911,7 +911,7 @@ export function PlayerOverlay() { }, [st.open, st.mini, seekStep, poke]); // The macOS traffic lights fade with the rest of the player's chrome. - const chromeHidden = st.open && !st.mini && !st.postPlay && !visible && st.firstFrame && !st.error; + const chromeHidden = st.open && !st.mini && !visible && st.firstFrame && !st.error; useEffect(() => { if (!chromeHidden) return; win.setButtonsVisible(false); @@ -965,12 +965,10 @@ export function PlayerOverlay() { {!st.fullscreen && }
- {(loading || st.buffering || st.seeking || preparing || st.reconnecting) && !st.error && ( + {(loading || st.buffering || st.seeking || preparing) && !st.error && (
- {st.reconnecting ? ( -

Lost connection to {server?.name ?? 'the server'}

- ) : preparing && ( + {preparing && (

Preparing {UPSCALING[st.enhance.active].label} upscaling First time on this computer only @@ -1025,8 +1023,6 @@ export function PlayerOverlay() {

- {/* Balances Stop on the other side, so play/pause stays centred. */} -
- - {!fullscreen && } -
- -
-
-
-
- - {upcoming || !contextReady ? 'Up next' : 'More to watch'} - - {item.grandparentId ? ( - - ) : ( - - )} - {upcoming ? ( - <> -

{upcoming.title}

- - {upcoming.summary &&

{upcoming.summary}

} - - - ) : ( - contextReady &&

You’ve reached the end of this series.

- )} -
-
- - {server && } - - ); -} - -/** - * Draws the native video into the frame's rectangle and cuts the same hole in - * the page, following window resizes and display scale changes. - */ -function useVideoRect(root: React.RefObject, frame: React.RefObject) { - useLayoutEffect(() => { - const el = frame.current; - const page = root.current; - if (!el || !page) return; - let raf = 0; + useEffect(() => { + const el = video.current; + if (!el) return; + let frame = 0; const place = () => { - cancelAnimationFrame(raf); - raf = requestAnimationFrame(() => { + cancelAnimationFrame(frame); + frame = requestAnimationFrame(() => { const r = el.getBoundingClientRect(); - page.style.setProperty('--up-x', `${r.x}px`); - page.style.setProperty('--up-y', `${r.y}px`); - page.style.setProperty('--up-w', `${r.width}px`); - page.style.setProperty('--up-h', `${r.height}px`); - page.classList.add('placed'); + const style = root.current!.style; + for (const [key, value] of Object.entries({ x: r.x, y: r.y, w: r.width, h: r.height })) style.setProperty(`--up-video-${key}`, `${value}px`); const dpr = window.devicePixelRatio || 1; - // A pixel of overdraw on each side keeps the hole covered at any scale. if (isNative) mpv.rect({ x: r.x * dpr - 1, y: r.y * dpr - 1, width: r.width * dpr + 2, height: r.height * dpr + 2 }).catch(() => {}); + root.current!.classList.add('placed'); }); }; - const ro = new ResizeObserver(place); - ro.observe(el); + const observer = new ResizeObserver(place); + observer.observe(el); window.addEventListener('resize', place); place(); return () => { - cancelAnimationFrame(raf); - ro.disconnect(); + cancelAnimationFrame(frame); + observer.disconnect(); window.removeEventListener('resize', place); if (isNative) mpv.rect(null).catch(() => {}); }; }, []); -} - -/** Where the playing episode is, under the video. Its own subscription: position ticks re-render only this. */ -function NowPlaying({ item }: { item: Item }) { - const position = usePlayer((s) => s.position); - const total = usePlayer((s) => s.duration); - return ( -
-
- - {episodeLabel(item)} · {item.title} - - −{clock(Math.max(0, total - position))} -
-
- -
-
- ); -} - -/** - * Play next episode. While autoplay counts down, a lighter fill sweeps across it. - * The store counts in 50 ms steps; the fill is drawn every frame between them. - */ -function PlayNext({ ref }: { ref: React.Ref }) { - const counting = usePlayer((s) => s.countdown !== null && s.countdownTotal > 0); - const fill = useRef(null); - useEffect(() => { - if (!counting) return; - let last = { value: usePlayer.getState().countdown ?? 0, at: performance.now() }; - const unsubscribe = usePlayer.subscribe((s, prev) => { - if (s.countdown !== prev.countdown && s.countdown !== null) last = { value: s.countdown, at: performance.now() }; - }); - let raf = 0; - const draw = () => { - const { countdownTotal: total } = usePlayer.getState(); - // Run on from the last step, but never more than a couple of steps ahead (a held countdown stays held). - const remaining = Math.max(0, last.value - Math.min(performance.now() - last.at, 120) / 1000); - if (fill.current && total) fill.current.style.transform = `scaleX(${1 - remaining / total})`; - raf = requestAnimationFrame(draw); - }; - draw(); - return () => { - unsubscribe(); - cancelAnimationFrame(raf); - }; - }, [counting]); - return ( - - ); -} - -function UpNextRows({ item, nextUp }: { item: Item; nextUp: Item | null }) { - const server = useSession((s) => s.server)!; - const season = useQuery({ - queryKey: [server.machineId, 'children', item.parentId], - queryFn: () => api.children(server, item.parentId), - enabled: !!item.parentId, - staleTime: 30_000, - }); - const related = useQuery({ - queryKey: [server.machineId, 'related', item.grandparentId], - queryFn: () => api.related(server, item.grandparentId), - enabled: !!item.grandparentId, - staleTime: 10 * 60_000, - }); - const episodes = (season.data ?? []).filter((e) => e.type === 'episode'); - const seen = new Set([item.grandparentId]); - const shows = (related.data ?? []).flatMap((h) => h.items).filter((i) => i.type === 'show' && !seen.has(i.id) && !!seen.add(i.id)); - - // The season row starts just before the playing episode. - const seasonRow = useRef(null); - useLayoutEffect(() => { - const row = seasonRow.current?.querySelector('.shelf'); - const current = row?.querySelector('[aria-current]'); - if (!row || !current) return; - const start = (current.previousElementSibling as HTMLElement | null) ?? current; - const target = row.scrollLeft + start.getBoundingClientRect().left - row.getBoundingClientRect().left - parseFloat(getComputedStyle(row).paddingLeft); - row.scrollTo({ left: target, behavior: 'instant' }); - }, [episodes.length]); + const watch = () => { + if (st.ended) st.togglePause(); + st.dismissPostPlay(); + }; const choose = (episode: Item) => { - const st = usePlayer.getState(); - if (episode.id === item.id) st.dismissPostPlay(); + if (episode.id === item.id) watch(); else st.play(episode, { resume: true, quality: st.quality }); }; const browse = async (show: Item) => { - await usePlayer.getState().close(); + await st.close(); navigate({ name: 'item', id: show.id, title: show.title }); }; - if (!episodes.length && !shows.length) return null; + const rail = (label: string, items: Item[], episodes: boolean) => items.length > 0 && ( +
+

{label}

+
+ {items.map((entry) => ( + + ))} +
+
+ ); + return ( -
- {episodes.length > 0 && ( -
- - {episodes.map((ep) => ( - choose(ep)} - /> - ))} - +
+
{server && }
+ {!st.fullscreen &&
} +
+
+
- )} - {shows.length > 0 && ( - - {shows.map((show) => ( - void browse(show)} /> - ))} - - )} +
+ {upcoming || !st.episodeContextReady ? 'Up next' : 'More to watch'} + + {upcoming ? <> +

{upcoming.title}

+ + {upcoming.summary &&

{upcoming.summary}

} +
+ +
+ : st.episodeContextReady ?

You’ve reached the end of this series.

: } +
+
+
+ {rail(item.parentIndex ? `Season ${item.parentIndex}` : 'Episodes', season, true)} + {rail('Related shows', related, false)} +
); } - -function UpNextCard({ item, caption, current, onChoose }: { item: Item; caption: string; current?: boolean; onChoose: () => void }) { - const server = useSession((s) => s.server)!; - const episode = item.type === 'episode'; - const title = episode ? `${item.index}. ${item.title}` : item.title; - const progress = episode && !current && item.viewOffset && item.duration ? item.viewOffset / item.duration : 0; - return ( -
{ - if (e.key !== 'Enter' && e.key !== ' ') return; - e.preventDefault(); - onChoose(); - }} - > -
- {title}} /> -
- {episode && !current && ( -
- -
- )} - {progress > 0 && ( - - - - )} -
-
-
- {title} -
- {caption &&
{caption}
} -
-
- ); -} diff --git a/src/player/miniWindow.ts b/src/player/miniWindow.ts index eebe2b2..2f1966c 100644 --- a/src/player/miniWindow.ts +++ b/src/player/miniWindow.ts @@ -30,7 +30,6 @@ interface PlayerView { duration: number; firstFrame: boolean; buffering: boolean; - reconnecting: boolean; error: string; } @@ -51,8 +50,7 @@ function view(st: PlayerView): MiniState { position: st.position, duration: st.duration, loading: !st.firstFrame && !st.error, - // Waiting for the server to come back shows as buffering. - buffering: st.buffering || st.reconnecting, + buffering: st.buffering, error: !!st.error, }; } diff --git a/src/player/store.test.ts b/src/player/store.test.ts index df87345..26169bc 100644 --- a/src/player/store.test.ts +++ b/src/player/store.test.ts @@ -5,7 +5,7 @@ const harness = vi.hoisted(() => { const memory = new Map(); vi.stubGlobal('localStorage', { getItem: (k: string) => memory.get(k) ?? null, setItem: (k: string, v: string) => memory.set(k, v), removeItem: (k: string) => memory.delete(k) }); vi.stubGlobal('document', Object.assign(new EventTarget(), { hidden: false, hasFocus: () => true, documentElement: { classList: { toggle: vi.fn() } } })); - return { event: (_e: MpvEvent) => {}, next: [] as unknown[], focused: true, identity: vi.fn() }; + return { event: (_e: MpvEvent) => {}, next: [] as unknown[], focused: true }; }); vi.mock('../platform/native', () => ({ @@ -20,7 +20,7 @@ vi.mock('./engine', () => ({ mpv: { } })); vi.mock('../app/session', async () => { const { create } = await import('zustand'); - return { useSession: create(() => ({ server: { machineId: 'test', token: 'test-only', name: 'Test', get: harness.identity }, connection: { local: true } })) }; + return { useSession: create(() => ({ server: { machineId: 'test', token: 'test-only' }, connection: { local: true } })) }; }); vi.mock('../downloads/store', () => ({ useDownloads: { getState: () => ({ items: [] }) } })); vi.mock('../app/queries', () => ({ invalidateLibrary: vi.fn() })); @@ -42,11 +42,7 @@ const episode = (id = '1') => parseItem({ ratingKey: id, type: 'episode', title: Media: [{ Part: [{ key: '/video', Stream: [{ id: 'audio', streamType: 2 }] }] }], }); const time = (position: number) => harness.event({ type: 'property', name: 'time-pos', value: position }); -/** The stream ending at `position` (by default the real end of the 100 s episode). */ -const eof = (position = 99.6) => { - usePlayer.setState({ position }); - harness.event({ type: 'end-file', reason: 'eof' }); -}; +const eof = () => harness.event({ type: 'end-file', reason: 'eof' }); beforeEach(async () => { vi.useFakeTimers(); @@ -106,14 +102,6 @@ describe('Up Next playback lifecycle', () => { expect(next).toHaveBeenCalledOnce(); usePlayer.setState({ playNext: original }); }); - it('starts the next episode from the beginning, ignoring an earlier partial viewing', async () => { - const original = usePlayer.getState().play; - const spy = vi.fn().mockResolvedValue(undefined); - usePlayer.setState({ play: spy, nextUp: { ...episode('2'), viewOffset: 88000 } }); - await usePlayer.getState().playNext(); - expect(spy).toHaveBeenCalledWith(expect.objectContaining({ id: '2' }), expect.objectContaining({ resume: false })); - usePlayer.setState({ play: original }); - }); it('cancels autoplay while keeping the screen open, including across EOF', () => { time(81); usePlayer.getState().cancelCountdown(); @@ -121,26 +109,12 @@ describe('Up Next playback lifecycle', () => { vi.advanceTimersByTime(10000); expect(usePlayer.getState()).toMatchObject({ postPlay: true, countdown: null, postPlayDismissed: true }); }); - it('returns to credits without reopening while they play', () => { + it('returns to credits without reopening on the next time event or EOF', () => { time(81); usePlayer.getState().dismissPostPlay(); time(82); - expect(usePlayer.getState()).toMatchObject({ postPlay: false, countdown: null }); - }); - it('reopens at the end after returning to the credits', () => { - time(81); - usePlayer.getState().dismissPostPlay(); eof(); - expect(usePlayer.getState()).toMatchObject({ postPlay: true, countdown: 5 }); - }); - it('reopens when the credits start again after seeking back into the episode', () => { - time(81); - usePlayer.getState().dismissPostPlay(); - usePlayer.getState().seek(40); - time(40); - expect(usePlayer.getState().postPlay).toBe(false); - time(80); - expect(usePlayer.getState()).toMatchObject({ postPlay: true, countdown: 5 }); + expect(usePlayer.getState()).toMatchObject({ postPlay: false, countdown: null }); }); it.each(['hidden', 'mini'] as const)('holds the countdown while %s', (reason) => { time(81); @@ -230,51 +204,3 @@ describe('Up Next playback lifecycle', () => { expect(usePlayer.getState()).toMatchObject({ open: false, postPlay: false, countdown: null }); }); }); - -describe('Losing the server mid-stream', () => { - it('waits for the server instead of ending when the stream is cut off early', () => { - eof(42); - expect(usePlayer.getState()).toMatchObject({ reconnecting: true, ended: false, postPlay: false }); - }); - it('resumes from where it stopped once the server answers again', async () => { - const original = usePlayer.getState().play; - const play = vi.fn().mockResolvedValue(undefined); - usePlayer.setState({ play }); - harness.identity.mockRejectedValueOnce(new Error('unreachable')); - eof(42); - await vi.advanceTimersByTimeAsync(2000); - expect(play).not.toHaveBeenCalled(); - expect(usePlayer.getState().reconnecting).toBe(true); - harness.identity.mockResolvedValueOnce({}); - await vi.advanceTimersByTimeAsync(3000); - expect(play).toHaveBeenCalledWith(expect.objectContaining({ id: '1' }), expect.objectContaining({ offsetMs: 42000, keepMini: true })); - expect(usePlayer.getState().reconnecting).toBe(false); - usePlayer.setState({ play: original }); - }); - it('tries straight away on Play instead of starting over', async () => { - const original = usePlayer.getState().play; - const play = vi.fn().mockResolvedValue(undefined); - usePlayer.setState({ play }); - harness.identity.mockResolvedValueOnce({}); - eof(42); - usePlayer.getState().togglePause(); - await vi.waitFor(() => expect(play).toHaveBeenCalledWith(expect.anything(), expect.objectContaining({ offsetMs: 42000 }))); - expect(mpv.command).not.toHaveBeenCalledWith('seek', '0.000', 'absolute+exact'); - usePlayer.setState({ play: original }); - }); - it('treats a second cut-off at the same place as the real end of the file', async () => { - harness.identity.mockResolvedValueOnce({}); - eof(42); - await vi.advanceTimersByTimeAsync(2000); - usePlayer.setState({ firstFrame: true }); - eof(42.5); - expect(usePlayer.getState()).toMatchObject({ reconnecting: false, ended: true }); - }); - it('stops waiting when the player is closed', async () => { - eof(42); - await usePlayer.getState().close(); - harness.identity.mockClear(); - await vi.advanceTimersByTimeAsync(10000); - expect(harness.identity).not.toHaveBeenCalled(); - }); -}); diff --git a/src/player/store.ts b/src/player/store.ts index 0606a41..5107db3 100644 --- a/src/player/store.ts +++ b/src/player/store.ts @@ -36,8 +36,6 @@ export interface PlayOptions { quality?: Quality; /** Keep these track choices (UI keys) instead of applying the preferences again. */ tracks?: { audioKey: string; subKey: string }; - /** Reloading the same title in place (after an outage): stay in the miniplayer if it's there. */ - keepMini?: boolean; } interface PlayerState { @@ -50,8 +48,6 @@ interface PlayerState { error: string; /** The server owner stopped this stream (error holds their message). */ terminated: boolean; - /** The stream was cut off before the end (the server went away); waiting for it to come back. */ - reconnecting: boolean; position: number; duration: number; cacheTime: number; @@ -601,7 +597,7 @@ function onEvent(e: MpvEvent) { } break; case 'eof-reached': - if (v === true) onStreamEnd(); + if (v === true) onEnded(); break; } break; @@ -622,14 +618,11 @@ function onEvent(e: MpvEvent) { // (Briefly: an unreachable server shouldn't hold up the error.) const failed = session; Promise.race([report('buffering'), new Promise((r) => setTimeout(() => r(false), 3000))]).then((terminated) => { - const now = usePlayer.getState(); - if (terminated || !now.open || session !== failed) return; - // Partway through a stream that was playing, it's the connection that failed. - if (cutShort(now)) return onStreamEnd(); + if (terminated || !usePlayer.getState().open || session !== failed) return; usePlayer.setState({ error: e.error ? `Playback failed: ${e.error}` : 'This video could not be played.' }); fallbackAfterError(); }); - } else if (e.reason === 'eof') onStreamEnd(); + } else if (e.reason === 'eof') onEnded(); break; case 'log': noteMpvLog(e.level, e.prefix, e.text); @@ -654,69 +647,8 @@ function fallbackAfterError() { function maybeCredits(pos: number) { const st = usePlayer.getState(); - if (st.item?.type !== 'episode' || !st.firstFrame) return; - const inCredits = st.item.markers.some((m) => m.type === 'credits' && pos * 1000 >= m.start && pos * 1000 < m.end); - // Leaving the credits (seeking back into the episode) re-arms Up Next for the next time they start. - if (!inCredits) { - if (st.postPlayDismissed && !st.postPlay && !st.ended) usePlayer.setState({ postPlayDismissed: false }); - } else if (!st.postPlayDismissed) openPostPlay(); -} - -/** - * A streamed title stopping well short of its end means the connection went - * (mpv plays out its buffer, then sees the cut-off stream as the end of the file). - */ -const CUT_SHORT_MARGIN = 15; -let reconnectTimer: ReturnType | null = null; -/** Where the last cut-off happened, so a file that really does end early isn't retried forever. */ -let lastCutAt: number | null = null; - -function cutShort(st: PlayerState) { - return st.delivery?.mode !== 'local' && st.firstFrame && st.duration > 0 && st.position < st.duration - CUT_SHORT_MARGIN; -} - -/** The stream ran out: a real ending, or a lost connection to wait out. */ -function onStreamEnd() { - const st = usePlayer.getState(); - if (!cutShort(st)) return onEnded(); - if (st.reconnecting || st.ended) return; - // Cut off at the same place again once the server answered: the file itself ends there. - if (lastCutAt !== null && Math.abs(st.position - lastCutAt) < 5) return onEnded(); - lastCutAt = st.position; - usePlayer.setState({ reconnecting: true, buffering: false }); - keepAwake(false); - scheduleReconnect(2000); -} - -function stopReconnecting() { - if (reconnectTimer) clearTimeout(reconnectTimer); - reconnectTimer = null; -} - -function scheduleReconnect(delay: number) { - stopReconnecting(); - reconnectTimer = setTimeout(() => void tryReconnect(), delay); -} - -/** Resumes where the stream was cut off if the server answers; otherwise checks again shortly. */ -async function tryReconnect(): Promise { - stopReconnecting(); - const st = usePlayer.getState(); - const s = server(); - if (!st.open || !st.reconnecting || !st.item || !s) return false; - const reachable = await s.get('/identity', undefined, { timeout: 4000 }).then( - () => true, - () => false, - ); - const now = usePlayer.getState(); - if (!now.open || !now.reconnecting || now.item?.id !== st.item.id) return false; - if (!reachable) { - scheduleReconnect(3000); - return false; - } - usePlayer.setState({ reconnecting: false }); - await now.play(now.item, { offsetMs: now.position * 1000, mediaIndex: now.mediaIndex, quality: now.quality, tracks: currentTracks(now), keepMini: true }); - return true; + if (st.item?.type !== 'episode' || !st.firstFrame || st.postPlayDismissed) return; + if (st.item.markers.some((m) => m.type === 'credits' && pos * 1000 >= m.start && pos * 1000 < m.end)) openPostPlay(); } function onEnded() { @@ -725,11 +657,7 @@ function onEnded() { usePlayer.setState({ ended: true }); report('stopped'); checkScrobble(); - // Reaching the end always offers Up Next, as on Android, even after watching the credits. - if (st.item?.type === 'episode' && !st.postPlay) { - usePlayer.setState({ postPlayDismissed: false }); - openPostPlay(); - } + if (st.item?.type === 'episode') openPostPlay(); } export const usePlayer = create((set, get) => ({ @@ -741,7 +669,6 @@ export const usePlayer = create((set, get) => ({ firstFrame: false, error: '', terminated: false, - reconnecting: false, position: 0, duration: 0, cacheTime: 0, @@ -785,8 +712,6 @@ export const usePlayer = create((set, get) => ({ return; } const previous = get(); - stopReconnecting(); - if (previous.item?.id !== input.id) lastCutAt = null; // The previous title's reporting ends here, against its own server. if (reportTimer) clearInterval(reportTimer); reportTimer = null; @@ -815,7 +740,6 @@ export const usePlayer = create((set, get) => ({ firstFrame: false, error: '', terminated: false, - reconnecting: false, position: (opts.offsetMs ?? 0) / 1000, lastSeek: 0, duration: input.duration / 1000, @@ -837,7 +761,7 @@ export const usePlayer = create((set, get) => ({ subKey: opts.tracks?.subKey ?? '__init', video: null, fullscreen: fullscreenNow, - mini: opts.keepMini ? previous.open && previous.mini : false, + mini: false, videoGamma: '', enhance: { ...previous.enhance, bypass: false, preparing: false }, }); @@ -934,9 +858,6 @@ export const usePlayer = create((set, get) => ({ offsetMs > 0 && delivery.mode !== 'transcode' ? `start=${(offsetMs / 1000).toFixed(2)}` : 'start=none', ].join(','); await mpv.command('loadfile', delivery.url, 'replace', -1, fileOpts); - // A file left paused at its end (keep-open) re-pauses as soon as it's unpaused - // above, so a reload in place (after an outage) would open paused: unpause again. - await mpv.set('pause', false); if (stale()) return; keepAwake(true); report('buffering'); @@ -955,8 +876,6 @@ export const usePlayer = create((set, get) => ({ loadToken++; const st = get(); stopCountdown(); - stopReconnecting(); - lastCutAt = null; if (reportTimer) clearInterval(reportTimer); reportTimer = null; if (st.item && !st.error) report('stopped'); @@ -974,7 +893,7 @@ export const usePlayer = create((set, get) => ({ await mpv.command('stop').catch(() => {}); await mpv.show(false).catch(() => {}); } - set({ open: false, mini: false, postPlay: false, item: null, delivery: null, error: '', terminated: false, reconnecting: false, countdown: null, nextUp: null, prevUp: null, firstFrame: false }); + set({ open: false, mini: false, postPlay: false, item: null, delivery: null, error: '', terminated: false, countdown: null, nextUp: null, prevUp: null, firstFrame: false }); // Closing the full player hands back the window it found; closing the // miniplayer leaves browsing as it is, full screen or not. if (!st.mini) { @@ -986,13 +905,6 @@ export const usePlayer = create((set, get) => ({ togglePause() { const st = get(); - // Play while the server is away: try it now rather than at the next check. - if (st.reconnecting) { - tryReconnect().then((resumed) => { - if (!resumed && get().reconnecting) toast(`Still can’t reach ${server()?.name ?? 'the server'}.`); - }); - return; - } if (st.ended) { st.seek(0); set({ ended: false }); @@ -1099,15 +1011,13 @@ export const usePlayer = create((set, get) => ({ const st = get(); stopCountdown(); if (!st.nextUp) return; - // Watching on through a season starts each episode from the top, never at a - // stale position left by an earlier, unfinished viewing. - await st.play(st.nextUp, { resume: false, quality: st.quality }); + await st.play(st.nextUp, { resume: true, quality: st.quality }); }, async playPrevious() { const st = get(); if (!st.prevUp) return; - await st.play(st.prevUp, { resume: false, quality: st.quality }); + await st.play(st.prevUp, { resume: true, quality: st.quality }); }, cancelCountdown() { diff --git a/src/plex/plex.test.ts b/src/plex/plex.test.ts index fdd06ff..8be9e2e 100644 --- a/src/plex/plex.test.ts +++ b/src/plex/plex.test.ts @@ -3,7 +3,7 @@ import { parseItem, parseScores } from './parse'; import { isLocalAddress } from './account'; import { partAt } from './playback'; import { headerSafe } from './client'; -import { duration, formatBadges, isWatched, remaining, resumable, washGradient } from '../app/format'; +import { duration, formatBadges, isWatched, remaining, washGradient } from '../app/format'; import { buildFeatures } from '../screens/discover'; import type { Hub } from './types'; @@ -65,16 +65,10 @@ describe('parsing', () => { }); describe('watched rules', () => { - it('keeps a title watched while it is being rewatched', () => { - expect(isWatched(movie({ viewCount: 1, viewOffset: 3000000 }), 90)).toBe(true); + it('treats a resumed title as watched only past the threshold', () => { + expect(isWatched(movie({ viewCount: 1, viewOffset: 3000000 }), 90)).toBe(false); + expect(isWatched(movie({ viewCount: 1, viewOffset: 5700000 }), 90)).toBe(true); expect(isWatched(movie({ viewCount: 1 }), 90)).toBe(true); - expect(resumable(movie({ viewCount: 1, viewOffset: 3000000 }))).toBe(true); - }); - - it('counts an unplayed title as watched only past the threshold', () => { - expect(isWatched(movie({ viewOffset: 3000000 }), 90)).toBe(false); - expect(isWatched(movie({ viewOffset: 5700000 }), 90)).toBe(true); - expect(isWatched(movie({}), 90)).toBe(false); }); it('uses episode counts for shows', () => { diff --git a/src/screens/Item.tsx b/src/screens/Item.tsx index dba8e82..ebaf887 100644 --- a/src/screens/Item.tsx +++ b/src/screens/Item.tsx @@ -4,12 +4,12 @@ import type { Item } from '../plex/types'; import { PROGRESS, useChildren, useItem, useRelated, useServerQuery } from '../app/queries'; import { useServer } from '../app/session'; import { useSettings } from '../app/settings'; -import { goBack, navigate } from '../app/router'; -import { canManage, itemMenu, openDialog, playItem, playWithVersion, setWatched, shuffleItem } from '../app/actions'; -import { bitrate, channelLabel, date, duration, episodeLabel, extraLabel, fileSize, isWatched, remaining, remainingEpisodes, resolutionLabel, resumable, technicalLine } from '../app/format'; +import { goBack, navigate, useRouter } from '../app/router'; +import { canManage, itemMenu, openDialog, openItem, playItem, playWithVersion, setWatched, shuffleItem } from '../app/actions'; +import { bitrate, channelLabel, date, duration, episodeLabel, extraLabel, fileSize, isWatched, remaining, resolutionLabel, technicalLine } from '../app/format'; import { Backdrop } from '../ui/Backdrop'; -import { EpisodeCard, Facts, HubShelf, LandscapeCard, PersonCard, PosterCard, Shelf, TitleArt } from '../ui/media'; -import { Artwork, Button, EmptyState, ErrorState, IconButton, PageLoader } from '../ui/primitives'; +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 } from '../ui/overlays'; import { useDownloads } from '../downloads/store'; @@ -255,12 +255,11 @@ function AboutPanel({ item }: { item: Item }) { // —— Movie —————————————————————————————————————————————————————————— function MovieDetail({ item }: { item: Item }) { - const resume = resumable(item); + const resume = item.viewOffset > 0 && !isWatched(item); return (
- {/* The Resume button carries the time left; the facts give the runtime. */} - +
+ {p > 0 && !watched && ( + + + + )} +
+
+

+ {ep.title} + {watched && } +

+
+ {[duration(ep.duration), ep.originallyAvailableAt ? date(ep.originallyAvailableAt) : '', ep.viewOffset && !watched ? remaining(ep) : ''].filter(Boolean).join(' · ')} +
+ {ep.summary &&

{ep.summary}

} +
+
); } -function EpisodesSection({ episodes, subtitle, upNextId }: { episodes: Item[] | undefined; subtitle?: string; upNextId?: string }) { +function Episodes({ seasons, initialSeason, showPicker = true }: { seasons: Item[]; initialSeason?: string; showPicker?: boolean }) { + const saved = useRouter((s) => s.current.state.season as string | undefined); + const [seasonId, setSeasonId] = useState(saved ?? initialSeason ?? seasons[0]?.id); + useEffect(() => { + if (!seasonId && seasons[0]) setSeasonId(initialSeason ?? seasons[0].id); + }, [seasons, initialSeason]); + const episodes = useChildren(seasonId); + const season = seasons.find((s) => s.id === seasonId); + if (!seasons.length) return null; return (
-
-

- Episodes - {subtitle && {subtitle}} -

+
+

Episodes

+ {showPicker && seasons.length > 1 && ( + set('skipIntro', v)} options={skipOptions} /> - - - set('autoSkipDelay', v)} - options={[0, 3, 5, 10].map((v) => ({ value: v, label: v ? `${v} seconds` : 'Skip straight away' }))} - /> - - + +
+ +
+
+ Intros + set('skipCredits', v)} options={skipOptions} /> +
+ {(s.skipIntro === 'auto' || s.skipCredits === 'auto') && ( +
+ Skip delay + * { position: relative; } -/* —— Up Next ———————————————————————————————————————————————————————— - The credits keep playing in the top-left frame: the native video is drawn - into its rectangle and the scene has a matching hole (PostPlay.tsx). Only - the rows scroll, so the frame never moves. */ +/* Up Next keeps a stationary opening over the native video; +only the rows scroll. */ .up-next { display: flex; flex-direction: column; - --up-top: 64px; - --up-video-w: clamp(320px, 34vw, 640px); + --up-gutter: clamp(28px, 4vw, 64px); } .up-next-scene { position: absolute; inset: 0; - overflow: hidden; - isolation: isolate; background: var(--bg); pointer-events: none; } +/* Up Next places copy on the right as well as the left. Keep every part of + the artwork dark enough for text, including with the colour wash enabled. + This layer shares the scene's video cutout, so it never dims the credits. */ +.up-next-scene::after { + content: ''; + position: absolute; + inset: 0; + z-index: 1; + background: linear-gradient(180deg, rgba(9, 10, 12, 0.76), rgba(9, 10, 12, 0.9)); +} .up-next.placed .up-next-scene { - -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='2.4'/%3E%3C/svg%3E"); - -webkit-mask-size: 100% 100%, var(--up-w) var(--up-h); - -webkit-mask-position: 0 0, var(--up-x) var(--up-y); + -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'/%3E%3C/svg%3E"); + -webkit-mask-size: 100% 100%, var(--up-video-w) var(--up-video-h); + -webkit-mask-position: 0 0, var(--up-video-x) var(--up-video-y); -webkit-mask-repeat: no-repeat; -webkit-mask-composite: xor; mask-composite: exclude; } -.up-next-backdrop { - height: min(78vh, 860px); - bottom: auto; +.up-next-window-controls { + position: absolute; + top: 0; + right: 0; + z-index: 2; } -.backdrop-tint.up-next-backdrop { - height: 100%; -} -/* The next episode's details sit over the artwork, so it stays dimmer here - than on a title page, with or without the colour wash. */ -.up-next-backdrop .backdrop-scrim, -.up-next-backdrop.washed .backdrop-scrim { - background: - linear-gradient(90deg, rgba(9, 10, 12, 0.96) 0%, rgba(9, 10, 12, 0.9) 38%, rgba(9, 10, 12, 0.74) 62%, rgba(9, 10, 12, 0.55) 100%), - linear-gradient(0deg, var(--bg) 0%, rgba(9, 10, 12, 0.6) 22%, transparent 55%); -} -.up-next-top { - height: 60px; - z-index: 3; -} -.up-next-fullscreen { - margin-left: auto; -} -/* Beside the window's own buttons (Windows, outside full screen), it takes - their size and line so the four read as one group. */ -.up-next-top:has(> .window-controls) .up-next-fullscreen { - align-self: flex-start; - width: 46px; - height: 34px; - margin-right: 110px; - border-radius: 0; - color: #e4e8e9; -} -.up-next-top:has(> .window-controls) .up-next-fullscreen svg { - width: 15px; - height: 15px; -} -.up-next-head { +.up-next-header { position: relative; - z-index: 1; + display: grid; + grid-template-columns: minmax(240px, 37%) minmax(0, 1fr); + gap: clamp(28px, 4vw, 64px); + padding: 36px var(--up-gutter) 26px; flex: none; - display: flex; - align-items: flex-start; - gap: clamp(28px, 3vw, 48px); - padding: var(--up-top) var(--gutter) 30px; - animation: fade-in 320ms var(--ease); } .up-next-now { - flex: none; - width: var(--up-video-w); + min-width: 0; } .up-next-video { display: block; + position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: 8px; - box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.16); - transition: box-shadow var(--t-fast); + outline: 1px solid #ffffff30; + outline-offset: 2px; } .up-next-video:hover, .up-next-video:focus-visible { - outline: none; - box-shadow: 0 0 0 2px #fff; + outline: 2px solid #fff; + outline-offset: 2px; } -.up-next-progress { - margin-top: 12px; -} -.up-next-progress-text { +.up-next-caption { display: flex; justify-content: space-between; gap: 12px; + margin: 14px 0 8px; font-size: 12px; - color: var(--muted); + color: #cbd2d4; } -.up-next-progress-text span { +.up-next-caption > span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; } -.up-next-progress-text small { +.up-next-caption small { flex: none; - font-size: inherit; - color: var(--dim); font-variant-numeric: tabular-nums; } -.up-next-video:hover + .up-next-progress .up-next-progress-text span { - color: #fff; -} -.up-next-progress-bar { +.up-next-progress { height: 3px; - margin-top: 8px; - border-radius: 3px; - background: rgba(255, 255, 255, 0.22); + border-radius: 2px; + background: #ffffff25; overflow: hidden; } -.up-next-progress-bar i { +.up-next-progress i { display: block; height: 100%; background: var(--accent); } -.up-next-info { - flex: 1; +.up-next-details { min-width: 0; - max-width: 680px; - padding-top: 6px; - text-shadow: 0 1px 12px rgba(0, 0, 0, 0.5); + align-self: center; } -.up-next-info .micro { +.up-next-details .micro { display: block; - margin-bottom: 12px; + margin-bottom: 10px; + color: #c3cbcd; } -.up-next-info .up-next-logo { - margin-bottom: 14px; +.up-next-details .facts { + color: #d0d6d8; } -.up-next-info .title-text { - font-size: clamp(26px, 2.4vw, 36px); - margin-bottom: 12px; +.up-next-details .title-art { + margin-bottom: 10px; } -.up-next-info h1 { +.up-next-details .title-text { margin: 0 0 10px; - font-size: clamp(20px, 1.7vw, 26px); + font-size: clamp(24px, 2.4vw, 34px); + line-height: 1.1; +} +.up-next-details h1 { + margin: 10px 0; + font-size: clamp(22px, 2vw, 30px); line-height: 1.2; - letter-spacing: -0.025em; - font-weight: 680; - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; + letter-spacing: -.025em; } .up-next-summary { - margin: 14px 0 0; - color: #e3e7e9; - text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6), 0 1px 14px rgba(0, 0, 0, 0.55); + color: #d6dcde; font-size: 14px; - line-height: 1.62; + line-height: 1.65; + margin: 12px 0 18px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; + max-width: 720px; } -/* The countdown: a lighter fill sweeps across the button, without numbers. */ .up-next-play { position: relative; overflow: hidden; - isolation: isolate; - margin-top: 22px; - text-shadow: none; + min-height: 42px; + padding: 0 20px; + border-radius: 6px; + background: #eee; + color: #101214; + font-size: 13px; + font-weight: 650; } -.up-next-play.counting, -.up-next-play.counting:hover:not(:disabled) { - background: #a3a8a9; +.up-next-play.counting { + background: #999; } -.up-next-play-fill { +.up-next-play.counting::before { + content: ''; position: absolute; - inset: 0; - z-index: -1; - background: #f6f7f7; - transform: scaleX(0); - transform-origin: left; - will-change: transform; + inset: 0 auto 0 0; + width: var(--p); + background: #f4f4f4; + transition: width 60ms linear; } -.up-next-play:focus-visible { - outline: 2px solid #fff; - outline-offset: 3px; +.up-next-play > span { + position: relative; + display: flex; + align-items: center; + gap: 8px; +} +.up-next-play:hover { + box-shadow: 0 0 0 2px #ffffff40; } .up-next-rows { position: relative; - z-index: 1; - flex: 1; - min-height: 0; - overflow-x: hidden; overflow-y: auto; - padding-bottom: 12px; - animation: fade-in 420ms var(--ease); + min-height: 0; + padding: 0 var(--up-gutter) 32px; + scrollbar-gutter: stable; } -.up-next-shelf { - margin-bottom: 22px; +.up-next-rail { + margin-bottom: 24px; } -/* Cards are sized from the space below the header, so the season and related - rows fill it (--up-row: a row's height besides its artwork). In a short, - wide window they keep a sensible size and the related row runs off the - bottom, as on Android TV. */ -.up-next-rows { - container-type: size; - --up-row: 128px; +.up-next-rail h2 { + font-size: 18px; + font-weight: 650; + margin: 0 0 14px; } -.up-next-shelf .shelf .card.landscape { - width: clamp(15vw, calc((50cqh - var(--up-row)) * 16 / 9), 26vw); +.up-next-cards { + display: flex; + gap: 16px; + overflow-x: auto; + padding: 4px 4px 14px; + scroll-snap-type: x proximity; } -@media (max-width: 1333px) { - .up-next-shelf .shelf .card.landscape { - width: clamp(200px, calc((50cqh - var(--up-row)) * 16 / 9), 26vw); +.up-next-card { + flex: 0 0 clamp(190px, 20vw, 280px); + min-width: 0; + text-align: left; + scroll-snap-align: start; +} +.up-next-card-art { + position: relative; + background: #202427; + aspect-ratio: 16 / 9; + border-radius: 7px; + overflow: hidden; + outline: 1px solid #ffffff15; +} +.up-next-card-art img { + display: block; + width: 100%; + height: 100%; + object-fit: cover; + transition: transform 180ms; +} +.up-next-card:hover .up-next-card-art, +.up-next-card:focus-visible .up-next-card-art { + outline: 2px solid #fff; + outline-offset: 2px; +} +.up-next-card > b { + display: block; + font-size: 12px; + font-weight: 550; + margin-top: 10px; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} +.up-next-card > small { + display: block; + margin-top: 5px; + font-size: 11px; + color: #aeb8bb; +} +.up-next button:focus-visible { + outline: 2px solid #fff; + outline-offset: 3px; +} +@media (max-height: 720px) { + .up-next-header { + grid-template-columns: minmax(220px, 32%) minmax(0, 1fr); + gap: 28px; + padding-top: 30px; + padding-bottom: 22px; } -} -.up-next-shelf .card { - scroll-margin-left: 0; -} -@media (max-height: 760px) { - .up-next-head { - padding-bottom: 20px; + .up-next-details .title-art { + max-height: 38px; } - .up-next-info .micro { - margin-bottom: 8px; - } - .up-next-info .up-next-logo { - height: 44px !important; - margin-bottom: 10px; - } - .up-next-info .up-next-logo img { - max-height: 44px !important; + .up-next-details h1 { + font-size: 22px; + margin: 6px 0; } .up-next-summary { -webkit-line-clamp: 2; - margin-top: 10px; + margin: 8px 0 12px; } - .up-next-play { - margin-top: 16px; + .up-next-details .micro { + margin-bottom: 6px; } - .up-next-shelf { - margin-bottom: 14px; - } -} -.up-next .card:focus-visible { - outline: none; } .player-error { position: absolute; diff --git a/src/styles/screens.css b/src/styles/screens.css index 1f617ce..191a778 100644 --- a/src/styles/screens.css +++ b/src/styles/screens.css @@ -430,30 +430,6 @@ button.chip:hover { letter-spacing: -0.035em; font-weight: 700; } -.season-switch { - display: inline-flex; - align-items: center; - gap: 6px; - margin-left: -8px; - padding: 2px 6px 2px 8px; - border-radius: 8px; - font: inherit; - letter-spacing: inherit; - transition: background var(--t-fast); -} -.season-switch svg { - color: #aeb5b8; - transition: - color var(--t-fast), - transform var(--t-fast); -} -.season-switch:hover { - background: rgba(255, 255, 255, 0.08); -} -.season-switch:hover svg { - color: #fff; - transform: translateY(1px); -} .synopsis-wrap { max-width: 640px; } @@ -604,29 +580,122 @@ button.chip:hover { } /* Episodes */ .episodes { - margin-bottom: 34px; + margin-bottom: 36px; } -.episodes .shelf-head { - padding: 0; +.episodes-head { + display: flex; + align-items: center; + gap: 16px; + margin-bottom: 8px; } -.episode-grid { - display: grid; - grid-template-columns: repeat(auto-fill, minmax(clamp(240px, 19vw, 320px), 1fr)); - gap: 30px 16px; +.episodes-head h2 { + margin: 0; + font-size: 19px; + letter-spacing: -0.028em; } -.episode-grid .card { +.episodes-sub { + color: var(--dim); + font-size: 12px; +} +.season-summary { + color: #aeb5b8; + font-size: 12.5px; + line-height: 1.6; + max-width: 760px; + margin: 4px 0 8px; +} +.episode-row { scroll-margin: 96px 0 48px; + display: grid; + grid-template-columns: 34px 220px minmax(0, 1fr) 40px; + gap: 20px; + align-items: center; + padding: 16px 12px 16px 6px; + border-bottom: 1px solid var(--line-soft); + border-radius: 10px; + cursor: pointer; + transition: background var(--t-fast); } -.episode-card-summary { - margin: 7px 0 0; +.episode-row:hover, +.episode-row:focus-visible { + background: rgba(255, 255, 255, 0.045); +} +.episode-row:focus-visible { + outline: 2px solid #f2f5f4; + outline-offset: 0; +} +.episode-index { + font-size: 22px; + font-weight: 650; + color: #8a9196; + text-align: center; + font-variant-numeric: tabular-nums; +} +.episode-pic { + position: relative; + aspect-ratio: 16 / 9; + border-radius: 6px; + overflow: hidden; + background: #1c2024; +} +.episode-pic .artwork { + position: absolute; + inset: 0; +} +.episode-play { + position: absolute; + left: 50%; + top: 50%; + width: 42px; + height: 42px; + margin: -21px 0 0 -21px; + border-radius: 50%; + display: grid; + place-items: center; + background: rgba(255, 255, 255, 0.92); + color: #121314; + opacity: 0; + transform: scale(0.9); + transition: + opacity var(--t), + transform var(--t) var(--ease-out); +} +.episode-row:hover .episode-play { + opacity: 1; + transform: none; +} +.episode-text h3 { + font-size: 14px; + margin: 0 0 4px; + font-weight: 640; + display: flex; + align-items: center; + gap: 8px; +} +.episode-watched { + color: #9fd6bb; +} +.episode-meta { + font-size: 11.5px; + color: #8a9196; + margin-bottom: 7px; +} +.episode-text p { + margin: 0; font-size: 12px; line-height: 1.55; - color: #a1a8ac; + color: #a8afb3; display: -webkit-box; - -webkit-line-clamp: 3; + -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; } +.episode-more { + opacity: 0; +} +.episode-row:hover .episode-more { + opacity: 1; +} /* —— Search ————————————————————————————————————————————————— */ .search-hero { @@ -1083,6 +1152,29 @@ button.chip:hover { gap: 8px; flex: none; } +.marker-preference .pref { + flex-direction: column; + align-items: flex-start; + gap: 14px; +} +.marker-preference .pref-control { + width: 100%; +} +.marker-controls { + display: flex; + flex-wrap: wrap; + gap: 12px 20px; +} +.marker-control { + display: flex; + flex-direction: column; + align-items: flex-start; + gap: 6px; +} +.marker-control > span { + font-size: 11.5px; + color: var(--muted); +} .pref-input { width: 240px; min-height: 34px; @@ -1976,6 +2068,10 @@ button.chip:hover { .download-intro { grid-template-columns: minmax(0, 1fr); } + .episode-row { + grid-template-columns: 26px 160px minmax(0, 1fr) 36px; + gap: 14px; + } .history-row { grid-template-columns: 36px minmax(0, 1fr) 120px 90px; } diff --git a/src/ui/Icon.tsx b/src/ui/Icon.tsx index 0d94c62..04d1b54 100644 --- a/src/ui/Icon.tsx +++ b/src/ui/Icon.tsx @@ -13,7 +13,6 @@ const PATHS: Record = { arrowLeft: '', play: '', pause: '', - stop: '', plus: '', minus: '', check: '', diff --git a/src/ui/media.tsx b/src/ui/media.tsx index 52be013..11b9136 100644 --- a/src/ui/media.tsx +++ b/src/ui/media.tsx @@ -1,10 +1,9 @@ -import { memo, useEffect, useLayoutEffect, useRef, useState, type ReactNode } from 'react'; +import { memo, useEffect, useRef, useState, type ReactNode } from 'react'; import type { Item } from '../plex/types'; import { useServer, useSession } from '../app/session'; import { useSettings } from '../app/settings'; -import { art, date, displayTitle, duration, episodeLabel, formatBadges, isWatched, progress, remaining, remainingEpisodes } from '../app/format'; +import { art, displayTitle, duration, episodeLabel, formatBadges, isWatched, progress, remaining, remainingEpisodes } from '../app/format'; import { itemMenu, openItem, playWithVersion } from '../app/actions'; -import { navigate } from '../app/router'; import { Artwork } from './primitives'; import { Icon } from './Icon'; import { openMenu } from './overlays'; @@ -142,14 +141,9 @@ function WatchBadge({ item }: { item: Item }) { return null; } -/** - * A watched title's leftover position (from an unfinished rewatch) only shows where it's - * what you're resuming: Continue Watching, or the season's up-next episode. - */ -function ProgressLine({ item, always = false }: { item: Item; always?: boolean }) { - const percent = useSettings((s) => s.watchedPercent); +function ProgressLine({ item }: { item: Item }) { const p = progress(item); - if (!p || p > 0.995 || (!always && isWatched(item, percent))) return null; + if (!p || p > 0.995) return null; return ( @@ -210,15 +204,12 @@ export const PosterCard = memo(function PosterCard({ item, caption = 'year', cla const server = useServer(); const handlers = useCardHandlers(item); const path = art.poster(item); - // On its show's page a season is just "Season 2"; anywhere else it needs the show's name. - const seasonAlone = item.type === 'season' && caption !== 'episodes' && !!item.parentTitle; - const title = item.type === 'season' && !seasonAlone ? item.title : displayTitle(item); let meta: ReactNode = null; - if (caption === 'year') meta = item.type === 'episode' ? episodeLabel(item) : item.type === 'season' ? item.title : item.type === 'collection' ? (item.childCount ? `${item.childCount} titles` : 'Collection') : item.year || ''; + if (caption === 'year') meta = item.type === 'episode' ? episodeLabel(item) : item.type === 'season' ? (item.leafCount ? `${item.leafCount} episodes` : '') : item.type === 'collection' ? (item.childCount ? `${item.childCount} titles` : 'Collection') : item.year || ''; if (caption === 'episodes') meta = item.leafCount ? `${item.leafCount} episodes` : ''; if (caption === 'role') meta = (item as any).roleName ?? item.year; return ( -
+
{displayTitle(item)}} />
@@ -228,8 +219,8 @@ export const PosterCard = memo(function PosterCard({ item, caption = 'year', cla
{caption !== 'none' && (
-
- {title} +
+ {item.type === 'season' ? item.title : displayTitle(item)}
{meta ?
{meta}
: null}
@@ -241,16 +232,14 @@ export const PosterCard = memo(function PosterCard({ item, caption = 'year', cla export const LandscapeCard = memo(function LandscapeCard({ item, continueWatching, showTitle = true, episodeStyle = false }: { item: Item; continueWatching?: boolean; showTitle?: boolean; episodeStyle?: boolean }) { const server = useServer(); const handlers = useCardHandlers(item, { continueWatching }); - const percent = useSettings((s) => s.watchedPercent); - const inProgress = !!item.viewOffset && (continueWatching || !isWatched(item, percent)); const isEp = item.type === 'episode'; const path = isEp ? item.thumb || item.grandparentArt : art.landscape(item); const title = episodeStyle && isEp ? `${item.index}. ${item.title}` : displayTitle(item); const meta = isEp ? episodeStyle - ? [duration(item.duration), inProgress ? remaining(item) : ''].filter(Boolean).join(' · ') + ? [duration(item.duration), item.viewOffset ? remaining(item) : ''].filter(Boolean).join(' · ') : `${episodeLabel(item)} ${item.title}` - : inProgress + : item.viewOffset ? remaining(item) : [item.year, duration(item.duration)].filter(Boolean).join(' · '); return ( @@ -265,25 +254,12 @@ export const LandscapeCard = memo(function LandscapeCard({ item, continueWatchin
{episodeStyle && } - +
{showTitle && (
- {isEp && !episodeStyle && item.grandparentId ? ( - - ) : ( - title - )} + {title}
{meta}
@@ -292,34 +268,6 @@ export const LandscapeCard = memo(function LandscapeCard({ item, continueWatchin ); }); -/** An episode with its synopsis, for a season's episode grid. `upNext` shows its resume point even when watched. */ -export const EpisodeCard = memo(function EpisodeCard({ item, upNext = false }: { item: Item; upNext?: boolean }) { - const server = useServer(); - const handlers = useCardHandlers(item); - const percent = useSettings((s) => s.watchedPercent); - const inProgress = !!item.viewOffset && (upNext || !isWatched(item, percent)); - const title = item.index ? `${item.index}. ${item.title}` : item.title; - const meta = [duration(item.duration), inProgress ? remaining(item) : date(item.originallyAvailableAt)].filter(Boolean).join(' · '); - return ( -
-
- {title}} /> -
- - - -
-
-
- {title} -
-
{meta}
- {item.summary &&

{item.summary}

} -
-
- ); -}); - export function PersonCard({ name, role, thumb, onClick }: { name: string; role?: string; thumb?: string; onClick?: () => void }) { const server = useServer(); const initials = name @@ -342,22 +290,15 @@ export function PersonCard({ name, role, thumb, onClick }: { name: string; role? export function Shelf({ title, subtitle, onViewAll, children, className = '', kind = 'poster' }: { title: ReactNode; subtitle?: ReactNode; onViewAll?: () => void; children: ReactNode; className?: string; kind?: 'poster' | 'landscape' | 'people' | 'wide' }) { const row = useRef(null); - const atStart = useRef(true); const [edges, setEdges] = useState({ start: true, end: false }); const update = () => { const el = row.current; if (!el) return; const start = el.scrollLeft < 8; const end = el.scrollLeft + el.clientWidth >= el.scrollWidth - 8; - atStart.current = start; // Runs on every scroll event; re-render only when an edge changes. setEdges((prev) => (prev.start === start && prev.end === end ? prev : { start, end })); }; - // A row the viewer hasn't scrolled stays at its start when items are added - // in front (Continue Watching), rather than holding on to the old first card. - useLayoutEffect(() => { - if (atStart.current && row.current) row.current.scrollLeft = 0; - }, [children]); useEffect(() => { update(); const el = row.current; diff --git a/updates/latest.json b/updates/latest.json index 8289664..b8cdf27 100644 --- a/updates/latest.json +++ b/updates/latest.json @@ -1,11 +1,11 @@ { - "version": "1.0.1", - "notes": "A quicker start, a Stop button, and recovery when the server drops out mid-video.\r\n\r\n- Kaleido starts faster: the opening animation is shorter, so you reach your library in about a second.\r\n- The player has a Stop button, next to the forward controls, which closes the player completely instead of moving it to the miniplayer.\r\n- If your Plex server goes down while you're watching, the player waits for it once the buffered video runs out, then carries on from the same spot when the server is back. Before, it treated the video as finished and Play started it again from the beginning. Pressing Play while it waits tries to reconnect straight away.", - "pub_date": "2026-11-17T17:47:20.996Z", + "version": "0.1.0-beta.16", + "notes": "- Simplify playback settings: group intro, credits and skip-delay choices together, show the delay only when automatic skipping is enabled, and combine the next-episode switch and countdown into one Off / After … seconds selection. Existing preferences are preserved.\n- Make Up Next readable over bright artwork with a dark backdrop across the page, brighter secondary text and larger synopsis and autoplay hints. The playing video stays at its original brightness.", + "pub_date": "2026-11-12T06:51:10.050Z", "platforms": { "windows-x86_64": { - "signature": "dW50cnVzdGVkIGNvbW1lbnQ6IHNpZ25hdHVyZSBmcm9tIHRhdXJpIHNlY3JldCBrZXkKUlVST1RiNHdFVm01NFZMQVRPVll0SHZPQWJWUlIyQnZEME10bldKUnYxSkhHWEJSWWxOT3FoVHp6NlNsU0dwdlg1UmUweGlEdzNoQnduSnora0dZempZS2ZWdFZLa3BIRkFJPQp0cnVzdGVkIGNvbW1lbnQ6IHRpbWVzdGFtcDoxNzk0OTM3NjI5CWZpbGU6S2FsZWlkb18xLjAuMV94NjQtc2V0dXAuZXhlCXZlcnNpb246MS4wLjEKeUI5aUJ4d3hONmVlNlBBWDFxQkFkYTV4WXU0eHIzb1ZKaVZjaDhpODhpbXdvL2RWRlhTRTBwQXJGV3hJYlg2RERnMDBhSFBRWHZDekxCRTVNNCtIRFE9PQo=", - "url": "https://git.elijahkuntz.com/Elijah/Kaleido-Desktop/releases/download/v1.0.1/Kaleido_1.0.1_x64-setup.exe" + "signature": "dW50cnVzdGVkIGNvbW1lbnQ6IHNpZ25hdHVyZSBmcm9tIHRhdXJpIHNlY3JldCBrZXkKUlVST1RiNHdFVm01NFRWYUFBcFRudUhuVmx4eDZSb0RxUGlhOFF1Qi9kOU5STDJTbEJZb2dNYmExeGk3Tll0WXZ3bVEwMjlxRFlMODVOOHlYdHRyY3FoSm54VGpyYTMvOVFJPQp0cnVzdGVkIGNvbW1lbnQ6IHRpbWVzdGFtcDoxNzk0NDY2MjUxCWZpbGU6S2FsZWlkb18wLjEuMC1iZXRhLjE2X3g2NC1zZXR1cC5leGUJdmVyc2lvbjowLjEuMC1iZXRhLjE2CjZwRmRuSU56am8xN3hUbThyVXFac3E4TjhOVmFDek4rS3UvS1duOWlFQ3J1bThWQ21Oa0ZDTGVpTXRPclQrdC9FUCtuenFzM0llKytiUm4xQndsRENRPT0K", + "url": "https://git.elijahkuntz.com/Elijah/Kaleido-Desktop/releases/download/v0.1.0-beta.16/Kaleido_0.1.0-beta.16_x64-setup.exe" } } }