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

后端 未结 11 1388
闹比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:08

    Swift 4 (xCode 10.1)

    This is what worked for me in the latest version of Swift. I did not see this answer, and it took me a while to suss out so here is how to get the front facing camera.

     if let device = AVCaptureDevice.defaultDevice(withDeviceType: .builtInWideAngleCamera , mediaType: AVMediaTypeVideo, position: .front)  {
        //Do the camera thing here..
    }
    

提交回复
热议问题