如何停止需要麦克风权限的 UWP Camera
How do I stop UWP Camera requiring permission to the Microphone
所以我在我的 Surface Pro 设备上的 UWP 应用程序中初始化一个 MediaCapture
元素,如下所示:
// Create MediaCapture and its settings
mediaCapture = new MediaCapture();
var mediaInitSettings = new MediaCaptureInitializationSettings
{
VideoDeviceId = cameraDevice.Id,
AudioDeviceId = string.Empty,
//StreamingCaptureMode = StreamingCaptureMode.Video,
//PhotoCaptureSource = PhotoCaptureSource.Photo
};
// Initialize MediaCapture
try
{
await mediaCapture.InitializeAsync(mediaInitSettings);
....
}
在第 InitializeAsync
行,应用程序要求摄像头和麦克风功能。
现在我不需要麦克风功能,因为我只拍摄照片,我的许多用户拒绝访问麦克风说 "Why do you need microphone access to take a photo"
我使用内置的 "Camera" 应用程序进行了测试,并在 windows 上拒绝了对麦克风的许可,这非常有效。
我查看了 documentation,上面写着:
InitializeAsync will launch a consent prompt to get the user's
permission for the app to access the microphone or camera
那么是否可以停止请求麦克风权限的应用程序?
好的,我设法通过更改 MediaCaptureInitializationSettings
上的 StreamingCaptureMode
添加以下行来轻松解决它:
StreamingCaptureMode = StreamingCaptureMode.Video
所以变成了:
var mediaInitSettings = new MediaCaptureInitializationSettings
{
VideoDeviceId = cameraDevice.Id,
AudioDeviceId = string.Empty,
StreamingCaptureMode = StreamingCaptureMode.Video,
};
所以我在我的 Surface Pro 设备上的 UWP 应用程序中初始化一个 MediaCapture
元素,如下所示:
// Create MediaCapture and its settings
mediaCapture = new MediaCapture();
var mediaInitSettings = new MediaCaptureInitializationSettings
{
VideoDeviceId = cameraDevice.Id,
AudioDeviceId = string.Empty,
//StreamingCaptureMode = StreamingCaptureMode.Video,
//PhotoCaptureSource = PhotoCaptureSource.Photo
};
// Initialize MediaCapture
try
{
await mediaCapture.InitializeAsync(mediaInitSettings);
....
}
在第 InitializeAsync
行,应用程序要求摄像头和麦克风功能。
现在我不需要麦克风功能,因为我只拍摄照片,我的许多用户拒绝访问麦克风说 "Why do you need microphone access to take a photo"
我使用内置的 "Camera" 应用程序进行了测试,并在 windows 上拒绝了对麦克风的许可,这非常有效。
我查看了 documentation,上面写着:
InitializeAsync will launch a consent prompt to get the user's permission for the app to access the microphone or camera
那么是否可以停止请求麦克风权限的应用程序?
好的,我设法通过更改 MediaCaptureInitializationSettings
上的 StreamingCaptureMode
添加以下行来轻松解决它:
StreamingCaptureMode = StreamingCaptureMode.Video
所以变成了:
var mediaInitSettings = new MediaCaptureInitializationSettings
{
VideoDeviceId = cameraDevice.Id,
AudioDeviceId = string.Empty,
StreamingCaptureMode = StreamingCaptureMode.Video,
};