Skip to content

Instantly share code, notes, and snippets.

@b-r-o
Created May 3, 2017 20:46
Show Gist options
  • Save b-r-o/9553c0cbff4b0700ae0dcb8ee2058e97 to your computer and use it in GitHub Desktop.
Save b-r-o/9553c0cbff4b0700ae0dcb8ee2058e97 to your computer and use it in GitHub Desktop.
Wrap up
public func flipCamera() {
sessionQueue.async { [unowned self] in
self.captureSession.beginConfiguration()
guard let currentCaptureInput = self.captureSession.inputs.first as? AVCaptureInput else { return }
self.captureSession.removeInput(currentCaptureInput)
guard let currentCaptureOutput = self.captureSession.outputs.first as? AVCaptureOutput else { return }
self.captureSession.removeOutput(currentCaptureOutput)
self.position = self.position == .front ? .back : .front
self.configureSession()
self.captureSession.commitConfiguration()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment