diff --git a/camera.xcodeproj/project.xcworkspace/xcuserdata/nataliaterlecka.xcuserdatad/UserInterfaceState.xcuserstate b/camera.xcodeproj/project.xcworkspace/xcuserdata/nataliaterlecka.xcuserdatad/UserInterfaceState.xcuserstate index ba960be..c89466f 100644 Binary files a/camera.xcodeproj/project.xcworkspace/xcuserdata/nataliaterlecka.xcuserdatad/UserInterfaceState.xcuserstate and b/camera.xcodeproj/project.xcworkspace/xcuserdata/nataliaterlecka.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/camera/CameraManager.swift b/camera/CameraManager.swift index 3d9c022..381613c 100644 --- a/camera/CameraManager.swift +++ b/camera/CameraManager.swift @@ -245,7 +245,7 @@ class CameraManager: NSObject, AVCaptureFileOutputRecordingDelegate { } /** - Inits a capture session and adds a preview layer to the given view. Preview layer bounds will automaticaly be set to match given view. + Inits a capture session and adds a preview layer to the given view. Preview layer bounds will automaticaly be set to match given view. Default session is initialized with still image output. :param: view The view you want to add the preview layer to :param: cameraOutputMode The mode you want capturesession to run image / video / video and microphone @@ -280,6 +280,21 @@ class CameraManager: NSObject, AVCaptureFileOutputRecordingDelegate { self.captureSession?.stopRunning() } + /** + Restarts capture session. + */ + func restartCaptureSession() + { + if let validCaptureSession = self.captureSession? { + validCaptureSession.startRunning() + } else { + if self.cameraIsSetup { + self.stopAndRemoveCaptureSession() + } + self._setupCamera({Void -> Void in }) + } + } + /** Stops running capture session and removes all setup devices, inputs and outputs. */