IOS devicesWithMediaType deprecated

前端 未结 2 1137
一个人的身影
一个人的身影 2021-02-09 12:02

I am currently using the method:

NSArray *captureDevices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo];

to get a list of devices but X

2条回答
  •  迷失自我
    2021-02-09 12:46

    Create AVCaptureDeviceDiscoverySession for your requirement and then call devices method to get Array of currently available devices matching the session’s criteria

    Code:

    AVCaptureDeviceDiscoverySession *captureDeviceDiscoverySession = [AVCaptureDeviceDiscoverySession discoverySessionWithDeviceTypes:@[AVCaptureDeviceTypeBuiltInWideAngleCamera] 
                                          mediaType:AVMediaTypeVideo 
                                           position:AVCaptureDevicePositionBack];
    NSArray *captureDevices = [captureDeviceDiscoverySession devices];
    

    Swift 4+

    let discoverySession = AVCaptureDevice.DiscoverySession(deviceTypes: [.builtInWideAngleCamera], mediaType: .video, position: .back)
    

    Available

    Device types

    Media types

    Position

提交回复
热议问题