AVCaptureDevice requestAccessForMediaType:

问题描述 投票:1回答:1

MacOS 10.14

<key>NSMicrophoneUsageDescription</key>
    <string>Record audio!</string>

这在一个快速的项目中起作用:

AVCaptureDevice.requestAccess(for: .audio) { granted in
            if granted {
                //self.setupCaptureSession()
            }
        }

但是这在ObjectiveC项目中不起作用(线程8:信号SIGABRT)

[AVCaptureDevice requestAccessForMediaType:AVMediaTypeAudio completionHandler:^(BOOL granted) {
            if (granted) {
                //self.microphoneConsentState = PrivacyConsentStateGranted;
            }
            else {
                //self.microphoneConsentState = PrivacyConsentStateDenied;
            }
        }];

我在ObjectiveC项目中做错了什么或错过了什么? (我不想将项目转换为swift。)

任何帮助表示赞赏。谢谢,保罗

objective-c crash avcapturedevice
1个回答
0
投票
为了使用AVCaptureDevice,您需要添加两个项目的描述,即NSCameraUsageDescription, NSMicrophoneUsageDescription
© www.soinside.com 2019 - 2024. All rights reserved.