标签:
enum { AVCaptureDevicePositionBack = 1, AVCaptureDevicePositionFront = 2 }; typedef NSInteger AVCaptureDevicePosition;
enum { AVCaptureFlashModeOff = 0, AVCaptureFlashModeOn = 1, AVCaptureFlashModeAuto = 2 }; typedef NSInteger AVCaptureFlashMode;
enum { AVCaptureTorchModelOff = 0, AVCaptureTorchModelOn = 1, AVCaptureTorchModeAuto = 2 }; typedef NSInteger AVCaptureTorchMode;
enum { AVCaptureFocusModelLocked = 0, AVCaptureFocusModeAutoFocus = 1, AVCaptureFocusModeContinousAutoFocus = 2 }; typedef NSInteger AVCaptureFocusMode;
enum { AVCaptureExposureModeLocked = 0, AVCaptureExposureModeAutoExpose = 1, AVCaptureExposureModeContinuousAutoExposure = 2 }; typedef NSInteger AVCaptureExposureMode;
enum { AVCaptureWhiteBalanceModeLocked = 0, AVCaptureWhiteBalanceModeAutoWhiteBalance = 1, AVCaptureWhiteBalanceModeContinuousAutoWhiteBalance = 2 }; typedef NSInteger AVCaptureWhiteBalanceMode;
开启闪光灯
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];
}
标签:
原文地址:http://www.cnblogs.com/allanliu/p/4194620.html