iOS Development

ios – Error Area=AVFoundationErrorDomain Code=-11803 “Can not Report”

Spread the love


Hi iOS group want your assist and strategies. I’m engaged on an utility the place I’m capturing picture from the again digital camera utilizing AVCaptureSession. It’s working positive with the units working iOS17+ however I’m going through an error on machine iPhone X working iOS 16.7.4

 error: Non-obligatory(Error Area=AVFoundationErrorDomain Code=-11803 "Can not Report" UserInfo={NSUnderlyingError=0x283f0b780 {Error Area=NSOSStatusErrorDomain Code=-16409 "(null)"}, NSLocalizedRecoverySuggestion=Strive recording once more., AVErrorRecordingFailureDomainKey=3, NSLocalizedDescription=Can not Report})

right here is my Code:

remaining class CedulaScanningVC: UIViewController {

var captureSession: AVCaptureSession!
var stillImageOutput: AVCapturePhotoOutput!
var videoPreviewLayer: AVCaptureVideoPreviewLayer!

var delegate: ScanCedulaDelegate?

override func viewDidLoad() {
    tremendous.viewDidLoad()
}


override func viewWillAppear(_ animated: Bool) {
    tremendous.viewWillAppear(animated)
}

override func viewWillDisappear(_ animated: Bool) {
    tremendous.viewWillDisappear(animated)
    self.captureSession.stopRunning()
}

override func viewDidAppear(_ animated: Bool) {
    tremendous.viewDidAppear(animated)
    setupCamera()
}

// MARK: - Configure Digital camera


func setupCamera()  {
    
    captureSession = AVCaptureSession()
    captureSession.sessionPreset = .medium
    
    guard let backCamera = AVCaptureDevice.default(for: AVMediaType.video)
        else {
            print("Unable to entry again digital camera!")
            return
    }
    
    let enter: AVCaptureDeviceInput
    do {
        enter = strive AVCaptureDeviceInput(machine: backCamera)
        //Step 9
        stillImageOutput = AVCapturePhotoOutput()

        if captureSession.canAddInput(enter) && captureSession.canAddOutput(stillImageOutput) {
            captureSession.addInput(enter) 
            captureSession.addOutput(stillImageOutput)
            setupLivePreview()
        }
    }
    catch let error  {
        print("Error Unable to initialize again digital camera:  (error.localizedDescription)")
    }
    
}

func setupLivePreview() {
    
    videoPreviewLayer = AVCaptureVideoPreviewLayer(session: captureSession)
    
    videoPreviewLayer.videoGravity = .resizeAspectFill
    videoPreviewLayer.connection?.videoOrientation = .portrait
    self.view.layer.addSublayer(videoPreviewLayer)
    
    //Step12
    DispatchQueue.international(qos: .userInitiated).async { [weak self] in
        self?.captureSession.startRunning()
        //Step 13
        DispatchQueue.most important.async {
            self?.videoPreviewLayer.body = self?.view.bounds ?? .zero
        }
    }
}

func failed() {
    let ac = UIAlertController(title: "Scanning not supported", message: "Your machine doesn't assist scanning a code from an merchandise. Please use a tool with a digital camera.", preferredStyle: .alert)
    ac.addAction(UIAlertAction(title: "OK", fashion: .default))
    current(ac, animated: true)
    captureSession = nil
}

// MARK: - actions

func cameraButtonPressed() {
    let settings = AVCapturePhotoSettings(format: [AVVideoCodecKey: AVVideoCodecType.jpeg])
    stillImageOutput.capturePhoto(with: settings, delegate: self)
}

  }


  extension CedulaScanningVC: AVCapturePhotoCaptureDelegate {

func photoOutput(_ output: AVCapturePhotoOutput, didFinishProcessingPhoto picture: AVCapturePhoto, error: Error?) {
    
    print("error: (error)")
    captureSession.stopRunning()
    DispatchQueue.most important.asyncAfter(deadline: .now() + 1.0) { [weak self] in
        
        guard let self = self else {return}
        guard let imageData = picture.fileDataRepresentation()
            else {
            print("NO picture captured")
            return
            
        }
        
        let picture = UIImage(information: imageData)
        self.delegate?.capturedImage(picture: picture)
    }
}
}

Any assist or suggestion could be appreciated.

Leave a Reply

Your email address will not be published. Required fields are marked *