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:
@ -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}
|
||||
|
||||
Reference in New Issue
Block a user