hjam40 / Camera.MAUI

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

StopCameraAsync does not remove green dot and turn off the light front of the camera on IOS #178

Open hercul1017 opened 1 month ago

hercul1017 commented 1 month ago

Hi,

After moving to another pages the green dot indicating the camera still on does not disappear even after calling StopCameraAsync. I tried following code but it did not work. StopCameraAsync returns Success, but green dot continues to display. Newer models of IPhones light next the front camera that I use, also continues to light and it does not turn off.

    MainThread.BeginInvokeOnMainThread(async () =>
    {
        cameraView.FlashMode = FlashMode.Disabled;
        cameraView.TorchEnabled = false;

        if (await cameraView.StopCameraAsync() == CameraResult.Success)
        {                 
        }            
    });

Thanks for any help,

thomasgalliker commented 1 week ago

I guess this comes from the fact, that MAUI does not call DisconnectHandler automatically when a page (and all its UI elements) is no longer used. I created this helper class which automatically disconnects handlers once the page is navigated away: HandlerCleanUpHelper.cs

Someone who maintains Camera.MAUI would have to take something like that into consideration. MAUI will probably not solve the problem for us...