How to get Microphone privacy setting programmatically

Vijay Gawli 21 Reputation points

Is there way to get the Microphone privacy setting pro-grammatically - ?

Universal Windows Platform (UWP)
0 comments No comments
{count} votes

Accepted answer
  1. Fay Wang - MSFT 5,196 Reputation points


    ​Welcome to our Microsoft Q&A platform!

    If you want to get the Microphone setting for the entire computer, there is no api can achieve it in UWP.

    But if you want to get microphone permission status for your app, it is feasible.

    First you need to accept the Microsoft Privacy Policy granting permission for your app to use it. Set the Microphone device capability in the manifest file and when run the app, it will show a system dialog requesting permission about Microphone, clicks Yes and then your app has access to the microphone. In that case, you can try the following code to check if Microphone is disable. If microphone permission is off, then the method will throw System.UnauthorizedAccessException, you can set IsMicAvailable as false when catching the exception.

    bool IsMicAvailable = true;
            MediaCapture mediaCapture = new MediaCapture();
            var settings = new MediaCaptureInitializationSettings();
            settings.StreamingCaptureMode = StreamingCaptureMode.Audio;
            await mediaCapture.InitializeAsync(settings);
        catch (Exception exception)
            IsMicAvailable = false;
        if (IsMicAvailable)
            //do something
            //do something

0 additional answers

Sort by: Most helpful