我知道有很多关于这个问题的重复提问,但是,对我来说非常重要。我现在在Windows Phone 8.1 C#相机初始化方面遇到了麻烦。
async private void InitCamera_Click(object sender, RoutedEventArgs e)
{
captureManager = new MediaCapture();
await captureManager.InitializeAsync();
try
{
captureManager = new Windows.Media.Capture.MediaCapture();
await captureManager.InitializeAsync();
if (captureManager.MediaCaptureSettings.VideoDeviceId != "" && captureManager.MediaCaptureSettings.AudioDeviceId != "")
{
System.Diagnostics.Debug.WriteLine("Init successful");
captureManager.RecordLimitationExceeded += new Windows.Media.Capture.RecordLimitationExceededEventHandler(RecordLimitationExceeded);
captureManager.Failed += new Windows.Media.Capture.MediaCaptureFailedEventHandler(Failed);
}
else
{
System.Diagnostics.Debug.WriteLine("No Device");
}
}
catch (Exception exception)
{
System.Diagnostics.Debug.WriteLine("Exception raised!!!!:" + exception);
}
}
这是我用来初始化摄像机的代码,但由于某种原因,在Lumia 920上的
Windows.Media.Capture.MediaCapture()
构造函数调用失败,并显示System.UnauthorizedAccessException
,在模拟器上则显示访问冲突。我已经在Google上搜索了这个问题,但目前没有答案。有些人告诉我不仅需要启用网络摄像头,还需要启用麦克风,但这并没有解决我的问题。一切似乎都设置得很好,在应用程序清单中授予了所有访问权限。另外,如果你有一些关于如何使用摄像头拍照的好的、可行的示例/教程,请提供。