diff --git a/web-player/src/lib/components/player/PlayerBar.svelte b/web-player/src/lib/components/player/PlayerBar.svelte
index 3b14356..27ff684 100644
--- a/web-player/src/lib/components/player/PlayerBar.svelte
+++ b/web-player/src/lib/components/player/PlayerBar.svelte
@@ -6,7 +6,9 @@
import { player } from '$lib/player/player.svelte';
import { queuePanel } from '$lib/player/queuePanel.svelte';
import { fmtTime } from '$lib/utils/format';
+ import Volume1 from '@lucide/svelte/icons/volume-1';
import Volume2 from '@lucide/svelte/icons/volume-2';
+ import VolumeX from '@lucide/svelte/icons/volume-x';
import ListMusic from '@lucide/svelte/icons/list-music';
function seek(value: number) {
@@ -48,9 +50,22 @@
-
+
player.toggleMute()}
+ >
+ {#if player.muted || player.volume === 0}
+
+ {:else if player.volume < 50}
+
+ {:else}
+
+ {/if}
+
player.setVolume(value)}
diff --git a/web-player/src/lib/player/player.svelte.ts b/web-player/src/lib/player/player.svelte.ts
index e34af4c..dbf6927 100644
--- a/web-player/src/lib/player/player.svelte.ts
+++ b/web-player/src/lib/player/player.svelte.ts
@@ -119,6 +119,7 @@ class PlayerState {
playing = $state(false);
progress = $state(0);
volume = $state(browser ? Number(localStorage.getItem('player.volume') ?? 100) : 100);
+ muted = $state(browser ? localStorage.getItem('player.muted') === 'true' : false);
loading = $state(false);
recentlyPlayed = $state([]);
playlists = $state([]);
@@ -148,6 +149,7 @@ class PlayerState {
const audio = new Audio();
audio.preload = 'auto';
audio.volume = this.volume / 100;
+ audio.muted = this.muted;
audio.addEventListener('durationchange', () => this.#syncDuration(audio.duration));
audio.addEventListener('loadedmetadata', () => this.#syncDuration(audio.duration));
audio.addEventListener('play', () => {
@@ -401,6 +403,18 @@ class PlayerState {
else audio.pause();
}
+ toggleMute() {
+ this.#applyMuted(!this.muted);
+ if (!this.muted && this.volume === 0) this.setVolume(50);
+ }
+
+ #applyMuted(value: boolean) {
+ this.muted = value;
+ const audio = this.#audioEl();
+ if (audio) audio.muted = value;
+ if (browser) localStorage.setItem('player.muted', String(value));
+ }
+
next() {
if (this.tracks.length === 0) return;
const idx = this.#index();
@@ -459,6 +473,7 @@ class PlayerState {
setVolume(value: number) {
this.volume = Math.min(100, Math.max(0, Math.round(value)));
+ if (this.muted && this.volume > 0) this.#applyMuted(false);
const audio = this.#audioEl();
if (audio) {
audio.volume = this.volume / 100;