本文介绍了不推荐使用iOS设备WithMediaType的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我当前正在使用方法:
NSArray *captureDevices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo];
获取设备列表,但XCode向我发出警告:
to get a list of devices but XCode is giving me a warning:
Use AVCaptureDeviceDiscoverySession instead
我查看了文档,但不知道如何访问设备数组
I have looked at the documentation but do not know how to access the devices array
AVCaptureDeviceDiscoverySession *session = [[AVCaptureDeviceDiscoverySession alloc]init];
???
推荐答案
创建 AVCaptureDeviceDiscoverySession
根据您的要求,然后调用devices
方法获取与会话标准匹配的当前可用设备的Array
Create AVCaptureDeviceDiscoverySession
for your requirement and then call devices
method to get Array
of currently available devices matching the session’s criteria
代码:
AVCaptureDeviceDiscoverySession *captureDeviceDiscoverySession = [AVCaptureDeviceDiscoverySession discoverySessionWithDeviceTypes:@[AVCaptureDeviceTypeBuiltInWideAngleCamera]
mediaType:AVMediaTypeVideo
position:AVCaptureDevicePositionBack];
NSArray *captureDevices = [captureDeviceDiscoverySession devices];
### Swift 4
###Swift 4
let discoverySession = AVCaptureDevice.DiscoverySession(deviceTypes: [.builtInWideAngleCamera], mediaType: .video, position: .back)
这篇关于不推荐使用iOS设备WithMediaType的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!