fix(player): show mute in the volume indicator
Muting does not change the volume level, and VolumeChanged carried nothing but that level — so pressing M silenced playback and left the indicator showing the volume it still had. The UI had nothing to react to. Mute rides on its own event rather than widening the volume payload, since the two are genuinely independent: a muted player at 40% is a different state from a player at 0%, and only one of them comes back when you unmute. The icon crosses out and dims, and the popup gains an explicit Mute/Unmute so the keyboard shortcut is not the only way in. MuteToggle also now takes the speaker lock (it was mutating the effects chain from outside it) and refuses politely rather than dereferencing a nil streamer when nothing has been loaded yet.
This commit is contained in:
1 parent
c48123f7a3
commit
0ca37a31a6
10 files changed
+154
-4
No files matched your search
@@ -28,6 +28,7 @@ export interface PlayerState {
|
||||
isPlaying: boolean;
|
||||
currentTrack: TrackInfo | null;
|
||||
volume: number; // 0-100
|
||||
muted: boolean; // silenced independently of the volume level
|
||||
|
||||
// Frontend-only state (for future use)
|
||||
// selectedTrackIds: Set<number>;
|
||||
@@ -41,6 +42,7 @@ class PlayerStore {
|
||||
isPlaying: false,
|
||||
currentTrack: null,
|
||||
volume: 50,
|
||||
muted: false,
|
||||
};
|
||||
|
||||
private subscribers = new Set<Subscriber>();
|
||||
@@ -72,6 +74,10 @@ class PlayerStore {
|
||||
EventsOn(Events.VolumeChanged, (volume: number) => {
|
||||
this.update({ volume });
|
||||
});
|
||||
|
||||
EventsOn(Events.MuteChanged, (muted: boolean) => {
|
||||
this.update({ muted });
|
||||
});
|
||||
}
|
||||
|
||||
// ===================================================================
|
||||
@@ -103,6 +109,10 @@ class PlayerStore {
|
||||
Player.SetVolume(level);
|
||||
}
|
||||
|
||||
toggleMute(): void {
|
||||
void Player.MuteToggle();
|
||||
}
|
||||
|
||||
// ===================================================================
|
||||
// SUBSCRIPTION SYSTEM
|
||||
// ===================================================================
|
||||
|
||||
Reference in new issue
Block a user