Closed aleene closed 7 years ago
Currently I'm using
AVCaptureDevice.defaultDevice(withMediaType: AVMediaTypeVideo)
I changed captureDevice() to this, in order to remove the compiler warning:
` func captureDevice() -> AVCaptureDevice? { let allTypes = [AVCaptureDeviceType.builtInDuoCamera, AVCaptureDeviceType.builtInWideAngleCamera, AVCaptureDeviceType.builtInTelephotoCamera ]
if let currentSession = AVCaptureDeviceDiscoverySession.init(deviceTypes: allTypes, mediaType: AVMediaTypeVideo, position: (self.device?.position)!) {
if let validDevices = currentSession.devices {
for device in validDevices {
if self.device?.position == AVCaptureDevicePosition.back {
if device.position == AVCaptureDevicePosition.front {
return device
}
} else if self.device?.position == AVCaptureDevicePosition.front {
if device.position == AVCaptureDevicePosition.back {
return device
}
}
}
}
}
return nil
}
`
We are supposed to use AVCaptureDeviceDiscoverySession.
not sure how I should change this.