dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.24k stars 1.76k forks source link

CaptureVideoAsync always returning null when using Windows Machine #7616

Closed efonsecab closed 2 years ago

efonsecab commented 2 years ago

Description

When trying to capture video running the app as Windows Machine, the video capture method does not show the webcam, and immediately returns null.

private async Task OnCaptureVideoClickedAsync()
        {
            if (await Permissions.CheckStatusAsync<Camera>() != PermissionStatus.Granted)
            {
                var result = await Permissions.RequestAsync<Camera>();
                if (result != PermissionStatus.Granted)
                {
                    ToastService.ShowError("You need to grant the camera permission to use this feature");
                    return;
                }
            }
            var video = await MediaPicker.Default.CaptureVideoAsync();
        }

Permissions are set like this

<Capabilities>
    <rescap:Capability Name="runFullTrust" />
    <DeviceCapability Name="location"></DeviceCapability>
    <DeviceCapability Name="webcam" />
    <DeviceCapability Name="microphone" />
  </Capabilities>

Steps to Reproduce

  1. Create a MAUI Blazor app
  2. Add a button and invoke a method containing. var video = await MediaPicker.Default.CaptureVideoAsync();
  3. Configure the permissions as in the description
  4. Run the app as Windows Machine.

Version with bug

6.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

net6.0-windows10.0.19041.0

Did you find any workaround?

No, haven't found a workaround.

Relevant log output

No response

Xyncgas commented 2 years ago

Are you saying the application works on other machines aside from Windows Machine?

efonsecab commented 2 years ago

Are you saying the application works on other machines aside from Windows Machine?

Yes indeed, the application actually shows the webcam if running using the Android emulator, but not when using Windows Machine as the build target, on Windows Machine always returns null immediately.

uuggghhhJay commented 2 years ago

Hi getting the same result on MediaPicker.Default.CapturePhotoAsync() on a windows machine. Works on android.

Capabilities set "webcam, microphone"

VincentBu commented 2 years ago

run into same error when running MAUI App and MAUI Blazor app with vs main build(32606.310.main)

efonsecab commented 2 years ago

Seems it is related to this issue and that it's not a MAUI issue, but instead a WinUI/platform issue https://github.com/dotnet/maui/issues/5849

janseris commented 2 years ago

Seems it is related to this issue and that it's not a MAUI issue, but instead a WinUI/platform issue #5849

https://github.com/microsoft/WindowsAppSDK/issues/1034 since July 2021

jfversluis commented 2 years ago

There are multiple duplicates for this and closing some of them including this one. I'd like to keep #7660 open as it has a workaround for now. Internally I am seeing if we can get the WinAppSDK team to prioritize that bug or if we should move forward for .NET MAUI to implement the workaround in the linked issue. Thanks everyone!

jfversluis commented 2 years ago

Duplicate of #7660