07-12-2010, 08:28 AM
#26 (permalink )
Registered Member
Join Date: Mar 2009
Posts: 59
Led flash
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?
Any code examples would be greatly appreciated.
07-12-2010, 10:59 AM
#27 (permalink )
Registered Member
Join Date: Dec 2008
Location: UK
Posts: 1,886
I've attached a project with the basic idea. Hope it helps.
07-12-2010, 01:44 PM
#29 (permalink )
Registered Member
Join Date: Mar 2009
Posts: 59
Quote:
Originally Posted by
harrytheshark
I've attached a project with the basic idea. Hope it helps.
Also, it works well when it is first installed and ran. Once you quit the app anf the flash goes off, the app is still "running" in the background and when it is releaunched the flash will not turn back on. That is curious...
07-12-2010, 02:06 PM
#30 (permalink )
Registered Member
Join Date: Dec 2008
Location: UK
Posts: 1,886
Yeah, you've got to handle that yourself. I just gave you a basic example
07-12-2010, 03:03 PM
#31 (permalink )
Registered Member
Join Date: Mar 2009
Posts: 59
Quote:
Originally Posted by
harrytheshark
Yeah, you've got to handle that yourself. I just gave you a basic example
So, is that better to handle in backgrounding code or to disable backgrounding in the app and start fresh on relaunch? I haven't messed with the multitasking API's yet so my experience is laking there.
Also I greatly appreciate your help. Thanks
07-12-2010, 03:05 PM
#32 (permalink )
Registered Member
Join Date: Dec 2008
Location: UK
Posts: 1,886
I just disabled multitasking, there's no reason for it to even be suspended, because it doesn't take any time to launch and all you're doing is turning the torch on.
07-12-2010, 03:30 PM
#33 (permalink )
Registered Member
Join Date: Mar 2009
Posts: 59
Quote:
Originally Posted by
harrytheshark
I just disabled multitasking, there's no reason for it to even be suspended, because it doesn't take any time to launch and all you're doing is turning the torch on.
That was my thought as well. I would at some point like to fiddle with the backgrounding as well to see what other possibilities it could morph into. If I get something in the next week or so I'll let you know.
07-12-2010, 03:31 PM
#34 (permalink )
Registered Member
Join Date: Dec 2008
Location: UK
Posts: 1,886
Sounds good
07-12-2010, 07:39 PM
#35 (permalink )
Registered Member
Join Date: Jun 2009
Posts: 8
Quote:
Originally Posted by
harrytheshark
I've attached a project with the basic idea. Hope it helps.
Can't open the zipped file. Goes in endless loop of cpgz file, and etc.
07-13-2010, 04:46 PM
#36 (permalink )
Registered Member
Join Date: Jun 2009
Posts: 131
Quote:
Originally Posted by
harrytheshark
I've attached a project with the basic idea. Hope it helps.
hey, thanks for posting your project, will be a major help. i dont have my iPhone 4 yet so i cant test it out just yet but was just curious to what it does.
turn on the torch or flash on and off?
and to turn it off do you just need to change ...
[device setTorchMode:AVCaptureTorchModeOn];
[device setFlashMode:AVCaptureFlashModeOn];
to....
[device setTorchMode:AVCaptureTorchModeOff];
[device setFlashMode:AVCaptureFlashModeOff];
or is there something as well as that?
thanks.
07-13-2010, 04:47 PM
#37 (permalink )
Registered Member
Join Date: Dec 2008
Location: UK
Posts: 1,886
To turn it off you stop running the session.
07-13-2010, 05:23 PM
#38 (permalink )
Registered Member
Join Date: Jun 2009
Posts: 131
Quote:
Originally Posted by
harrytheshark
To turn it off you stop running the session.
what if you put the code in a IBAction button instead of view did load? would it still work?
07-13-2010, 05:24 PM
#39 (permalink )
Registered Member
Join Date: Dec 2008
Location: UK
Posts: 1,886
You can put the code wherever you want.
07-13-2010, 05:43 PM
#40 (permalink )
Registered Member
Join Date: Jun 2009
Posts: 8
Quote:
Originally Posted by
harrytheshark
I've attached a project with the basic idea. Hope it helps.
HELLO? Anyone? The File just keeps looping into CPGZ File, and it won't open with Unarchiver. Anyone tell me how to open the zip file?
07-13-2010, 05:45 PM
#41 (permalink )
Registered Member
Join Date: Dec 2008
Location: UK
Posts: 1,886
There's no trick to it, just double click the icon.
07-13-2010, 05:48 PM
#42 (permalink )
Registered Member
Join Date: Oct 2009
Posts: 519
Quote:
Originally Posted by
harrytheshark
To turn it off you stop running the session.
?? you don't have to stop the session ever, just turn it off with the aforementioned code.
07-13-2010, 05:50 PM
#43 (permalink )
Registered Member
Join Date: Dec 2008
Location: UK
Posts: 1,886
Stopping the session works also, and stops the phone grabbing camera data.
07-13-2010, 05:52 PM
#44 (permalink )
Registered Member
Join Date: Oct 2009
Posts: 519
Quote:
Originally Posted by
harrytheshark
Stopping the session works also, and stops the phone grabbing camera data.
so instead of reinitializing the capture session to turn the flash back on, you just use the one line of code to flip flop it.
07-13-2010, 05:54 PM
#45 (permalink )
Registered Member
Join Date: Dec 2008
Location: UK
Posts: 1,886
Yup
07-17-2010, 06:02 AM
#46 (permalink )
Registered Member
Join Date: Jul 2010
Posts: 26
Quote:
Originally Posted by
harrytheshark
I've attached a project with the basic idea. Hope it helps.
I'm getting a
Code:
expected specifier-qualifier-list before AVCaptureSession
build error here
Code:
@interface TorchViewController : UIViewController {
AVCaptureSession * torchSession;
}
@property (nonatomic, retain) AVCaptureSession * torchSession;
Does anyone know why this is happening?
07-17-2010, 06:03 AM
#47 (permalink )
Registered Member
Join Date: Dec 2008
Location: UK
Posts: 1,886
Include the AVFoundation framework and don't build for the simulator. It only works on a device.
07-17-2010, 06:31 AM
#48 (permalink )
Registered Member
Join Date: Jul 2010
Posts: 26
Quote:
Originally Posted by
harrytheshark
Include the AVFoundation framework and don't build for the simulator. It only works on a device.
Ah ok thanks
07-17-2010, 06:31 PM
#49 (permalink )
Registered Member
Join Date: Jul 2010
Posts: 10
Questions?
Hi,
I'm making a flashlight app for my beginner Iphone dev class, the app is only for demonstration in class and not for publishing.
I've made a customButton with an IBOutlet and a IBAction and made the connections in interfacebuilder. The button has a Normal and Selected state.
My question is, How do add this code to the IBAction? Do I just past the code in between the curly brackets?
Since I have a Normal and Selected button, I want the first tap to turn the flashlight On and then Off when the button get tapped again.
I'm new to this, so please help me out...
David H.
07-18-2010, 02:26 PM
#50 (permalink )
Registered Member
Join Date: Aug 2008
Location: Germany
Posts: 78
Hi guys,
now i can switch off the light but i cant switch the light again on?
Thread Tools
Display Modes
Linear Mode
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
» Advertisements
» Online Users: 260
20 members and 240 guests
ADY , Alsahir , beleg_1998 , Dani77 , e2applets , iph_s , JasonR , mer10 , Monstertaco , piesia , prchn4christ , Promo Dispenser , Robiwan , Rudy , sly24 , smithdale87 , timle8n1 , Touchmint , twerner
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,880
Threads: 89,228
Posts: 380,758
Top Poster: BrianSlick (7,129)
Welcome to our newest member, @sandris