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-18-2010, 02:35 PM   #51 (permalink)
Registered Member
 
thecyberduck's Avatar
 
Join Date: Jun 2010
Posts: 58
Default

Quote:
Originally Posted by blackyE View Post
Hi guys,

now i can switch off the light but i cant switch the light again on?
how can you switch off the light???
thecyberduck is offline   Reply With Quote
Old 07-18-2010, 02:39 PM   #52 (permalink)
Registered Member
 
blackyE's Avatar
 
Join Date: Aug 2008
Location: Germany
Posts: 78
Default

Quote:
Originally Posted by thecyberduck View Post
how can you switch off the light???
Code:
	AVCaptureSession * torchSession;
}

- (IBAction)OFF:(id)sender;

@property (nonatomic, retain) AVCaptureSession * torchSession;

@end
Quote:
- (IBAction)OFFid)sender {

AVCaptureSession * session = [[AVCaptureSession alloc] init];

[session beginConfiguration];

AVCaptureDevice * device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];

if ([device hasTorch] && [device hasFlash]){
[device lockForConfiguration:nil];
[device setTorchMode:AVCaptureTorchModeOff];
[device setFlashMode:AVCaptureFlashModeOff];
[device unlockForConfiguration];
}

}
In the IB create a button an connect it with "touch up inside" with the files owner.

Dont forget so safe the XIB!
blackyE is offline   Reply With Quote
Old 07-18-2010, 02:50 PM   #53 (permalink)
Registered Member
 
thecyberduck's Avatar
 
Join Date: Jun 2010
Posts: 58
Default

Quote:
Originally Posted by blackyE View Post
Code:
	AVCaptureSession * torchSession;
}

- (IBAction)OFF:(id)sender;

@property (nonatomic, retain) AVCaptureSession * torchSession;

@end


In the IB create a button an connect it with "touch up inside" with the files owner.

Dont forget so safe the XIB!
thank you very much!!
thecyberduck is offline   Reply With Quote
Old 07-18-2010, 09:53 PM   #54 (permalink)
Obj-C Learner
 
Join Date: Apr 2009
Location: Manchester, UK
Posts: 1,030
Send a message via MSN to ZunePod Send a message via Yahoo to ZunePod
Default

Is it possible to not have the system pulling data from the camera, and just have the flashlight being operated on its own?
__________________
Will code for food
ZunePod is offline   Reply With Quote
Old 07-19-2010, 02:50 AM   #55 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,886
Default

Not with the current OS, but you can always file a bug report.
harrytheshark is offline   Reply With Quote
Old 07-19-2010, 10:39 AM   #56 (permalink)
Obj-C Learner
 
Join Date: Apr 2009
Location: Manchester, UK
Posts: 1,030
Send a message via MSN to ZunePod Send a message via Yahoo to ZunePod
Default

Quote:
Originally Posted by harrytheshark View Post
Not with the current OS, but you can always file a bug report.
I was hoping that it would be in 4.1?
__________________
Will code for food
ZunePod is offline   Reply With Quote
Old 07-19-2010, 11:14 AM   #57 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,886
Default

We can't talk about 4.1. Either ask on the developer forums, or download the SDK and find out yourself.

If it's not there, file a bug report.
harrytheshark is offline   Reply With Quote
Old 07-20-2010, 03:57 PM   #58 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 10
Default Make it blink/pulse

I have a few questions, I've added a button to turn it on/off, now I would like to add 2 more buttons with the following functions;

How do you make the flash blink(like a strobe), like it would send out mayday signals?

How do you make the flash pulse like it was a lazerbeam?


Thanks for taking the time help out.
David H.
holmes2870 is offline   Reply With Quote
Old 07-20-2010, 03:59 PM   #59 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,886
Default

You can't make it pulse, but for the flashing thing, just turn the flash on and off very quickly in your code.
harrytheshark is offline   Reply With Quote
Old 07-20-2010, 04:06 PM   #60 (permalink)
Registered Member
 
blackyE's Avatar
 
Join Date: Aug 2008
Location: Germany
Posts: 78
Default

I need help!

do you know how i can turn on and off the flashlight everytime?

Because i can switch the flashlight on, off and on. After that it doesnt work!
blackyE is offline   Reply With Quote
Old 07-20-2010, 04:25 PM   #61 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,886
Default

Just keep a reference to the AVCaptureDevice, and set the flash to on and off.
Something like this (not tested).
Code:
[theDevice lockForConfiguration:nil];
[theDevice setTorchMode...];
[theDevice unlockForConfiguration];
harrytheshark is offline   Reply With Quote
Old 07-20-2010, 05:06 PM   #62 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 10
Default UISlider or +/- UIButton?

Thanks Harry,

If I wanted to increase/decrease the strength of the flash and add it to a UISlider or a +/- Button Action, how do I modify the code for that?

Thanks Harry
David
holmes2870 is offline   Reply With Quote
Old 07-20-2010, 05:06 PM   #63 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,886
Default

You can't.
harrytheshark is offline   Reply With Quote
Old 07-22-2010, 03:47 AM   #64 (permalink)
Registered Member
 
thecyberduck's Avatar
 
Join Date: Jun 2010
Posts: 58
Default

Quote:
Originally Posted by holmes2870 View Post
I have a few questions, I've added a button to turn it on/off, now I would like to add 2 more buttons with the following functions;

How do you make the flash blink(like a strobe), like it would send out mayday signals?

How do you make the flash pulse like it was a lazerbeam?


Thanks for taking the time help out.
David H.
I think you can make the strobe with this code (Untested, please test


Code:
-(void)strobe:(id)sender {
	
	NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:0.3 target:self selector:@selector(TorchOn) userInfo:nil repeats:YES];
	NSTimer *timer2 = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(TorchOff) userInfo:nil repeats:YES];
	
	
	
	
}
thecyberduck is offline   Reply With Quote
Old 07-22-2010, 09:02 AM   #65 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 2
Default

Quote:
Originally Posted by blackyE View Post
I need help!

do you know how i can turn on and off the flashlight everytime?

Because i can switch the flashlight on, off and on. After that it doesnt work!
yeah, i have the same prob. has anyone a solution?
alex_10 is offline   Reply With Quote
Old 07-22-2010, 09:06 AM   #66 (permalink)
Registered Member
 
thecyberduck's Avatar
 
Join Date: Jun 2010
Posts: 58
Default

Quote:
Originally Posted by alex_10 View Post
yeah, i have the same prob. has anyone a solution?
please can someone with iPhone 4 test mi strobe method that i posted over?
thecyberduck is offline   Reply With Quote
Old 07-22-2010, 09:34 PM   #67 (permalink)
Registered Member
 
suksmo's Avatar
 
Join Date: Mar 2010
Location: iTunes store : Scrambleface otherwise Scotland
Posts: 262
Default

Quote:
Originally Posted by thecyberduck View Post
please can someone with iPhone 4 test mi strobe method that i posted over?
Does this code show the video feed onscreen?
__________________
FREE live action video puzzler

download it FREE now:-
http://itunes.apple.com/us/app/scram...416999968?mt=8
suksmo is offline   Reply With Quote
Old 07-23-2010, 02:23 AM   #68 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 2
Default

Quote:
Originally Posted by thecyberduck View Post
please can someone with iPhone 4 test mi strobe method that i posted over?
i haven't tested it yet. but if you are not able to manage the light by buttons, it won't be able to manage it with a timer or something else.

i promise: if there is a solution, i am the first one to test it
alex_10 is offline   Reply With Quote
Old 07-23-2010, 05:23 AM   #69 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 3
Default

I have the same problem? What is my mistake, please?
Here my project:

Problem with AVCaptureSession on Twitpic


Quote:
Originally Posted by Vmlweb View Post
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?
Tentoxa is offline   Reply With Quote
Old 07-23-2010, 05:24 AM   #70 (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-23-2010, 07:25 AM   #71 (permalink)
Registered Member
 
suksmo's Avatar
 
Join Date: Mar 2010
Location: iTunes store : Scrambleface otherwise Scotland
Posts: 262
Smile

deleted
__________________
FREE live action video puzzler

download it FREE now:-
http://itunes.apple.com/us/app/scram...416999968?mt=8

Last edited by suksmo; 07-26-2010 at 05:49 AM.
suksmo is offline   Reply With Quote
Old 07-25-2010, 07:12 AM   #72 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 2
Default

Quote:
Originally Posted by suksmo View Post
Can someone check if this works (my iphone 4 hasn't arrived) - i salvaged this code -

- add the AV foundation framework

- create a view based application call it torch

- in the torchViewController.h file :-



- in the torchViewController.m :-

Code:
#import "torchViewController.h"

@implementation torchViewController

- (void)viewDidLoad {
	capSession=[[AVCaptureSession alloc] init];
	
    device=[AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
	
    [device lockForConfiguration:&err];
	
    [capSession beginConfiguration];
    
    input=[[AVCaptureDeviceInput alloc] initWithDevice:device error:&err];
    
    output= [[AVCaptureStillImageOutput alloc] init];
    
    [capSession addInput:input];
    
    [capSession addOutput:output];
    
    [capSession commitConfiguration];
    
    [capSession startRunning];

}

-(IBAction)lightOn{
[device setTorchMode:AVCaptureTorchModeOn];
}

-(IBAction)lightOff{
	[device setTorchMode:AVCaptureTorchModeOff];
}

/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
        // Custom initialization
    }
    return self;
}
*/

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/


/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
}
*/


/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
	// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
	
	// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
	// Release any retained subviews of the main view.
	// e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [super dealloc];
}

@end
- go into interface builder and add two buttons to the view, name them on and off. Control drag from each of the buttons to the files owner, and select Event as lightOn and lightOff respectively.

Then build and run.

If it works post up here and thank me

Many compile errors.
xxxdacheeze is offline   Reply With Quote
Old 07-25-2010, 07:25 AM   #73 (permalink)
Registered Member
 
suksmo's Avatar
 
Join Date: Mar 2010
Location: iTunes store : Scrambleface otherwise Scotland
Posts: 262
Default

Quote:
Originally Posted by xxxdacheeze View Post
Many compile errors.
You have to build for device. It does build fir device. It won't work on the simulator.
__________________
FREE live action video puzzler

download it FREE now:-
http://itunes.apple.com/us/app/scram...416999968?mt=8
suksmo is offline   Reply With Quote
Old 07-25-2010, 05:50 PM   #74 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 1
Default

Works well! Thanks!


Quote:
Originally Posted by suksmo View Post
Can someone check if this works (my iphone 4 hasn't arrived) - i salvaged this code -

- add the AV foundation framework

- create a view based application call it torch

- in the torchViewController.h file :-



- in the torchViewController.m :-

Code:
#import "torchViewController.h"

@implementation torchViewController

- (void)viewDidLoad {
	capSession=[[AVCaptureSession alloc] init];
	
    device=[AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
	
    [device lockForConfiguration:&err];
	
    [capSession beginConfiguration];
    
    input=[[AVCaptureDeviceInput alloc] initWithDevice:device error:&err];
    
    output= [[AVCaptureStillImageOutput alloc] init];
    
    [capSession addInput:input];
    
    [capSession addOutput:output];
    
    [capSession commitConfiguration];
    
    [capSession startRunning];

}

-(IBAction)lightOn{
[device setTorchMode:AVCaptureTorchModeOn];
}

-(IBAction)lightOff{
	[device setTorchMode:AVCaptureTorchModeOff];
}

/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
        // Custom initialization
    }
    return self;
}
*/

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/


/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
}
*/


/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
	// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
	
	// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
	// Release any retained subviews of the main view.
	// e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [super dealloc];
}

@end
- go into interface builder and add two buttons to the view, name them on and off. Control drag from each of the buttons to the files owner, and select Event as lightOn and lightOff respectively.

Then build and run.

If it works post up here and thank me
fiveohho is offline   Reply With Quote
Old 07-26-2010, 04:59 AM   #75 (permalink)
Registered Member
 
suksmo's Avatar
 
Join Date: Mar 2010
Location: iTunes store : Scrambleface otherwise Scotland
Posts: 262
Default

Quote:
Originally Posted by fiveohho View Post
Works well! Thanks!
good luck with your app fiveohho!
__________________
FREE live action video puzzler

download it FREE now:-
http://itunes.apple.com/us/app/scram...416999968?mt=8
suksmo 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: 261
20 members and 241 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:22 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0