2017-06-29 13 views
2

私はUWPアプリケーションでカメラにアクセスしようとするが、私はエラーを持っている:ここではMediaCaptureを使用してUWPアプリケーションでカメラにアクセスするにはどうすればよいですか?

Exception thrown: 'System.UnauthorizedAccessException' in mscorlib.ni.dll 
WinRT information: Access is denied. 

The app was denied access to the camera 
The thread 0x2c9c has exited with code 0 (0x0). 
The program '[3352] CameraGetPreviewFrame.exe' has exited with code 1 (0x1). 

は私のコードは次のとおりです。

if (cameraDevice == null) 
{ 
    Debug.WriteLine("No camera device found!"); 
    return; 
} 

// Create MediaCapture and its settings 
_mediaCapture = new MediaCapture(); 

// Register for a notification when something goes wrong 
_mediaCapture.Failed += MediaCapture_Failed; 

var settings = new MediaCaptureInitializationSettings { VideoDeviceId = cameraDevice.Id }; 

// Initialize MediaCapture 
try 
{ 
    await _mediaCapture.InitializeAsync(settings); 
    _isInitialized = true; 
} 
catch (UnauthorizedAccessException) 
{ 
    Debug.WriteLine("The app was denied access to the camera"); 
} 

例外が発生した理由を私に説明してもらえますし、どのように解決するために問題?

答えて

3

あなたのプロジェクトには、マイクとウェブカムの能力を設定する必要があります。これを行うには、機能タブ

  • チェックマイクウェブカメラ
    1. オープンPackage.appxmanifest
    2. ゴー、以下の手順に従うことができます
    関連する問題