Mediha
Mediha

Reputation: 760

Using front camera on wp8 code

I was using this Microsoft sample http://code.msdn.microsoft.com/wpapps/Basic-Camera-Sample-52dae359#content because I needed to implement camera functionality in my application. Ans this is working fine until I try to switch to front camera then the app just closes and I get this

The program '[3032] TaskHost.exe' has exited with code -532265403 (0xe0464645)

I was going through the code and I found out that this part of code causes the problem

public FlashState FlashState
        {
            get { return (FlashState) (uint) PhotoCaptureDevice.GetProperty(KnownCameraPhotoProperties.FlashMode); }
            set
            {
                try
                {
                    PhotoCaptureDevice.SetProperty(KnownCameraPhotoProperties.FlashMode, value);
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex.Message);
                }
            }
        }

It doesn't hit catch, just closes the app. The same thing is happening if I set Front Camera as a default one. Did anyone had this problem?

[SOLUTION] Ok, after trying everything - event posting here, now I have a solution. In the try block above I added this line

if (CameraSensorLocation == CameraSensorLocation.Front) return;

so now it doesn't crush, and the front camera is working fine. They should change this in official sample.

Upvotes: 1

Views: 880

Answers (1)

Mediha
Mediha

Reputation: 760

Ok, after trying everything - even posting here, now I have a solution. In the try block above I added this line

if (CameraSensorLocation == CameraSensorLocation.Front) return;

so now it doesn't crush, and the front camera is working fine.

Upvotes: 1

Related Questions