Skip to content

Instantly share code, notes, and snippets.

@nickmeehan
Created November 7, 2016 20:39
Show Gist options
  • Save nickmeehan/04b30ac0a5669aba9370fb9e2ef9025a to your computer and use it in GitHub Desktop.
Save nickmeehan/04b30ac0a5669aba9370fb9e2ef9025a to your computer and use it in GitHub Desktop.
AVFoundation - beginSession
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