美文网首页
iOS麦克风权限

iOS麦克风权限

作者: nihau | 来源:发表于2017-08-10 16:48 被阅读1209次
       
        AVAuthorizationStatus videoAuthStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeAudio];
        if (videoAuthStatus == AVAuthorizationStatusNotDetermined) {// 未询问用户是否授权
            //第一次询问用户是否进行授权
            [[AVAudioSession sharedInstance] requestRecordPermission:^(BOOL granted) {
                // CALL YOUR METHOD HERE - as this assumes being called only once from user interacting with permission alert!
                if (granted) {
                    // Microphone enabled code
                }
                else {
                    // Microphone disabled code
                }
            }];
        }
        else if(videoAuthStatus == AVAuthorizationStatusRestricted || videoAuthStatus == AVAuthorizationStatusDenied) {// 未授权
            //        [self showSetAlertView];
            NSLog(@"1111111");
        }
        else{// 已授权
            //        [self recordVoiceStart];
        }
    

    相关文章

      网友评论

          本文标题:iOS麦克风权限

          本文链接:https://www.haomeiwen.com/subject/yyghrxtx.html