Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.
Hi. I can't figure out how to access the camera flash on the iPhone 4 for my app. Is anyone able to figure this out? I looked through the developer documentation and still can't figure it out. Thanks.
EDIT:When I try to import the <AVFoundation/AVFoundation.h, it's almost as if it doesn't detect it. For instance, I will type AVCaptureDevice in the .h file and it won't recognize it and give me an error. It detects that I've imported some classes (such as the ones that were in 3.0) but not the ones that are new to 4.0 (which one I need).
HAve you tried the AVCaptureDevice class? I don't have an iPhone4, so I can't try it, but it looks like the way to go.
Yeah. That's the one I was looking at. I'm kind of a newbie and I'm trying to learn how to use the developer documentation. I just couldn't figure out how to implement it.
Since you are doing something that's not standard, there's not going to be sample code. So your choice is either try it yourself, or wait until someone else does and posts it. (If you can wait 3-4 weeks, that's when I get my iPhone 4).
If I were you, I would play with the devices array, taking each element and setting flashMode until one of them turned on the flash. IT might look something like this:
NSArray *devices = [AVCaptureDevice devices]; for (AVCaptureDevice *device in devices) { device.flashMode = AVCaptureFlashModeOn; }
Keep in mind, I'm guessing since I don't have the hardware, but see if that gets you started.
Since you are doing something that's not standard, there's not going to be sample code. So your choice is either try it yourself, or wait until someone else does and posts it. (If you can wait 3-4 weeks, that's when I get my iPhone 4).
If I were you, I would play with the devices array, taking each element and setting flashMode until one of them turned on the flash. IT might look something like this:
NSArray *devices = [AVCaptureDevice devices]; for (AVCaptureDevice *device in devices) { device.flashMode = AVCaptureFlashModeOn; }
Keep in mind, I'm guessing since I don't have the hardware, but see if that gets you started.
Ok. I will look at it and see if I can get it working. Thanks for your help.
I'm having a very similar problem with trying to access the AVCaptureDevice class. I've imported the AVFoundation.framework into my project and also did an import statement of the AVFoundation/AVFoundation.h, but XCode just keeps saying AVCaptureDevice is undeclared. Also if I look at the header files within the framework itself, it's missing half of the 4.0 specific AVFoundation classes found within the documentation. Any ideas?
EDIT: It wont compile when building for the sim but builds and runs on my iPhone 4. When I tap the button with this action it returns SIGBART on it. telling me
Sorry, I was talking more generally, in regards to your code, you need to run lockForConfiguration and unlockForConfiguration before and after changing device properties.
I have tried all of these suggestions and got nothing to turn on. All of the calls work without errors and the flash modes are tuned on but nothing happens.
A question which is a little out of topic; do anyone know how can I set the video encoding format as H264 when recording video using AVCaptureSession, AVCaptureInput and AVCaptureOutput?
I have tried all of these suggestions and got nothing to turn on. All of the calls work without errors and the flash modes are tuned on but nothing happens.
Can you share any of the code you used to make it successful? I looped through all the AVCapture devices and locked them and set the flash and torch on but to no avail. This seems much trickier than I expected. All I want is a app I can customize to my liking but it's almost more effort than it is worth.
Do you have to bring up the video cam for recording mode before it will work?
Replies
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeIf I were you, I would play with the devices array, taking each element and setting flashMode until one of them turned on the flash. IT might look something like this:
Keep in mind, I'm guessing since I don't have the hardware, but see if that gets you started.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeEverything you need is in there ;)
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeAndrew
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeI found a free version of a iP4 flashlight:
LED-Light
Works perfect!
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeI have one, and my code doesnt work in simulator, but in the iphone4, works....
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeMy Code:
But the flashlight is off :/ What´s wrong ? Test your Code on a iPhone 4. If you run this Code in Simulator it shows this error. If you use a Device it show´s no error ;)
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeAny ideas?
EDIT:
It wont compile when building for the sim but builds and runs on my iPhone 4. When I tap the button with this action it returns SIGBART on it. telling me
this failed.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeOutput and Input are their
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeI have tried all of these suggestions and got nothing to turn on. All of the calls work without errors and the flash modes are tuned on but nothing happens.
Any success for anyone?
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeDo you have to bring up the video cam for recording mode before it will work?
Any code examples would be greatly appreciated.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome