Using front camera on wp8 code

1

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.

camera
windows-phone-8
capture
asked on Stack Overflow Jun 4, 2013 by Mediha • edited Jun 4, 2013 by Mediha

1 Answer

1

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.

answered on Stack Overflow Jun 10, 2013 by Mediha • edited Nov 23, 2016 by Mediha

User contributions licensed under CC BY-SA 3.0