CameraManager icon indicating copy to clipboard operation
CameraManager copied to clipboard

Completion not firing when stopVideoRecording is calling

Open f3rr13r opened this issue 7 years ago • 6 comments

Implemented CameraManager a month ago for my custom video camera, and all was working very well. However, having returned back to the project, the completion block within stopVideoRecording does not fire anymore.

Having delved into the CameraManager code and investigating breakpoints, I have pin pointed it to the function:

executeVideoCompletionWithURL

The attempt to get videoCompletion, and store it in validCompletion is failing. Having set a didSet check within videoCompletion on line 247, it is apparent that the value of completion within stopVideoRecording IS being successfully passed in, but when settings a breakpoint on line inside _executeVideoCompletion, the following occurs (see screenshot below). It seems that due to this 'partial apply forward' issue, that the completion is never hit in my CameraVC.

Have any changes been made to the way that this specific thing is working within the last month or so? Or do you have any suggestions on how this could be prevented? Or if I am way off the mark, does anybody know a fix to this? Hope that this can be resolved as I really want to continue using this awesome pod.

Thanks in advance

screen shot 2018-09-05 at 1 09 14 am

f3rr13r avatar Sep 05 '18 00:09 f3rr13r

@f3rr13r did you ever find a solution to this issue? I am running into the same thing, unfortunately.

Bengejd avatar Sep 26 '18 16:09 Bengejd

So after using some print statements in my project, I have found the root of this issue. Basically, CameraManager, is not properly changing the output mode when you attempt to record with video, so the output mode is still cameraManager.cameraOutputMode = .stillImage

So I added the following in my videoRecord blocks:

StartVideoRecording

if(cameraManager.cameraOutputMode == .stillImage) {
        print("Camera output is stillImage, switching to videoWithMic");
        cameraManager.cameraOutputMode = CameraOutputMode.videoWithMic;
    }

    cameraManager.startRecordingVideo();

And then, you have to switch it back to .stillImage in your stopVideoRecording, but only after it outputs the videoURL. So you have to switch the output mode in the stopRecording block.

StopVideoRecording

cameraManager.stopVideoRecording { (URL, error) in
    print("Video Recording URL: ", URL!);
    
    if(cameraManager.cameraOutputMode == .videoWithMic) {
        cameraManager.cameraOutputMode = CameraOutputMode.stillImage;
    }
}

You'll receive the videoURL in the completion block, and then you have to switch it back to being a stillImage output. Simple as that, can't believe this has been bugging me for a few weeks now, and the solution was so simple.

Bengejd avatar Sep 27 '18 16:09 Bengejd

So after using some print statements in my project, I have found the root of this issue. Basically, CameraManager, is not properly changing the output mode when you attempt to record with video, so the output mode is still cameraManager.cameraOutputMode = .stillImage

So I added the following in my videoRecord blocks:

StartVideoRecording

if(cameraManager.cameraOutputMode == .stillImage) {
        print("Camera output is stillImage, switching to videoWithMic");
        cameraManager.cameraOutputMode = CameraOutputMode.videoWithMic;
    }

    cameraManager.startRecordingVideo();

And then, you have to switch it back to .stillImage in your stopVideoRecording, but only after it outputs the videoURL. So you have to switch the output mode in the stopRecording block.

StopVideoRecording

cameraManager.stopVideoRecording { (URL, error) in
    print("Video Recording URL: ", URL!);
    
    if(cameraManager.cameraOutputMode == .videoWithMic) {
        cameraManager.cameraOutputMode = CameraOutputMode.stillImage;
    }
}

You'll receive the videoURL in the completion block, and then you have to switch it back to being a stillImage output. Simple as that, can't believe this has been bugging me for a few weeks now, and the solution was so simple.

Thanks, was struggling with this for a bit. Docs made it a little confusing but this solved my issue!

omartehsin1 avatar Aug 28 '19 19:08 omartehsin1

I tried to use same code in my project but it was working well for .stillImage and .videoOnly. But If I set output mode into .videoWithMic, stopRecording callback is not fired.

mob-rockstar avatar Feb 11 '20 12:02 mob-rockstar

@Bengejd did you face same issue ?

mob-rockstar avatar Feb 11 '20 12:02 mob-rockstar

@mob-rockstar

are you still facing issues with the latest version v5.1.3?

torrao avatar Apr 20 '20 13:04 torrao