Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Type 'String!' has no member 'video'

Tags:

ios

swift

import UIKit
import AVKit

class ViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()

//start camera

        let captureSession = AVCaptureSession()

        guard let captureDevice =
           AVCaptureDevice.default(for: .video) else { return }
        guard let input = try? AVCaptureDeviceInput(device:
                captureDevice ) else { return }
        captureSession.addInput(input)

        captureSession.startRunning()
    }
}

I get the error in this line at (for: .video):

AVCaptureDevice.default(for: .video) else { return }
like image 838
David Avatar asked Jun 14 '26 21:06

David


1 Answers

Replacing AVMediaType.video with AVMediaTypeVideo worked for me.

like image 195
Deep Shah Avatar answered Jun 16 '26 11:06

Deep Shah



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!