Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 07-12-2010, 08:28 AM   #26 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 59
Default 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.
crivoli is offline   Reply With Quote
Old 07-12-2010, 10:59 AM   #27 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,886
Default

I've attached a project with the basic idea. Hope it helps.
Attached Files
File Type: zip Torch.zip (19.0 KB, 782 views)
harrytheshark is offline   Reply With Quote
Old 07-12-2010, 11:03 AM   #28 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 59
Default

Quote:
Originally Posted by harrytheshark View Post
I've attached a project with the basic idea. Hope it helps.
Thanks man. I'll try it out when I go home for lunch.

Also, I see you are from Leeds (I've been there) so I'll plug this: Go USA Bid: Bring the FIFA World Cup back to the United States in 2018/2022

crivoli is offline   Reply With Quote
Old 07-12-2010, 01:44 PM   #29 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 59
Default

Quote:
Originally Posted by harrytheshark View Post
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...
crivoli is offline   Reply With Quote
Old 07-12-2010, 02:06 PM   #30 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,886
Default

Yeah, you've got to handle that yourself. I just gave you a basic example
harrytheshark is offline   Reply With Quote
Old 07-12-2010, 03:03 PM   #31 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 59
Default

Quote:
Originally Posted by harrytheshark View Post
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
crivoli is offline   Reply With Quote
Old 07-12-2010, 03:05 PM   #32 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,886
Default

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.
harrytheshark is offline   Reply With Quote
Old 07-12-2010, 03:30 PM   #33 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 59
Default

Quote:
Originally Posted by harrytheshark View Post
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.
crivoli is offline   Reply With Quote
Old 07-12-2010, 03:31 PM   #34 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,886
Default

Sounds good
harrytheshark is offline   Reply With Quote
Old 07-12-2010, 07:39 PM   #35 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 8
Default

Quote:
Originally Posted by harrytheshark View Post
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.
alchemistmuffin is offline   Reply With Quote
Old 07-13-2010, 04:46 PM   #36 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 131
Default

Quote:
Originally Posted by harrytheshark View Post
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.
eski is offline   Reply With Quote
Old 07-13-2010, 04:47 PM   #37 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,886
Default

To turn it off you stop running the session.
harrytheshark is offline   Reply With Quote
Old 07-13-2010, 05:23 PM   #38 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 131
Default

Quote:
Originally Posted by harrytheshark View Post
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?
eski is offline   Reply With Quote
Old 07-13-2010, 05:24 PM   #39 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,886
Default

You can put the code wherever you want.
harrytheshark is offline   Reply With Quote
Old 07-13-2010, 05:43 PM   #40 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 8
Default

Quote:
Originally Posted by harrytheshark View Post
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?
alchemistmuffin is offline   Reply With Quote
Old 07-13-2010, 05:45 PM   #41 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,886
Default

There's no trick to it, just double click the icon.
harrytheshark is offline   Reply With Quote
Old 07-13-2010, 05:48 PM   #42 (permalink)
Registered Member
 
Join Date: Oct 2009
Posts: 519
Default

Quote:
Originally Posted by harrytheshark View Post
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.
__________________
Water Your Body (ON SALE $0.99)

Top Paid in Health & Fitness!

Tic Tac Pro ($0.99)

New and Noteworthy!

Click here to see a really cool website
bravetarget is offline   Reply With Quote
Old 07-13-2010, 05:50 PM   #43 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,886
Default

Stopping the session works also, and stops the phone grabbing camera data.
harrytheshark is offline   Reply With Quote
Old 07-13-2010, 05:52 PM   #44 (permalink)
Registered Member
 
Join Date: Oct 2009
Posts: 519
Default

Quote:
Originally Posted by harrytheshark View Post
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.
__________________
Water Your Body (ON SALE $0.99)

Top Paid in Health & Fitness!

Tic Tac Pro ($0.99)

New and Noteworthy!

Click here to see a really cool website
bravetarget is offline   Reply With Quote
Old 07-13-2010, 05:54 PM   #45 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,886
Default

Yup
harrytheshark is offline   Reply With Quote
Old 07-17-2010, 06:02 AM   #46 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 26
Default

Quote:
Originally Posted by harrytheshark View Post
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?
Vmlweb is offline   Reply With Quote
Old 07-17-2010, 06:03 AM   #47 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,886
Default

Include the AVFoundation framework and don't build for the simulator. It only works on a device.
harrytheshark is offline   Reply With Quote
Old 07-17-2010, 06:31 AM   #48 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 26
Default

Quote:
Originally Posted by harrytheshark View Post
Include the AVFoundation framework and don't build for the simulator. It only works on a device.
Ah ok thanks
Vmlweb is offline   Reply With Quote
Old 07-17-2010, 06:31 PM   #49 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 10
Default 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.
holmes2870 is offline   Reply With Quote
Old 07-18-2010, 02:26 PM   #50 (permalink)
Registered Member
 
blackyE's Avatar
 
Join Date: Aug 2008
Location: Germany
Posts: 78
Default

Hi guys,

now i can switch off the light but i cant switch the light again on?
blackyE is offline   Reply With Quote
Reply

Bookmarks

Tags
api, camera, camera flash, flash, framework

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» 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
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:23 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0