Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Opening settings charm while Camera open closes the camera in windows 8 / WinRT

I am using CameraCaptureUI for opening camera in my application; Here is the code what iam using

        var camera = new CameraCaptureUI();
        camera.PhotoSettings.AllowCropping = false;
        var file = await camera.CaptureFileAsync(CameraCaptureUIMode.Photo);
        if (file != null)
        {
            var fileStream = await file.OpenAsync(FileAccessMode.Read);
            var bitmapImage = new BitmapImage();
            bitmapImage.SetSource(fileStream);
            var sourceImage = new WriteableBitmap(bitmapImage.PixelWidth, bitmapImage.PixelHeight);
            var imageStream = await file.OpenAsync(FileAccessMode.Read);
            sourceImage.SetSource(imageStream);

        }

But the issue is not with camera. During the time of camera open. If we open settings charm the await function cancels var file = await camera.CaptureFileAsync(CameraCaptureUIMode.Photo); [File returns null] and hides the CameraCapture UI. What i am trying to do is i need to open my camera always even if the user opens the charm. How i can achieve this in WinRT

like image 563
StezPet Avatar asked May 29 '13 07:05

StezPet


1 Answers

To solve your problem, you need to stop using the CameraCaptureUI and start using the <CaptureElement/> in a UI you specifically design for your special scenario.

I wrote this up in an article to help. Here.

Best of luck!

like image 177
Jerry Nixon Avatar answered Nov 07 '22 03:11

Jerry Nixon