Not every Windows Phone has flash
I didn’t realise this until recently when testing with the cheap as chips Nokia Lumia 520. It’s a great device for the price but you need to add a check to your camera code to make sure other flash modes are available before manipulating it.
Here’s a method to get the available flash states and another to check if flash is available for the current device (ie: if there is one or less flash states).
public bool IsFlashAvailable()
List<FlashState> flashStates = GetAvailableFlashStates().ToList();
return (flashStates.Count > 1);
public IReadOnlyList<FlashState> GetAvailableFlashStates()
IReadOnlyList<object> rawValueList = PhotoCaptureDevice.GetSupportedPropertyValues(Device.SensorLocation, KnownCameraPhotoProperties.FlashMode);
List<FlashState> flashStates = new List<FlashState>(rawValueList.Count);foreach (object rawValue in rawValueList) flashStates.Add((FlashState)(uint)rawValue);
Update #1: Jay Benett ponts out that this can be done in a far simpler way than I have using LINQ’s .Any() https://twitter.com/JayTBennett/status/370221811423670272
Update #2: Just realised this update 1 method won’t work as even if there isn’t a flash on the device there will still be FlashState.Off in the list.
Update #3:After more discussion, it turns out there is a way to do it using Jay’s method: https://twitter.com/scottisafool/status/371913405080547328. I’m going to stop updating this post now.
In some regions the camera shutter sound can’t be turned off
Foundbite allows you to take a picture at the same time as recording audio so it wouldn’t be ideal if you could hear the shutter sound in every sound clip. It is possible to turn the sound off but in some regions of the world it’s a legal necessity to have this sound on.
It’s therefore a necessity to check that you can turn the sound off before doing so:
private void disableShutterSound()
It’s possible to turn off the flash that happens when you focus the camera
This setting is called the FocusIlluminationMode and can easily be changed, much like FlashMode, between Auto, On and Off.
Here’s the code to get the current value and change it:
public FocusIlluminationMode GetCurrentFocusIlluminatonMode()
public void SetIlluminationMode(FocusIlluminationMode mode)
It’s worth nothing that you should check the flash is available before changing this mode too!
Hopefully these will be helpful and save some time for others playing around with the camera.