如果我的应用没有,我需要提示用户输入麦克风权限。它是一个使用AVCaptureSession录制视频的视图控制器。我已经找到了如何使用AvAudioSession:
How to detect microphone input permission refused in iOS 7
但是,为了录制视频,是否可以使用AvCaptureSession执行相同操作?
由于
答案 0 :(得分:2)
这是苹果公司的示例代码
switch AVCaptureDevice.authorizationStatus(for: .video) {
case .authorized: // The user has previously granted access to the camera.
self.setupCaptureSession()
case .notDetermined: // The user has not yet been asked for camera access.
AVCaptureDevice.requestAccess(for: .video) { granted in
if granted {
self.setupCaptureSession()
}
}
case .denied: // The user has previously denied access.
return
case .restricted: // The user can't grant access due to restrictions.
return
}
我建议您尝试将麦克风使用的媒体类型更改为“ .audio”:
AVCaptureDevice.authorizationStatus(for: AVMediaType.audio)
来源:https://developer.apple.com/documentation/avfoundation/...