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];
}
slf
2010-07-08 13:31:44