How to get front camera, back camera and audio with AVCaptureDeviceDiscoverySession

后端 未结 11 1397
闹比i
闹比i 2020-12-12 20:58

Before iOS 10 came out I was using the following code to get the video and audio capture for my video recorder:

 for device in AVCaptureDevice.devices()
 {
          


        
11条回答
  •  死守一世寂寞
    2020-12-12 21:22

    You can get the front camera with the following:

    AVCaptureDevice.default(.builtInWideAngleCamera, for: AVMediaType.video, position: .front)
    

    The back camera:

    AVCaptureDevice.default(.builtInWideAngleCamera, for: AVMediaType.video, position: .back)
    

    And the microphone:

    AVCaptureDevice.default(.builtInMicrophone, for: AVMediaType.audio, position: .unspecified)
    

提交回复
热议问题