I\'m making an app to allow me to stitch images together into a panoramic scene. I want to be able to turn the Flash LED on the iPhone 4 programatically.
How can I do th
AVCaptureDevice* d = nil;
// find a device by position
NSArray* allDevices = [AVCaptureDevice devices];
for (AVCaptureDevice* currentDevice in allDevices) {
if (currentDevice.position == AVCaptureDevicePositionBack) {
d = currentDevice;
}
}
// at this point, d may still be nil, assuming we found something we like....
NSError* err = nil;
BOOL lockAcquired = [d lockForConfiguration:&err];
if (!lockAcquired) {
// log err and handle...
} else {
// flip on the flash mode
if ([d hasFlash] && [d isFlashModeSupported:AVCaptureFlashModeOn] ) {
[d setFlashMode:AVCaptureFlashModeOn];
}
[d unlockForConfiguration];
}