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:
@ -30,8 +30,8 @@ Abnahme M0: Ein gekauftes Buch läuft lokal mit Kapiteln.
|
||||
|
||||
| ID | Titel | Status |
|
||||
|----|-------|--------|
|
||||
| T-020 | Playback-Engine wählen und einbauen (Entscheidung E-01) | läuft |
|
||||
| T-021 | Play/Pause, Seek, Kapitelnavigation | offen |
|
||||
| T-020 | Playback-Engine wählen und einbauen (Entscheidung E-01) | fertig |
|
||||
| T-021 | Play/Pause, Seek, Kapitelnavigation | läuft |
|
||||
| T-022 | Wiedergabegeschwindigkeit (0.5–3.0×) | offen |
|
||||
| T-023 | Sleep-Timer | offen |
|
||||
| T-024 | Position pro Buch lokal speichern, beim Start fortsetzen | offen |
|
||||
|
||||
7
src-tauri/Cargo.lock
generated
7
src-tauri/Cargo.lock
generated
@ -1479,6 +1479,12 @@ dependencies = [
|
||||
"pin-project-lite",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "http-range"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2149c4b4b83390c71fab669730347d578ec6bdf759f2160c581ad8b8819733b4"
|
||||
|
||||
[[package]]
|
||||
name = "httparse"
|
||||
version = "1.10.1"
|
||||
@ -3371,6 +3377,7 @@ dependencies = [
|
||||
"gtk",
|
||||
"heck 0.5.0",
|
||||
"http",
|
||||
"http-range",
|
||||
"jni",
|
||||
"libc",
|
||||
"log",
|
||||
|
||||
@ -18,7 +18,7 @@ crate-type = ["staticlib", "cdylib", "rlib"]
|
||||
tauri-build = { version = "2", features = [] }
|
||||
|
||||
[dependencies]
|
||||
tauri = { version = "2", features = [] }
|
||||
tauri = { version = "2", features = ["protocol-asset"] }
|
||||
tauri-plugin-opener = "2"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
|
||||
@ -18,7 +18,11 @@
|
||||
}
|
||||
],
|
||||
"security": {
|
||||
"csp": null
|
||||
"csp": null,
|
||||
"assetProtocol": {
|
||||
"enable": true,
|
||||
"scope": ["$HOME/.local/share/hoerwerk/**"]
|
||||
}
|
||||
}
|
||||
},
|
||||
"bundle": {
|
||||
|
||||
@ -4,6 +4,17 @@
|
||||
startLogin,
|
||||
startDecrypt,
|
||||
getLibrary,
|
||||
playerLoad,
|
||||
playerToggle,
|
||||
playerSeek,
|
||||
playerSetPosition,
|
||||
playerSetChapter,
|
||||
playerStop,
|
||||
playerSnapshot,
|
||||
onPlayerState,
|
||||
fmtClock,
|
||||
assetUri,
|
||||
type PlayerState,
|
||||
getLocalBooks,
|
||||
getStreamOnly,
|
||||
getAlterNotes,
|
||||
@ -37,6 +48,18 @@
|
||||
let loadedOverride = $state<Record<string, boolean>>({})
|
||||
let removedLocals = $state<Record<string, boolean>>({})
|
||||
let streamOnly = $state<Record<string, boolean>>({})
|
||||
let player = $state<PlayerState>({
|
||||
loaded: false,
|
||||
playing: false,
|
||||
position: 0,
|
||||
duration: 0,
|
||||
chapter: -1,
|
||||
chapters: [],
|
||||
speed: 1,
|
||||
asin: null,
|
||||
title: null,
|
||||
cover: null,
|
||||
})
|
||||
let alterNotes = $state<Record<string, string>>({})
|
||||
let editingAlter = $state<string | null>(null)
|
||||
let alterDraft = $state('')
|
||||
@ -278,6 +301,10 @@
|
||||
|
||||
// Beim Start: auth prüfen, Download-Events abonnieren, Abstammung + Abgleich.
|
||||
$effect(() => {
|
||||
playerSnapshot().then((s) => (player = s)).catch(() => {})
|
||||
const unlistenPlayer = onPlayerState((st) => {
|
||||
player = st
|
||||
})
|
||||
checkAuth()
|
||||
const unlisten = onDownloadUpdate((it) => {
|
||||
downloads = { ...downloads, [it.asin]: it }
|
||||
@ -300,6 +327,7 @@
|
||||
clearPoll()
|
||||
clearInterval(syncId)
|
||||
unlisten.then((f) => f())
|
||||
unlistenPlayer.then((f) => f())
|
||||
}
|
||||
})
|
||||
|
||||
@ -482,5 +510,37 @@
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if player.loaded}
|
||||
<footer class="playerbar">
|
||||
{#if player.cover}
|
||||
<img class="barcover" src={assetUri(player.cover)} alt="" />
|
||||
{/if}
|
||||
<div class="barmeta">
|
||||
<div class="bt">{player.title ?? ''}</div>
|
||||
<div class="muted small">
|
||||
{player.chapters[player.chapter]?.title ?? (player.chapters.length ? '' : '')}
|
||||
</div>
|
||||
</div>
|
||||
<div class="barctrl">
|
||||
<button class="ghost" title="Kapitel zurück" disabled={player.chapter <= 0} onclick={() => playerSetChapter(Math.max(0, player.chapter - 1))}><Icon name="prevch" /></button>
|
||||
<button class="ghost" title="30 s zurück" onclick={() => playerSeek(-30)}><Icon name="rewind" /></button>
|
||||
<button class="primary" title={player.playing ? 'Pause' : 'Abspielen'} onclick={() => playerToggle()}><Icon name={player.playing ? 'pause' : 'play'} size={18} /></button>
|
||||
<button class="ghost" title="30 s vor" onclick={() => playerSeek(30)}><Icon name="forward" /></button>
|
||||
<button class="ghost" title="Kapitel vor" onclick={() => playerSetChapter(player.chapter + 1)}><Icon name="nextch" /></button>
|
||||
</div>
|
||||
<span class="mtime muted small">{fmtClock(player.position)} / {fmtClock(player.duration)}</span>
|
||||
<input
|
||||
class="seek"
|
||||
type="range"
|
||||
min="0"
|
||||
max={player.duration}
|
||||
step="1"
|
||||
value={player.position}
|
||||
onchange={(e) => playerSetPosition(Number(e.currentTarget.value))}
|
||||
/>
|
||||
<button class="ghost" title="Schließen" onclick={() => playerStop()}><Icon name="x" /></button>
|
||||
</footer>
|
||||
{/if}
|
||||
</main>
|
||||
{/if}
|
||||
|
||||
67
src/app.css
67
src/app.css
@ -312,3 +312,70 @@ code {
|
||||
border-radius: 4px;
|
||||
padding: 0.05rem 0.3rem;
|
||||
}
|
||||
|
||||
/* Player-Leiste (T-021) */
|
||||
|
||||
.playerbar {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.8rem;
|
||||
padding: 0.6rem 1rem;
|
||||
background: var(--bg-card);
|
||||
border-top: 1px solid var(--border);
|
||||
z-index: 5;
|
||||
}
|
||||
|
||||
.paddingbottom main {
|
||||
padding-bottom: 4.6rem;
|
||||
}
|
||||
|
||||
.barcover {
|
||||
width: 52px;
|
||||
height: 52px;
|
||||
border-radius: 6px;
|
||||
object-fit: cover;
|
||||
background: var(--bg);
|
||||
flex: none;
|
||||
}
|
||||
|
||||
.barmeta {
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.barmeta .bt {
|
||||
font-weight: 600;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.barctrl {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.3rem;
|
||||
flex: none;
|
||||
}
|
||||
|
||||
.playerbar button {
|
||||
width: 2.4rem;
|
||||
height: 2.4rem;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.mtime {
|
||||
flex: none;
|
||||
}
|
||||
|
||||
.playerbar .seek {
|
||||
flex: 1;
|
||||
min-width: 6rem;
|
||||
accent-color: var(--accent);
|
||||
}
|
||||
|
||||
@ -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"/>',
|
||||
|
||||
@ -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'
|
||||
|
||||
Reference in New Issue
Block a user