Is there way to get the Microphone privacy setting pro-grammatically - https://hub.mangoapps.com/sf/MjE3NjQ1XzE5NjI1OTM ?
Is there way to get the Microphone privacy setting pro-grammatically - https://hub.mangoapps.com/sf/MjE3NjQ1XzE5NjI1OTM ?
Hello,
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;
try
{
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
}
else
{
//do something
}
}
Hello,
Thank you for the solution. Yes, its solve my 80% issue.
Is there any way to detect the setting "Allow desktop apps to access your microphone" - https://hub.mangoapps.com/sf/MjE3ODIyXzE5NjI4OTI ?
Nope, you can't detect the setting "Allow desktop apps to access your microphone" in uwp, but can get microphone permission status for your app.
Thank you for your valuable response.
Can you please share the solution if you have to get microphone permission status for your app?
Thank you once again.
10 people are following this question.
How to write and read multiple types of data using Data Writer and Data Reader
Consuming UWP mail api from WPF Desktop Bridge App
Get Network usage information in UWP apps
How to Get/Set Cookies in Windows.Web.Http API
Switch the ListView Datatemplate from one data template to another data template?