Filter out true-depth-camera in getAvailableCameraDevices
This commit is contained in:
@@ -89,7 +89,14 @@ final class CameraViewManager: RCTViewManager {
|
||||
final func getAvailableCameraDevices(_ resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
||||
withPromise(resolve: resolve, reject: reject) {
|
||||
let discoverySession = AVCaptureDevice.DiscoverySession(deviceTypes: getAllDeviceTypes(), mediaType: .video, position: .unspecified)
|
||||
return discoverySession.devices.map {
|
||||
let devices = discoverySession.devices.filter({
|
||||
if #available(iOS 11.1, *) {
|
||||
// exclude the true-depth camera. The True-Depth camera has YUV and Infrared, can't take photos!
|
||||
return $0.deviceType != .builtInTrueDepthCamera
|
||||
}
|
||||
return true
|
||||
})
|
||||
return devices.map {
|
||||
return [
|
||||
"id": $0.uniqueID,
|
||||
"devices": $0.physicalDevices.map(\.deviceType.descriptor),
|
||||
|
@@ -23,14 +23,6 @@ extension AVCaptureDevice.DeviceType {
|
||||
break
|
||||
}
|
||||
}
|
||||
if #available(iOS 11.1, *) {
|
||||
switch self {
|
||||
case .builtInTrueDepthCamera:
|
||||
return "true-depth-camera"
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
switch self {
|
||||
case .builtInDualCamera:
|
||||
return "dual-camera"
|
||||
@@ -39,6 +31,7 @@ extension AVCaptureDevice.DeviceType {
|
||||
case .builtInWideAngleCamera:
|
||||
return "wide-angle-camera"
|
||||
default:
|
||||
// e.g. `.builtInTrueDepthCamera`
|
||||
fatalError("AVCaptureDevice.Position has unknown state.")
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user