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:
@@ -79,6 +79,19 @@ describe('player store: playback state', () => {
|
||||
expect(playerStore.getState().volume).toBe(42);
|
||||
});
|
||||
|
||||
it('tracks mute separately from the volume level', () => {
|
||||
// Mute leaves the volume number alone, which is exactly why it
|
||||
// needs an event of its own: the indicator had nothing to react to.
|
||||
emit(Events.VolumeChanged, 42);
|
||||
emit(Events.MuteChanged, true);
|
||||
|
||||
expect(playerStore.getState()).toMatchObject({ volume: 42, muted: true });
|
||||
|
||||
emit(Events.MuteChanged, false);
|
||||
|
||||
expect(playerStore.getState().muted).toBe(false);
|
||||
});
|
||||
|
||||
it('replaces state rather than mutating it, so a saved reference is stable', () => {
|
||||
emit(Events.VolumeChanged, 10);
|
||||
const before = playerStore.getState();
|
||||
@@ -110,12 +123,14 @@ describe('player store: actions', () => {
|
||||
playerStore.loadTrack('/music/one.mp3');
|
||||
playerStore.seek(30);
|
||||
playerStore.setVolume(60);
|
||||
playerStore.toggleMute();
|
||||
|
||||
expect(calls().map((c) => c.path)).toEqual([
|
||||
'player.Player.Pause',
|
||||
'player.Player.LoadFile',
|
||||
'player.Player.Seek',
|
||||
'player.Player.SetVolume',
|
||||
'player.Player.MuteToggle',
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user