Skip to content

Commit

Permalink
Fix volume level on mute
Browse files Browse the repository at this point in the history
  • Loading branch information
bramhaag committed Jan 25, 2021
1 parent cd2ef3b commit 54e8008
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion VolumeLevelListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ public class VolumeLevelListener

public void Start()
{
new CoreAudioController().DefaultPlaybackDevice.VolumeChanged.Subscribe(e =>
var playbackDevice = new CoreAudioController().DefaultPlaybackDevice;
playbackDevice.MuteChanged.Subscribe(e =>
OnVolumeLevelChange?.Invoke(this,
new VolumeLevelEventArgs {Level = e.IsMuted ? 0 : (int) e.Device.Volume})
);

playbackDevice.VolumeChanged.Subscribe(e =>
OnVolumeLevelChange?.Invoke(this, new VolumeLevelEventArgs {Level = (int) e.Volume})
);
}
Expand Down

0 comments on commit 54e8008

Please sign in to comment.