T-021: Player-Leiste — Cover, Titel/Kapitel, Kapitel vor/zurück, ±30 s, Play/Pause, Zeitanzeige, ScrubBar, Abspielen-Button auf lokalen Cards, Asset-Protocol für Cover

This commit is contained in:
2026-11-06 20:28:26 +01:00
parent 4a1cc24da8
commit 8339189d0a
8 changed files with 193 additions and 4 deletions

View File

@ -8,6 +8,15 @@
trash:
'<path d="M4 7h16"/><path d="M9 7V4h6v3"/><path d="M6.5 7l1 14h9l1-14"/>',
play: '<path d="M8 5v14l11-7z" fill="currentColor" stroke="none"/>',
nextch:
'<path d="m5 4 10 8-10 8V4z"/><path d="M19 5v14"/>',
prevch:
'<path d="M19 20 9 12l10-8v16z"/><path d="M5 19V5"/>',
pause: '<path d="M9 5v14"/><path d="M15 5v14"/>',
rewind:
'<path d="m11 18-6-6 6-6"/><path d="m19 18-6-6 6-6"/>',
forward:
'<path d="m4 6 6 6-6 6"/><path d="m13 6 6 6-6 6"/>',
check: '<path d="M4 12l5 5L20 6"/>',
pencil:
'<path d="M4 20h4L20 8l-4-4L4 16v4z"/><path d="M13.5 6.5l4 4"/>',

View File

@ -31,6 +31,48 @@ export const getAlterNotes = () => invoke<Record<string, string>>('get_alter_not
export const setAlterNote = (asin: string, note: string | null) =>
invoke<void>('set_alter_note', { asin, note })
import { convertFileSrc } from '@tauri-apps/api/core'
export interface PChapter {
title: string
start: number
end: number
}
export interface PlayerState {
loaded: boolean
playing: boolean
position: number
duration: number
chapter: number
chapters: PChapter[]
speed: number
asin: string | null
title: string | null
cover: string | null
}
export const playerLoad = (asin: string, title: string) =>
invoke<PlayerState>('player_load', { asin, title })
export const playerToggle = () => invoke<PlayerState>('player_toggle')
export const playerSeek = (secs: number) => invoke<PlayerState>('player_seek', { secs })
export const playerSetPosition = (pos: number) =>
invoke<PlayerState>('player_set_position', { pos })
export const playerSetChapter = (idx: number) =>
invoke<PlayerState>('player_set_chapter', { idx })
export const playerStop = () => invoke<PlayerState>('player_stop')
export const playerSnapshot = () => invoke<PlayerState>('player_snapshot')
export const onPlayerState = (cb: (s: PlayerState) => void) =>
listen<PlayerState>('player-state', (ev) => cb(ev.payload))
export const assetUri = (path: string) => convertFileSrc(path)
export function fmtClock(sec: number): string {
const t = Math.max(0, Math.floor(sec))
const h = Math.floor(t / 3600)
const m = Math.floor((t % 3600) / 60)
const s = t % 60
return h > 0 ? `${h}:${String(m).padStart(2, '0')}:${String(s).padStart(2, '0')}` : `${m}:${String(s).padStart(2, '0')}`
}
export interface DlItem {
asin: string
status: 'queued' | 'running' | 'decrypting' | 'done' | 'failed' | 'cancelled'