Release Kaleido Desktop 0.1.0-beta.10
All checks were successful
Validate Kaleido Desktop / validate (push) Successful in 1m22s
All checks were successful
Validate Kaleido Desktop / validate (push) Successful in 1m22s
- Player controls centred under the timeline: previous episode, back 10 s, play/pause, forward 10 s, next episode; volume and time on the left. - Previous episode button and Shift+P. - Draggable miniplayer, kept inside the window and remembered. - Fix the next-episode card's buttons and the skip button being covered by the player's title row, and skip buttons also pausing playback. - Drop the "Highly rated"/"Recommended" label from the hero and restore the gap between its logo and the details line. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
10103d0e77
commit
a38db53161
15 changed files with 220 additions and 61 deletions
|
|
@ -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 (
|
||||
<button className="skip-button" onClick={() => seek(marker.end / 1000)}>
|
||||
<button
|
||||
className="skip-button"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
seek(marker.end / 1000);
|
||||
}}
|
||||
onDoubleClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
{marker.type === 'intro' ? 'Skip intro' : 'Skip credits'}
|
||||
<Icon name="skipNext" size={16} />
|
||||
</button>
|
||||
|
|
@ -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<HTMLDivElement>(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 (
|
||||
<div ref={box} className={`mini-player${loading || st.error ? ' loading' : ''}`} onDoubleClick={() => st.expand()}>
|
||||
<div ref={box} className={`mini-player${loading || st.error ? ' loading' : ''}`} onPointerDown={startDrag} onDoubleClick={() => st.expand()}>
|
||||
<div className="mini-scrim" />
|
||||
<div className="mini-top">
|
||||
<button className="mini-icon" aria-label="Back to full screen player" title="Expand" onClick={() => st.expand()}>
|
||||
|
|
@ -732,6 +824,11 @@ export function PlayerOverlay() {
|
|||
if (e.shiftKey && p.nextUp) p.playNext();
|
||||
else handled = false;
|
||||
break;
|
||||
case 'p':
|
||||
case 'P':
|
||||
if (e.shiftKey && p.prevUp) p.playPrevious();
|
||||
else handled = false;
|
||||
break;
|
||||
case 'u':
|
||||
case 'U': {
|
||||
const prefs = useSettings.getState();
|
||||
|
|
@ -887,25 +984,45 @@ export function PlayerOverlay() {
|
|||
<Timeline onScrub={setScrubbing} />
|
||||
<div className="player-controls">
|
||||
<div className="player-controls-left">
|
||||
<button className="player-icon big" aria-label={st.paused ? 'Play' : 'Pause'} onClick={() => st.togglePause()}>
|
||||
<Icon name={st.paused || st.ended ? 'play' : 'pause'} size={26} />
|
||||
</button>
|
||||
<button className="player-icon" aria-label="Back 10 seconds" onClick={() => st.seekBy(-10)}>
|
||||
<Icon name="replay10" size={24} />
|
||||
</button>
|
||||
<button className="player-icon" aria-label="Forward 10 seconds" onClick={() => st.seekBy(10)}>
|
||||
<Icon name="forward10" size={24} />
|
||||
</button>
|
||||
{st.nextUp && (
|
||||
<button className="player-icon" aria-label="Next episode" title={`Next: ${episodeLabel(st.nextUp)} ${st.nextUp.title}`} onClick={() => st.playNext()}>
|
||||
<Icon name="skipNext" size={22} />
|
||||
</button>
|
||||
)}
|
||||
<Volume />
|
||||
<span className="player-time">
|
||||
{clock(st.position, st.duration >= 3600)} <span className="dim">/ {clock(st.duration, st.duration >= 3600)}</span>
|
||||
</span>
|
||||
</div>
|
||||
<div className="player-controls-center">
|
||||
{/* Both episode buttons stay for episodes (dimmed at either end) so play/pause holds its place. */}
|
||||
{item.type === 'episode' && (
|
||||
<button
|
||||
className="player-icon"
|
||||
aria-label="Previous episode"
|
||||
title={st.prevUp ? `Previous: ${episodeLabel(st.prevUp)} ${st.prevUp.title}` : undefined}
|
||||
disabled={!st.prevUp}
|
||||
onClick={() => st.playPrevious()}
|
||||
>
|
||||
<Icon name="skipPrev" size={22} />
|
||||
</button>
|
||||
)}
|
||||
<button className="player-icon" aria-label="Back 10 seconds" onClick={() => st.seekBy(-10)}>
|
||||
<Icon name="replay10" size={24} />
|
||||
</button>
|
||||
<button className="player-icon big" aria-label={st.paused ? 'Play' : 'Pause'} onClick={() => st.togglePause()}>
|
||||
<Icon name={st.paused || st.ended ? 'play' : 'pause'} size={28} />
|
||||
</button>
|
||||
<button className="player-icon" aria-label="Forward 10 seconds" onClick={() => st.seekBy(10)}>
|
||||
<Icon name="forward10" size={24} />
|
||||
</button>
|
||||
{item.type === 'episode' && (
|
||||
<button
|
||||
className="player-icon"
|
||||
aria-label="Next episode"
|
||||
title={st.nextUp ? `Next: ${episodeLabel(st.nextUp)} ${st.nextUp.title}` : undefined}
|
||||
disabled={!st.nextUp}
|
||||
onClick={() => st.playNext()}
|
||||
>
|
||||
<Icon name="skipNext" size={22} />
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
<div className="player-controls-right">
|
||||
<button className={`player-icon${panel === 'tracks' ? ' on' : ''}${st.subKey ? ' lit' : ''}`} aria-label="Audio and subtitles" onClick={() => setPanel(panel === 'tracks' ? '' : 'tracks')}>
|
||||
<Icon name="captions" size={23} />
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue