diff --git a/CHANGELOG.md b/CHANGELOG.md index 561793e..7b83c7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # Changelog +## 0.1.0-beta.10 + +A redesigned player control bar, previous episode, and a movable miniplayer. + +- The player's controls are rearranged the way most media players lay them out: play/pause sits in the centre under the timeline, with 10-second skips either side and previous/next episode beyond those. Volume and the time are on the left; subtitles, settings and full screen stay on the right. +- New previous-episode button (and Shift+P) to go back an episode. For episodes both buttons always show, dimmed at the start or end of a show, so play/pause stays put. +- The miniplayer can be dragged anywhere in the window. It stays inside the window when it's resized, and remembers where you left it. +- Fixed: the Play now and Cancel buttons on the next-episode card during the credits couldn't be clicked (the player's title row covered them). The Skip intro/credits button had the same problem with tall show logos. +- Fixed: clicking Skip intro or Skip credits also paused the video. +- The featured titles at the top of Home, Movies and TV Shows no longer carry a "Highly rated" / "Recommended" label, and their logo has room above the details line instead of touching it. + ## 0.1.0-beta.9 Fixes for the Mac version. diff --git a/README.md b/README.md index 198e1d8..e0fcfb4 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ place (see [Architecture](docs/architecture.md)). Linux builds browse but don't | Enter / Space | Open / play | ↑ / ↓, wheel | Volume | | Menu or Shift+F10 | Title actions | F, double-click | Full screen | | Alt+← (⌘[) / mouse back | Back | C | Next subtitle | -| / | Focus search | Shift+N | Next episode | +| / | Focus search | Shift+P / N | Previous / next episode | | F11 (⌃⌘F) | Full screen | Esc | Exit full screen, then player | Keys in brackets are the macOS equivalents. diff --git a/package-lock.json b/package-lock.json index 01e5262..8f1a25f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "kaleido-desktop", - "version": "0.1.0-beta.9", + "version": "0.1.0-beta.10", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "kaleido-desktop", - "version": "0.1.0-beta.9", + "version": "0.1.0-beta.10", "dependencies": { "@fontsource-variable/inter": "^5.3.0", "@tanstack/react-query": "^5.105.0", diff --git a/package.json b/package.json index 17159e2..28e5543 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "kaleido-desktop", "private": true, - "version": "0.1.0-beta.9", + "version": "0.1.0-beta.10", "type": "module", "scripts": { "dev": "vite", diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 202e163..f013d0c 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -2173,7 +2173,7 @@ dependencies = [ [[package]] name = "kaleido" -version = "0.1.0-beta.9" +version = "0.1.0-beta.10" dependencies = [ "fs2", "futures-util", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 7aaed82..dd5ffab 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "kaleido" -version = "0.1.0-beta.9" +version = "0.1.0-beta.10" 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 013bdfe..abdfb41 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": "0.1.0-beta.9", + "version": "0.1.0-beta.10", "identifier": "tv.kaleido.desktop", "build": { "beforeDevCommand": "npm run dev", diff --git a/src/player/PlayerOverlay.tsx b/src/player/PlayerOverlay.tsx index 7beee7d..1930c88 100644 --- a/src/player/PlayerOverlay.tsx +++ b/src/player/PlayerOverlay.tsx @@ -1,4 +1,4 @@ -import { useCallback, useEffect, useRef, useState, type ReactNode } from 'react'; +import { useCallback, useEffect, useRef, useState, type PointerEvent as ReactPointerEvent, type ReactNode } from 'react'; import { usePlayer } from './store'; import { useSession } from '../app/session'; import { useSettings, QUALITY_LABEL, UPSCALING, type Quality, type SubtitleBox, type Upscaling } from '../app/settings'; @@ -512,7 +512,14 @@ function SkipButton() { if (!marker || mode === 'off' || countdown !== null) return null; if (marker.type === 'credits' && nextUp) return null; return ( - @@ -583,18 +590,62 @@ function TitleBlock({ item }: { item: Item }) { ); } +/** Where the miniplayer was dragged to: its distance from the window's right and bottom edges. */ +type MiniPos = { x: number; y: number }; +const MINI_POS_KEY = 'kaleido.miniPosition'; +const MINI_MARGIN = 8; +let miniPos: MiniPos | null | undefined; + +function savedMiniPos(): MiniPos | null { + if (miniPos === undefined) { + try { + const p = JSON.parse(localStorage.getItem(MINI_POS_KEY) ?? 'null'); + miniPos = p && Number.isFinite(p.x) && Number.isFinite(p.y) ? p : null; + } catch { + miniPos = null; + } + } + return miniPos ?? null; +} + +/** Keeps the whole box inside the window. */ +function clampMini(el: HTMLElement, pos: MiniPos): MiniPos { + const cs = getComputedStyle(el); + const maxX = window.innerWidth - parseFloat(cs.width) - MINI_MARGIN; + const maxY = window.innerHeight - parseFloat(cs.height) - MINI_MARGIN; + return { x: Math.round(Math.max(MINI_MARGIN, Math.min(maxX, pos.x))), y: Math.round(Math.max(MINI_MARGIN, Math.min(maxY, pos.y))) }; +} + +/** The box and the page's hole for the video (base.css) both follow these. */ +function applyMiniPos(pos: MiniPos | null) { + const root = document.documentElement.style; + if (!pos) { + root.removeProperty('--mini-x'); + root.removeProperty('--mini-y'); + return; + } + root.setProperty('--mini-x', `${pos.x}px`); + root.setProperty('--mini-y', `${pos.y}px`); +} + /** - * 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`). + * Playing in the corner while browsing, and draggable anywhere in the window. + * 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(null); + const placeVideo = useRef(() => {}); useEffect(() => { const el = box.current; if (!el) return; let frame = 0; + const fit = () => { + const saved = savedMiniPos(); + applyMiniPos(saved && clampMini(el, saved)); + }; const place = () => { cancelAnimationFrame(frame); frame = requestAnimationFrame(() => { @@ -610,23 +661,64 @@ function MiniPlayer() { if (isNative) mpv.rect({ x: x * dpr - 1, y: y * dpr - 1, width: width * dpr + 2, height: height * dpr + 2 }).catch(() => {}); }); }; - place(); + placeVideo.current = place; + const onResize = () => { + fit(); + place(); + }; + onResize(); const ro = new ResizeObserver(place); ro.observe(el); - window.addEventListener('resize', place); + window.addEventListener('resize', onResize); return () => { cancelAnimationFrame(frame); ro.disconnect(); - window.removeEventListener('resize', place); + window.removeEventListener('resize', onResize); }; }, []); + const startDrag = (e: ReactPointerEvent) => { + const el = box.current; + if (e.button !== 0 || !el) return; + const cs = getComputedStyle(el); + const start = { px: e.clientX, py: e.clientY, x: parseFloat(cs.right), y: parseFloat(cs.bottom) }; + let dragging = false; + const move = (ev: PointerEvent) => { + const dx = ev.clientX - start.px; + const dy = ev.clientY - start.py; + if (!dragging && Math.hypot(dx, dy) < 5) return; + dragging = true; + el.classList.add('dragging'); + miniPos = clampMini(el, { x: start.x - dx, y: start.y - dy }); + applyMiniPos(miniPos); + placeVideo.current(); + }; + const up = () => { + window.removeEventListener('pointermove', move); + window.removeEventListener('pointerup', up); + window.removeEventListener('pointercancel', up); + if (!dragging) return; + el.classList.remove('dragging'); + localStorage.setItem(MINI_POS_KEY, JSON.stringify(miniPos)); + // Letting go after a drag isn't a click on the button under the pointer. + const swallow = (c: MouseEvent) => { + c.stopPropagation(); + c.preventDefault(); + }; + window.addEventListener('click', swallow, { capture: true, once: true }); + setTimeout(() => window.removeEventListener('click', swallow, { capture: true }), 0); + }; + window.addEventListener('pointermove', move); + window.addEventListener('pointerup', up); + window.addEventListener('pointercancel', up); + }; + 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 ( -
st.expand()}> +
st.expand()}>
- - - {st.nextUp && ( - - )} {clock(st.position, st.duration >= 3600)} / {clock(st.duration, st.duration >= 3600)}
+
+ {/* Both episode buttons stay for episodes (dimmed at either end) so play/pause holds its place. */} + {item.type === 'episode' && ( + + )} + + + + {item.type === 'episode' && ( + + )} +