NAudio icon indicating copy to clipboard operation
NAudio copied to clipboard

Not receiving OnVolumeNotification notifications

Open AriDeve opened this issue 3 years ago • 2 comments

var devEnum = new MMDeviceEnumerator();
foreach (var device in devEnum.EnumerateAudioEndPoints(DataFlow.Capture, DeviceState.Active))
{
    device.AudioEndpointVolume.OnVolumeNotification += data => {Debug.WriteLine(data.Muted);};
}

OnVolumeNotification doesn't produce a notification when changing the device volume or muted status in my project, even when the device has been enumerated over. Oddly enough, same code seems to work in a new project. Is there something that I have missed and should look out for, perhaps using only a single enumerator, since I have another one elsewhere, or do the notifications reset when enumerating a second time, or something similar?

AriDeve avatar Oct 27 '22 11:10 AriDeve

I had this issue. In my case it was the device object being disposed. Keeping a reference to the object fixed it.

juanmalm avatar Sep 01 '23 10:09 juanmalm

I had this issue. In my case it was the device object being disposed. Keeping a reference to the object fixed it.

Thank you for the reply, been a while since I had to deal with this issue, by now it isn't as relevant so I cannot confirm this in the moment, but I'll definitely check it out eventually!

AriDeve avatar Sep 01 '23 11:09 AriDeve