feat(frontend): persistent player volume

This commit is contained in:
2026-07-14 18:48:57 +02:00
parent 79119fe3fa
commit 92aec73b9d
2 changed files with 14 additions and 4 deletions
+7 -3
View File
@@ -48,10 +48,11 @@ class PlayerState {
currentId = $state<string | number | null>(null);
playing = $state(false);
progress = $state(0);
volume = $state(70);
volume = $state(
browser ? Number(localStorage.getItem("player.volume") ?? 100) : 100
);
loading = $state(false);
error = $state('');
recentlyPlayed = $state<PlayerTrack[]>([]);
playlists = $state<Playlist[]>([]);
@@ -274,7 +275,10 @@ class PlayerState {
setVolume(value: number) {
this.volume = Math.min(100, Math.max(0, Math.round(value)));
const audio = this.#audioEl();
if (audio) audio.volume = this.volume / 100;
if (audio) {
audio.volume = this.volume / 100;
localStorage.setItem("player.volume", String(this.volume));
}
}
}