hjam40 / Camera.MAUI

A CameraView Control for preview, take photos and control the camera options
MIT License
449 stars 72 forks source link

camera do not work in window #45

Open TheR7angelo opened 1 year ago

TheR7angelo commented 1 year ago

I want to display my webcam on window, and camera on android. In android that work but in window no why ?

My code:

`public MainPage() { InitializeComponent(); foreach (var i in CameraView.Cameras) { Console.WriteLine(i.Name); } }

private void CameraView_CamerasLoaded(object sender, EventArgs e)
{
    if (CameraView.NumCamerasDetected <= 0) return;

    if (CameraView.NumMicrophonesDetected > 0) CameraView.Microphone = CameraView.Microphones.First();
    CameraView.Camera = CameraView.Cameras.First();

    MainThread.BeginInvokeOnMainThread(async () =>
    {
        await CameraView.StartCameraAsync();
    });
}`

my Package.appxmanifest: `

<DeviceCapability Name="webcam"/>
<DeviceCapability Name="microphone"/>

`

hjam40 commented 1 year ago

Hi,

It is a known problem with Windows, you could add a Delay before the StartCameraAsync and it resolve the problem. In the next plugging version It should works fine.

TheR7angelo commented 1 year ago

Hi,

I just added Thread.Sleep(1000) It doesn't change anything, is it normal? I don't have to use the right delay maybe

hjam40 commented 1 year ago

Hi,

In the new version 1.4.4 I have added a new windows control for check if the native control is loaded before to initialize the preview, It should work fine right now (almost in my testapp works fine).

TheR7angelo commented 1 year ago

Hi I do not understand I followed your read me and it does not work, my application does not start. I used your test project and it works perfectly thank you.

Can you update your read me or make it more understandable?

xufeitt commented 1 year ago

I want to know too , StartCameraAsync how to work well in windows ?