VideoRecorderProtocol
public protocol VideoRecorderProtocol
Protocol to record a video with the rear camera.
Provides control over the recording process and camera preview. You can access the current state of the recording with status observable property.
The sequence of calls should be as follows:
initVideoRecorder(orientation)(usually onAppear and orientation change) call to init the rear camera and start receiving the preview into thepreviewLayerstartRecording()when the user presses the record button. This will start supplying the video frames to the recording session
When done:
stopRecording()when the user presses the stop button. Recording stops butpreviewLayercontinues to show the camera viewstopVideoRecorder()(usually onDisappear) to stop the preview and shutdown the camera
-
current status of the recorder
You can access the highlights found during the processing or after the processing is finished.
Note
this property updated only on the main threadDeclaration
Swift
var status: VideoRecorderStatus { get set } -
minimum zoom level for the camera
Declaration
Swift
var userFacingMinZoom: CGFloat { get } -
maximum zoom level for the camera
Declaration
Swift
var userFacingMaxZoom: CGFloat { get } -
current zoom level for the camera
Declaration
Swift
var userFacingZoom: CGFloat { get set } -
zoom level thresholds for the camera
Declaration
Swift
var userFacingZoomThresholds: [CGFloat] { get } -
max zoom level where the camera will start using digital zoom
Declaration
Swift
var userFacingUpscaleZoom: CGFloat { get } -
set new status object to track the video highlight processing
Declaration
Swift
func setStatusObject(_ status: VideoRecorderStatus) -
Initializes video recording session.
When used in UI this method should be called onAppear and then call
stopVideoRecorderonDisappearNote
This method should not be called on a main thread, either useTask.initorDispatchQueueDeclaration
Swift
@discardableResult func initVideoRecorder(orientation: AVCaptureVideoOrientation) -> BoolParameters
orientationorientation of the video according to the current phone orientation
Return Value
true on success
-
Stops everything related to video recording.
When used in UI this method should be called onDisappear. Can be called on main thread.
Declaration
Swift
func stopVideoRecorder() -
Sets the camera orientation for the recording
Should be called when the phone orientation changes. Has no effect if we are already recording. Can be called on main thread.
Declaration
Swift
func changeVideoOrientation(_ new: AVCaptureVideoOrientation)Parameters
newnew orientation
-
Starts recording video, i.e user pressed record button in UI for example
Can be called on main thread. It starts the recording initialization in async way. Check
VideoRecorderStatus.isRecordingto get if we actually recordingDeclaration
Swift
@discardableResult func startRecording() -> BoolReturn Value
true on success
-
Stops the recording if it is running now
Can be called on main thread. It stops the recording in async way. Check
VideoRecorderStatus.isRecordingto get if we actually stopped.Declaration
Swift
@discardableResult func stopRecording() -> BoolReturn Value
true if the recording was running and is stopped now
-
Video preview layer to be used in UI to preview what we capture
Note
This prop is not null only after theinitVideoRecorder()callDeclaration
Swift
var previewLayer: AVCaptureVideoPreviewLayer? { get } -
Sets the current zoom level of the video.
Declaration
Swift
func setZoom(_ val: CGFloat)Parameters
valnew zoom level
VideoRecorderProtocol Protocol Reference