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

StopVideoRecording doesn't trigger completion block in every cases

CallMeMeow opened this issue · comments

Hello,

Firstly, thanks for you work!

I'm using CameraManager to create an instagram like experience recording videos or taking pictures. In order to do that, I have one button to record a video and take a picture. Doing that made me realize that if startVideoRecording and stopVideoRecording are called too closely from each other, then the movieOutput is not recording when stopVideoRecording is triggered.

So I looked at that:

open func stopVideoRecording(_ completion: ((_ videoURL: URL?, _ error: NSError?) -> Void)?) {
if let runningMovieOutput = movieOutput,
runningMovieOutput.isRecording {
videoCompletion = completion
runningMovieOutput.stopRecording()
}
}

The completion is not called when this if is not satisfied. I think it would make sense to have an else statement here to call the completion with an error saying that a video couldn't be recorded.
Correct me if you think I'm wrong but I think that a completion should be called in any case if it exists.
For the time being I found a workaround using the captureSession, hope this helps!

Thank you!

@CallMeMeow

thanks for your feedback. You are right, the completion should be called to account for those edge cases. I'm currently doing some improvements regarding the video recording, so in the next release I will probably include your suggestion.

Hello guyzz,
Working perfectly fine with v5.1.3. What I have did just call "cameraManager.cameraOutputMode = .videoWithMic/.videoWithoutMic" before starting video recording.