Restart session added.

This commit is contained in:
nelanelanela 2014-10-16 12:08:42 +01:00
parent 0f590811f3
commit dba7ad7368
2 changed files with 16 additions and 1 deletions

View File

@ -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.
*/