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

when view goes to background , capture session is getting nil and stop recording is not working

chiragkukreja opened this issue · comments

can anybody tell, why this is happening , when view goes to background , capture session is getting nil and stop recording is not working

i just debug the issue and found that
open func fileOutput(_ captureOutput: AVCaptureFileOutput, didFinishRecordingTo outputFileURL: URL, from connections: [AVCaptureConnection], error: Error?) is giving error

Error Domain=AVFoundationErrorDomain Code=-11818 "Recording Stopped" UserInfo={NSLocalizedDescription=Recording Stopped, AVErrorRecordingSuccessfullyFinishedKey=true, NSLocalizedRecoverySuggestion=Stop any other actions using the recording device and try again., NSUnderlyingError=0x1c084c1e0 {Error Domain=NSOSStatusErrorDomain Code=-16414 "(null)"}}

Hi,

A possible solution could be to set a notification for when the app moves to background to pause the captureSession (or do whatever you want to do) and then another notification to resume the captureSession (or whatever you want to do) when the app returns to foreground

i.e

NotificationCenter.default.addObserver(self, selector: #selector(appMovedToBackground), name: Notification.Name.UIApplicationWillResignActive, object: nil)

i tried the same thing but when u go background , this function
open func fileOutput(_ captureOutput: AVCaptureFileOutput, didFinishRecordingTo outputFileURL: URL, from connections: [AVCaptureConnection], error: Error?)
gets automatically called with error.

Any update about this issue:

we are facing same on iPad device. works fine for iphones.

error detail
[SwiftyCam]: Movie file finishing error: Error Domain=AVFoundationErrorDomain Code=-11818 "Recording Stopped" UserInfo={NSLocalizedDescription=Recording Stopped, AVErrorRecordingSuccessfullyFinishedKey=true, NSLocalizedRecoverySuggestion=Stop any other actions using the recording device and try again., NSUnderlyingError=0x28055ae20 {Error Domain=NSOSStatusErrorDomain Code=-16414 "(null)"}}

At the moment it's not possible for me to test on an iPad. Did you managed to identify the problem @Usman4Github ?

Closing due to inactivity