locked
Access being denied to webcam - UWP app RRS feed

Answers

  • Dear friend,

    It is confirmed that it is an issue on the latest Insider build 17035. And the Webcam works fine on Build 16299.

    Please refer to this post on forum:

    https://social.msdn.microsoft.com/Forums/en-US/b76d8cf6-6b91-43d9-a742-aa5af7c4f941/mediacapture-initializeasync-fails?forum=WindowsIoT


    Keep Fighting

    • Marked as answer by AwAw123 Friday, February 16, 2018 6:37 PM
    Tuesday, January 23, 2018 2:58 AM
  • Hello AwAw123,

    You can go to Settings->Privacy->Camera make sue "Let apps use my camera hardware" is "On" like this:


    And you can enable the specified app(like the WebCameraApp) to use your camera like this:

    Best regards,

    Rita


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Monday, January 22, 2018 7:44 AM
  • Hi AwAw123,

    Thank you for your feedback.

    According to the error message, the windows deny the operation. did you try to use the administrator to run the application?

    As far as i know that the sample is about iot, i think that the sample should be used on iot device.  i am not sure whether it can run on Laptop 

    You can see my capture to turn on the option. 

    Best Regards,

    Hart


    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by AwAw123 Friday, February 16, 2018 6:37 PM
    Monday, January 22, 2018 8:04 AM

All replies

  • I am trying to follow the tutorial here: https://developer.microsoft.com/en-us/windows/iot/samples/webcamapp

    I downloaded the solution from https://github.com/Microsoft/Windows-iotcore-samples/tree/develop/Samples/WebcamApp

    and compiled it as a debug, x64 app (later as x86 as well) and ran it. Everything was fine, but when I click Initialize Audio/Video button, the status text says: Unable to initialize camera for audio/video mode: Access is denied.

    While in the debug log it says:

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

    I have webcam, microphone, Pictures Library and Videos Library enabled.

    Any ideas regarding what might be happening? Thank you.



    • Edited by AwAw123 Friday, January 19, 2018 11:51 PM Updated links
    • Merged by Hart Wang Wednesday, January 24, 2018 3:08 AM duplicate
    Thursday, January 18, 2018 8:44 PM
  • Hi,

    (1) The URL you provided is something wrong. It doesn't have separators "/".
    (2) Please provide your code in [Initialize Audoo/Video] button.

    Regards,

    Ashidacchi

    Friday, January 19, 2018 4:00 AM
  • Hi AwAw123,

    Thank you for posting here.

    Did you put the application on the following devices to run?  As far as I know the following device has been supported.

    raspberry,minnowbox,dragon board.

    According to your description, you seems to simulate these device on x64 platform? I think that the sample cannot be run on x64 platform.

    Did you download the sample from the here?

    https://github.com/Microsoft/Windows-iotcore-samples .

    I suggest that you can post the issue on iot forum for getting better support.

    Best Regards,

    Hart


    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, January 19, 2018 6:01 AM
  • @Ashidacchi I could not post links as my account was not verified back then. Here are the links again.

    https://github.com/ms-iot/samples/tree/develop/WebcamApp/CS

    Details on code here: https://developer.microsoft.com/en-us/windows/iot/samples/webcamapp

    @Hart_Wang I downloaded the sample from the link above, but sounds like it is same as

    https://github.com/Microsoft/Windows-iotcore-samples/tree/develop/Samples/WebcamApp/CS

    I tried deplyoing the app on my own Windows 10 Laptop (the one that I am using for development) using both x86 and x64, but it gives me the same error, i.e. access denied at line 202 in MainPage.xaml.cs at

    await mediaCapture.InitializeAsync(); 
    Full code in initialize audio video button is as follows:

    private async void initVideo_Click(object sender, RoutedEventArgs e) { // Disable all buttons until initialization completes SetInitButtonVisibility(Action.DISABLE); SetVideoButtonVisibility(Action.DISABLE); SetAudioButtonVisibility(Action.DISABLE); try { if (mediaCapture != null) { // Cleanup MediaCapture object if (isPreviewing) { await mediaCapture.StopPreviewAsync(); captureImage.Source = null; playbackElement.Source = null; isPreviewing = false; } if (isRecording) { await mediaCapture.StopRecordAsync(); isRecording = false; recordVideo.Content = "Start Video Record"; recordAudio.Content = "Start Audio Record"; } mediaCapture.Dispose(); mediaCapture = null; } status.Text = "Initializing camera to capture audio and video..."; // Use default initialization mediaCapture = new MediaCapture(); await mediaCapture.InitializeAsync(); // Set callbacks for failure and recording limit exceeded status.Text = "Device successfully initialized for video recording!"; mediaCapture.Failed += new MediaCaptureFailedEventHandler(mediaCapture_Failed); mediaCapture.RecordLimitationExceeded += new Windows.Media.Capture.RecordLimitationExceededEventHandler(mediaCapture_RecordLimitExceeded); // Start Preview previewElement.Source = mediaCapture; await mediaCapture.StartPreviewAsync(); isPreviewing = true; status.Text = "Camera preview succeeded"; // Enable buttons for video and photo capture SetVideoButtonVisibility(Action.ENABLE); // Enable Audio Only Init button, leave the video init button disabled audio_init.IsEnabled = true; } catch (Exception ex) { status.Text = "Unable to initialize camera for audio/video mode: " + ex.Message; } }

    Any help will be greatly appreciated.


    Friday, January 19, 2018 3:54 PM
  • Please see the clarification above. Thank you for your reply.
    Friday, January 19, 2018 3:54 PM
  • Of note, the app does ask me if I want to let it use my camera or not. But even after clicking yes, it says 'access denied'. The behavior is same for both x86 and x64 compilations.
    Friday, January 19, 2018 3:57 PM
  • Hi 
    Please open your Package.appxmanifest file go to Capabilities tab then check your WebCam item. If it was not checked, check and test again.
    Saturday, January 20, 2018 4:58 AM
  • Microphone and webcam are checked. Any other thoughts?
    Monday, January 22, 2018 2:52 AM
  • Hello AwAw123,

    You can go to Settings->Privacy->Camera make sue "Let apps use my camera hardware" is "On" like this:


    And you can enable the specified app(like the WebCameraApp) to use your camera like this:

    Best regards,

    Rita


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Monday, January 22, 2018 7:44 AM
  • Hi AwAw123,

    Thank you for your feedback.

    According to the error message, the windows deny the operation. did you try to use the administrator to run the application?

    As far as i know that the sample is about iot, i think that the sample should be used on iot device.  i am not sure whether it can run on Laptop 

    You can see my capture to turn on the option. 

    Best Regards,

    Hart


    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by AwAw123 Friday, February 16, 2018 6:37 PM
    Monday, January 22, 2018 8:04 AM
  • Dear friend,

    It is confirmed that it is an issue on the latest Insider build 17035. And the Webcam works fine on Build 16299.

    Please refer to this post on forum:

    https://social.msdn.microsoft.com/Forums/en-US/b76d8cf6-6b91-43d9-a742-aa5af7c4f941/mediacapture-initializeasync-fails?forum=WindowsIoT


    Keep Fighting

    • Marked as answer by AwAw123 Friday, February 16, 2018 6:37 PM
    Tuesday, January 23, 2018 2:58 AM
  • And Microphone, on my case!
    Friday, March 16, 2018 3:32 PM