INNER CODE UNIT · Swift
initBarcodeComponents
AmolGangadhare/flutter_barcode_scanner · ios/Classes/SwiftFlutterBarcodeScannerPlugin.swift:265
func initBarcodeComponents(){
let deviceDiscoverySession = AVCaptureDevice.DiscoverySession(deviceTypes: [.builtInWideAngleCamera], mediaType: AVMediaType.video, position: .back)
// Get the back-facing camera for capturing videos
guard let captureDevice = deviceDiscoverySession.devices.first else {
print("Failed to get the camera device")
return
}
do {
// Get an instance of the AVCaptureDeviceInput class using the previous device object.
let input = try AVCaptureDeviceInput(device: captureDevice)
// Set the input device on the capture session.
if captureSession.inputs.isEmpty {
captureSession.addInput(input)
}
// Initialize a AVCaptureMetadataOutput object and set it as the output device to the capture session.