more player improvements
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
import { browser } from "$app/environment";
|
import { browser } from "$app/environment";
|
||||||
import { onDestroy, onMount } from "svelte";
|
import { onDestroy, onMount } from "svelte";
|
||||||
import {
|
import {
|
||||||
|
clearQueue,
|
||||||
jumpToTrack,
|
jumpToTrack,
|
||||||
next,
|
next,
|
||||||
nowPlayingLabel,
|
nowPlayingLabel,
|
||||||
@@ -47,6 +48,7 @@
|
|||||||
Shuffle,
|
Shuffle,
|
||||||
SkipBack,
|
SkipBack,
|
||||||
SkipForward,
|
SkipForward,
|
||||||
|
Trash2,
|
||||||
Volume2,
|
Volume2,
|
||||||
X,
|
X,
|
||||||
} from "@lucide/svelte";
|
} from "@lucide/svelte";
|
||||||
@@ -267,6 +269,17 @@
|
|||||||
void syncAndAutoplay();
|
void syncAndAutoplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onClearQueueRequest() {
|
||||||
|
if (snap.queue.length === 0) return;
|
||||||
|
|
||||||
|
const ok = window.confirm(
|
||||||
|
"Clear the queue? This will remove all queued tracks.",
|
||||||
|
);
|
||||||
|
if (!ok) return;
|
||||||
|
|
||||||
|
clearQueue();
|
||||||
|
}
|
||||||
|
|
||||||
function formatTime(seconds: number) {
|
function formatTime(seconds: number) {
|
||||||
if (!Number.isFinite(seconds) || seconds < 0) return "0:00";
|
if (!Number.isFinite(seconds) || seconds < 0) return "0:00";
|
||||||
const s = Math.floor(seconds);
|
const s = Math.floor(seconds);
|
||||||
@@ -596,7 +609,13 @@
|
|||||||
<div class="mx-auto max-w-4xl space-y-3">
|
<div class="mx-auto max-w-4xl space-y-3">
|
||||||
<div class="flex flex-wrap items-center gap-2">
|
<div class="flex flex-wrap items-center gap-2">
|
||||||
<button
|
<button
|
||||||
class="inline-flex h-8 w-8 items-center justify-center rounded border"
|
class={[
|
||||||
|
"inline-flex h-8 w-8 items-center justify-center rounded border transition-colors",
|
||||||
|
snap.shuffleEnabled &&
|
||||||
|
"border-primary/40 bg-primary/10 text-primary",
|
||||||
|
]
|
||||||
|
.filter(Boolean)
|
||||||
|
.join(" ")}
|
||||||
type="button"
|
type="button"
|
||||||
onclick={() => toggleShuffle()}
|
onclick={() => toggleShuffle()}
|
||||||
aria-label={snap.shuffleEnabled ? "Shuffle on" : "Shuffle off"}
|
aria-label={snap.shuffleEnabled ? "Shuffle on" : "Shuffle off"}
|
||||||
@@ -605,7 +624,13 @@
|
|||||||
<Shuffle class="h-4 w-4" />
|
<Shuffle class="h-4 w-4" />
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
class="inline-flex h-8 w-8 items-center justify-center rounded border"
|
class={[
|
||||||
|
"inline-flex h-8 w-8 items-center justify-center rounded border transition-colors",
|
||||||
|
snap.wrapEnabled &&
|
||||||
|
"border-primary/40 bg-primary/10 text-primary",
|
||||||
|
]
|
||||||
|
.filter(Boolean)
|
||||||
|
.join(" ")}
|
||||||
type="button"
|
type="button"
|
||||||
onclick={() => toggleWrap()}
|
onclick={() => toggleWrap()}
|
||||||
aria-label={snap.wrapEnabled ? "Wrap on" : "Wrap off"}
|
aria-label={snap.wrapEnabled ? "Wrap on" : "Wrap off"}
|
||||||
@@ -614,6 +639,17 @@
|
|||||||
<Repeat class="h-4 w-4" />
|
<Repeat class="h-4 w-4" />
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
<button
|
||||||
|
class="inline-flex h-8 w-8 items-center justify-center rounded border"
|
||||||
|
type="button"
|
||||||
|
disabled={snap.queue.length === 0}
|
||||||
|
onclick={onClearQueueRequest}
|
||||||
|
aria-label="Clear queue"
|
||||||
|
title="Clear queue"
|
||||||
|
>
|
||||||
|
<Trash2 class="h-4 w-4" />
|
||||||
|
</button>
|
||||||
|
|
||||||
<label class="ml-auto flex items-center gap-2 text-sm">
|
<label class="ml-auto flex items-center gap-2 text-sm">
|
||||||
<span class="text-muted-foreground" aria-hidden="true">
|
<span class="text-muted-foreground" aria-hidden="true">
|
||||||
<Volume2 class="h-4 w-4" />
|
<Volume2 class="h-4 w-4" />
|
||||||
@@ -764,7 +800,13 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<button
|
<button
|
||||||
class="inline-flex h-8 w-8 items-center justify-center rounded border"
|
class={[
|
||||||
|
"inline-flex h-8 w-8 items-center justify-center rounded border transition-colors",
|
||||||
|
snap.shuffleEnabled &&
|
||||||
|
"border-primary/40 bg-primary/10 text-primary",
|
||||||
|
]
|
||||||
|
.filter(Boolean)
|
||||||
|
.join(" ")}
|
||||||
type="button"
|
type="button"
|
||||||
onclick={() => toggleShuffle()}
|
onclick={() => toggleShuffle()}
|
||||||
aria-label={snap.shuffleEnabled ? "Shuffle on" : "Shuffle off"}
|
aria-label={snap.shuffleEnabled ? "Shuffle on" : "Shuffle off"}
|
||||||
@@ -773,7 +815,13 @@
|
|||||||
<Shuffle class="h-4 w-4" />
|
<Shuffle class="h-4 w-4" />
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
class="inline-flex h-8 w-8 items-center justify-center rounded border"
|
class={[
|
||||||
|
"inline-flex h-8 w-8 items-center justify-center rounded border transition-colors",
|
||||||
|
snap.wrapEnabled &&
|
||||||
|
"border-primary/40 bg-primary/10 text-primary",
|
||||||
|
]
|
||||||
|
.filter(Boolean)
|
||||||
|
.join(" ")}
|
||||||
type="button"
|
type="button"
|
||||||
onclick={() => toggleWrap()}
|
onclick={() => toggleWrap()}
|
||||||
aria-label={snap.wrapEnabled ? "Wrap on" : "Wrap off"}
|
aria-label={snap.wrapEnabled ? "Wrap on" : "Wrap off"}
|
||||||
@@ -781,6 +829,17 @@
|
|||||||
>
|
>
|
||||||
<Repeat class="h-4 w-4" />
|
<Repeat class="h-4 w-4" />
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
<button
|
||||||
|
class="inline-flex h-8 w-8 items-center justify-center rounded border"
|
||||||
|
type="button"
|
||||||
|
disabled={snap.queue.length === 0}
|
||||||
|
onclick={onClearQueueRequest}
|
||||||
|
aria-label="Clear queue"
|
||||||
|
title="Clear queue"
|
||||||
|
>
|
||||||
|
<Trash2 class="h-4 w-4" />
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user