SwiftyCam icon indicating copy to clipboard operation
SwiftyCam copied to clipboard

[SwiftyCam]: Cannot take photo. Capture session is not running (swift4)

Open ge0rgetang opened this issue 7 years ago • 6 comments

Unable to manually call takePhoto() or startVideoRecording() - console prints that capture session is not running.

ge0rgetang avatar Sep 26 '17 22:09 ge0rgetang

Same here.

0x7061 avatar Oct 20 '17 12:10 0x7061

I have the same issue here.
I looked into the code. Seems like the following is never called to set sessionRunning to true

@objc private func captureSessionDidStartRunning() { sessionRunning = true DispatchQueue.main.async { self.cameraDelegate?.swiftyCamSessionDidStartRunning(self) } }

hence sessionRunning is always false

guard sessionRunning == true else { print("[SwiftyCam]: Cannot take photo. Capture session is not running") return }

would changing the guard to self.session.isRunning == true be a better check ?

specc avatar Nov 12 '17 00:11 specc

+1

prefect42 avatar Dec 11 '17 15:12 prefect42

Has anyone figured this out? If so what should I do? I'm having the same issue

UNLK8852 avatar Aug 01 '18 22:08 UNLK8852

@specc you are right, the reason is that captureSessionDidStartRunning method isn't called. This method receives notification from event named AVCaptureSessionDidStartRunning. Subscription happens in viewWillApear. Make sure that you call super.viewWillAppear in overrided method.

bohachevskyy avatar Feb 19 '19 21:02 bohachevskyy

this happend because your viewwillapper and viewdidapper don't have super.viewWillAppear(animated) so just added in viewWillAppear its work override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) }

sadabios avatar Jun 25 '20 11:06 sadabios