Created
June 19, 2014 23:01
-
-
Save yojimbocorp/f2e1300835dd7a65394a to your computer and use it in GitHub Desktop.
Tu Telemundo Code Snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (IBAction)toggleCameras:(id)sender { | |
if (self.toggleCameraButton.enabled == NO) { | |
DLog(@"Don't allow toggle while button not enabled"); | |
return; | |
} | |
if (self.isRecording) { | |
DLog(@"Don't allow toggle while recording"); | |
return; | |
} | |
NSError *error; | |
AVCaptureDevicePosition position = [[self.activeVideoInput device] position]; | |
AVCaptureDeviceInput *videoInput; | |
if (position == AVCaptureDevicePositionBack) { | |
videoInput = [[AVCaptureDeviceInput alloc] initWithDevice:[self cameraWithPosition:AVCaptureDevicePositionFront] error:&error]; | |
self.previewLayer.transform = CATransform3DMakeRotation(M_PI, 0.0f, 1.0f, 0.0f); | |
} else { | |
videoInput = [[AVCaptureDeviceInput alloc] initWithDevice:[self cameraWithPosition:AVCaptureDevicePositionBack] error:&error]; | |
self.previewLayer.transform = CATransform3DIdentity; | |
} | |
if (videoInput) { | |
[self.captureSession beginConfiguration]; | |
[self.captureSession removeInput:self.activeVideoInput]; | |
if ([self.captureSession canAddInput:videoInput]) { | |
[self.captureSession addInput:videoInput]; | |
self.activeVideoInput = videoInput; | |
} | |
[self.captureSession commitConfiguration]; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment