PBJVISION - Error switching from cameraMode.Video to cameraMode.Photo

202 Views Asked by At

I am using 'PBJVISION' in my app for Instagram like touch-to-record feature. It works fine but when I try to switch from PBJCameraMode.Video to PBJCameraMode.Photo, I am receiving an error;

reason: -[AVCaptureStillImageOutput captureStillImageAsynchronouslyFromConnection:completionHandler:] - inconsistent state.'

My code is pretty straightforward;

@IBAction func changeCameraModeAction(sender: AnyObject) {
    if recordFlag == false {
        PBJVision.sharedInstance().maximumCaptureDuration = CMTimeMakeWithSeconds(kTotalVideoLength, kVideoFramePerSec)
        PBJVision.sharedInstance().cameraMode = PBJCameraMode.Video

        recordFlag = true

    } else {
        progressBarView.hidden = true
        PBJVision.sharedInstance().cameraMode = PBJCameraMode.Photo
        recordFlag = false
        }
}

Can you please help me?

Thanks, E.

1

There are 1 best solutions below

0
igpogo On BEST ANSWER

I had the same error when before I took down and set up the AVCaptureSession.

I only had spotted in iPhone 6.

Something it happen even when I do this in the main thread. I haven't use PBJVISION though. My error

    App crashing with exception: *** -[AVCaptureStillImageOutput captureStillImageAsynchronouslyFromConnection:completionHandler:] - inconsistent state.

   *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '*** -[AVCaptureStillImageOutput captureStillImageAsynchronouslyFromConnection:completionHandler:] - inconsistent state.'

I will update if I get more insight on this.