Add support of maxRecordedDuration
brightsider opened this issue · comments
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