[UWP] Get the event of disable microphone of device

Md. Niaz Mahmud 171 Reputation points
2022-03-16T08:35:26.447+00:00

Can we get the event of disabling microphone from device manager or somewhere else into app in runtime? Or, disconnecting microphone from device event?

Universal Windows Platform (UWP)
{count} votes

Accepted answer
  1. Nico Zhu (Shanghai Wicresoft Co,.Ltd.) 12,861 Reputation points
    2022-03-17T03:06:24.08+00:00

    Hello,
    Welcome to Microsoft Q&A!

    Can we get the event of disabling microphone from device manager

    Sure, you could use DeviceWatcher to detect this, if you disable microphone device , DeviceWatcher Removed event will be triggered.

    For example

    var watcher = DeviceInformation.CreateWatcher(DeviceClass.AudioCapture);  
    watcher.Updated += Watcher_Updated;  
    watcher.Added += Watcher_Added;  
    watcher.Removed += Watcher_Removed;  
    watcher.Start();  
    
    
    private void Watcher_Removed(DeviceWatcher sender, DeviceInformationUpdate args)  
    {  
        // will be triggered when disable audio capture device.   
    }  
    
    private void Watcher_Added(DeviceWatcher sender, DeviceInformation args)  
    {  
    
    }  
    

    Nico


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful