I want to turn on torch mode AVCaptureTorchModeOn in my app while doing video recording.
I m using below code.
-(void)set_TorchMode:(BOOL)turnOn
{
AVCaptureDevice *theDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
if ([theDevice hasTorch]) {
[theDevice lockForConfiguration: nil];
AVCaptureTorchMode currentMode = [theDevice torchMode];
BOOL isAlreadyTurnedOn = (AVCaptureTorchModeOn == currentMode);
if (isAlreadyTurnedOn != turnOn) {
[theDevice setTorchMode: turnOn? AVCaptureTorchModeOn: AVCaptureTorchModeOff];
}
[theDevice unlockForConfiguration];
}
}
I m calling this method while start recording to turn ON and while stop recording to turn it OFF.
Its working fine for me first time when i record, but while start recording second time, its turn on but immediately turns OFF.Its not keeping ON while recording is running.
Thanks for any help.
Following code is implemented for the turn on and off back light .
May this helping to you,
please test this code into the devices.