imaginary-cloud / CameraManager

Simple Swift class to provide all the configurations you need to create custom camera view in your app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add support of maxRecordedDuration

brightsider opened this issue · comments

commented

Hi @brightsider, from what I understand, using maxRecordedDuration is not the proper way to stop recording after x seconds, that's because the delegate is always called with an error when that happens and it makes the verification of the recording status messy. I recommend you to use a DispatchWorkItem for that.

Something like this

cameraManager.startRecordingVideo()
let requestWorkItem = DispatchWorkItem {
            cameraManager.stopVideoRecording { // completion handler }
}
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(yourMaxRecordedDuration), execute: requestWorkItem)

Don't forget to call requestWorkItem.cancel() when the user stops the recording before yourMaxRecordedDuration