iOS录音,调用麦克风话筒

来源:互联网 发布:同济大学软件研究生 编辑:程序博客网 时间:2024/04/27 21:21
AVAudioSession.sharedInstance().requestRecordPermission({ [weak self] (granted) in                guard let w = self else {                    return                }                if !granted {                    let alert = UIAlertController(title: "没有麦克风权限", message: "请在iPhone的“设置-隐私-麦克风”选项中,允许你的医生访问麦克风。", preferredStyle: .Alert)                    let jumpToSetting = UIAlertAction(title: "去设置", style: .Default, handler: { (sender) in                        UIApplication.sharedApplication().openURL(NSURL(string: UIApplicationOpenSettingsURLString)!)                        alert.dismissViewControllerAnimated(true, completion: nil)                    })                    alert.addAction(jumpToSetting)                    let cancel = UIAlertAction(title: "取消", style: .Cancel, handler: { (sender) in                        alert.dismissViewControllerAnimated(true, completion: nil)                    })                    alert.addAction(cancel)                    w.presentViewController(alert, animated: true, completion: nil)                } else {                    //获取权限成功                }            })

6 0
原创粉丝点击