Created
October 23, 2020 00:32
-
-
Save rorodriguez116/18740e67c833ff06148389b0fedd5421 to your computer and use it in GitHub Desktop.
Starts the capture session
This file contains hidden or 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
/// - Tag: Start capture session | |
public func start() { | |
// We use our capture session queue to ensure our UI runs smoothly on the main thread. | |
sessionQueue.async { | |
if !self.isSessionRunning && self.isConfigured { | |
switch self.setupResult { | |
case .success: | |
self.session.startRunning() | |
self.isSessionRunning = self.session.isRunning | |
if self.session.isRunning { | |
DispatchQueue.main.async { | |
self.isCameraButtonDisabled = false | |
self.isCameraUnavailable = false | |
} | |
} | |
case .configurationFailed, .notAuthorized: | |
print("Application not authorized to use camera") | |
DispatchQueue.main.async { | |
self.alertError = AlertError(title: "Camera Error", message: "Camera configuration failed. Either your device camera is not available or its missing permissions", primaryButtonTitle: "Accept", secondaryButtonTitle: nil, primaryAction: nil, secondaryAction: nil) | |
self.shouldShowAlertView = true | |
self.isCameraButtonDisabled = true | |
self.isCameraUnavailable = true | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment