Created
November 7, 2016 20:39
-
-
Save nickmeehan/04b30ac0a5669aba9370fb9e2ef9025a to your computer and use it in GitHub Desktop.
AVFoundation - beginSession
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
func beginSession() { | |
do { | |
let deviceInput = try AVCaptureDeviceInput(device: self.captureDevice) | |
self.captureSession.addInput(deviceInput) | |
} catch { | |
// Handle error and return early. | |
} | |
self.previewLayer = AVCaptureVideoPreviewLayer(session: self.captureSession) | |
if let preview = self.previewLayer { | |
self.view.layer.addSublayer(preview) | |
preview.frame = self.view.layer.frame | |
self.captureSession.startRunning() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment