0

I'm writing my first ever C# application, for Windows Phone Mango. It's designed to be an extremely simple flashlight app.

Previously, it wasn't possible to access the camera's flash on Windows Phone, but in this latest version, it is. Here's the documentation about it:

http://msdn.microsoft.com/en-us/library/microsoft.devices.flashmode(v=vs.92).aspx

Unfortunately, that makes absolutely no sense to me. I have the button set up and and the if-then statements working to switch the button icon and text on click. I just can't figure out how to actually turn the flash on and off. I'd appreciate a clear example so I can finish this up.

For those of you who don't want o leave the site...That link basically says this:

public enum FlashMode

Members: On, Off, Auto, RedEyeReduction

4 Answers 4

2

The FlashMode enumeration is just a set of values representing valid values for FlashMode. FlashMode, however, seems to define how the flash behaves when you take a picture. "On" seems to mean that the flash will always flash. It doesn't seem to mean that the light itself is "on" in the sense of producing light continuously.

A bit of evidence in favor of this: the FlashMode documentation says that FlashMode.On means "The camera flash is enabled."

Sign up to request clarification or add additional context in comments.

1 Comment

Ah. Damn, thought that meant you could toggle it. Thanks, though. I'll just submit it as is, with just a white background.
0

Did you see this link?

http://msdn.microsoft.com/en-us/library/hh202949(v=vs.92).aspx

If there is a variable called "cam" available to you (DISCLAIMER: I know nothing of mobile devices) you need to change the FlashMode property. So on your button click, you would do

cam.FlashMode = FlashMode.On 

EDIT: After looking a bit further it appears the "cam" variable is an instance of PhotoCamera class. So this may need to be constructed in your app somehwere. This link may also be of some help in doing so.

http://msdn.microsoft.com/en-us/library/hh202956(v=vs.92).aspx

Comments

0

There is a great explanation at MSDN on enum so I won't try to recreate that here, but essentially a new type has been created to ease the value assignment. Rather than having to remember that (for example) 'On' is equal to 0, and 'Off' is equal to 1, you can just use FlashMode.On instead. Of course, these enums only represent values so you will still need to assign it to something.

For example I found this in a link from within the link you provided:

cam.FlashMode = FlashMode.On;

This looks like fun so Good luck!

Comments

-1

If you are trying to make some kind of flashlight app, there is no API for the LED according to this

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.