Saturday, January 13, 2024
HomeiOS Developmentios - Error Area=AVFoundationErrorDomain Code=-11803 "Can not File"

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


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

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

right here is my Code:

closing 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 = attempt 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.world(qos: .userInitiated).async { [weak self] in
        self?.captureSession.startRunning()
        //Step 13
        DispatchQueue.primary.async {
            self?.videoPreviewLayer.body = self?.view.bounds ?? .zero
        }
    }
}

func failed() {
    let ac = UIAlertController(title: "Scanning not supported", message: "Your machine doesn't help scanning a code from an merchandise. Please use a tool with a digital camera.", preferredStyle: .alert)
    ac.addAction(UIAlertAction(title: "OK", model: .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.primary.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(knowledge: imageData)
        self.delegate?.capturedImage(picture: picture)
    }
}
}

Any assist or suggestion could be appreciated.



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments