I am using code (which I used before XCode 4 in another project) and now if I switch my flashlight on, it flashes once before it stays on.
Like so: -*-****
where -
=off & *
=on
The code I am using:
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
if (toggleSwitch.on)
{
NSLog( @"Light ON");
AVCaptureSession *session = [[AVCaptureSession alloc] init];
AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:device error:nil];
[session addInput:input];
AVCaptureVideoDataOutput *output = [[AVCaptureVideoDataOutput alloc] init];
[session addOutput:output];
[session beginConfiguration];
[device lockForConfiguration:nil];
[device setTorchMode:AVCaptureTorchModeOn];
[device unlockForConfiguration];
[session commitConfiguration];
[session startRunning];
[self setAVSession:session];
[output release];
[session release];
}
else
{
NSLog( @"Light OFF");
[AVSession stopRunning];
[AVSession release],AVSession = nil;
}
Switching it off works normal/fine.
Why would this happen? - How can I solve this problem?