ios7-录音权限访问-AVAudioSession
来源:互联网 发布:sai for mac中文版 编辑:程序博客网 时间:2024/05/21 06:16
ios7新增api requestRecordPermission
api 说明:
- (void)requestRecordPermission:(PermissionBlock)response
Description
Request the user’s permission for audio recording.
Recording audio requires explicit permission from the user. The system automatically prompts the user for permission if you use any session categories that enable recording, or you can call this method to prompt for permission at a time of your choosing. After the user grants or denies permission, the system remembers the choice for future use in the same app. If permission is not granted, or if the user has not yet responded to the permission prompt, any audio recording sessions record only silence.
The response parameter is a block of the PermissionBlock type, whose sole parameter indicates whether the user granted or denied permission to record. This method always returns immediately: if the user has previously granted or denied recording permission, it executes the block when called; otherwise, it displays an alert and executes the block only after the user has responded to the alert.
Parameters
response
A block to be called when recording permission has been granted or denied.
Availability iOS (7.0 and later)
新增api,获取录音权限.
返回值,YES为无拒绝,NO为拒绝录音.
-(BOOL)canRecord
{__block BOOL bCanRecord = YES;
if ([[[UIDevice currentDevice] systemVersion] compare:@"7.0"] != NSOrderedAscending)
{
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
if ([audioSession respondsToSelector:@selector(requestRecordPermission:)]) {
[audioSession performSelector:@selector(requestRecordPermission:) withObject:^(BOOL granted) {
if (granted) {
bCanRecord = YES;
}
else {
bCanRecord = NO;
dispatch_async(dispatch_get_main_queue(), ^{
[[[[UIAlertView alloc] initWithTitle:nil
message:@"app需要访问您的麦克风。\n请启用麦克风-设置/隐私/麦克风"
delegate:nil
cancelButtonTitle:@"关闭"
otherButtonTitles:nil] autorelease] show];
});
}
}];
}
}
return bCanRecord;
}
- ios7-录音权限访问-AVAudioSession
- ios7-录音权限访问-AVAudioSession
- IOS开发 录音权限访问-AVAudioSession
- AVAudioSession
- AVAudioSession
- AVAudioSession
- AVAudioSession
- AVAudioSession
- AVAudioSession
- AVAudioSession
- AVAudioSession
- AVAudioSession
- AVAudioSession
- iOS7 AVAudioRecorder不能录音
- iOS7 AVAudioRecorder录音
- 利用AVFoundation框架实现录音和播放(AVAudioSession、AVAudioRecorder、AVAudioPlayer)
- ios6 ios7 访问和使用系统通讯录权限
- ios7下不能录音问题解决
- struts2标签应用 需在web.xml中 配置
- POJ 3241 Object Clustering (曼哈顿距离最小生成树)
- SDWebImage手动清除缓存的方法
- zend debugger安装配置
- 利用LNMP搭建wordpress
- ios7-录音权限访问-AVAudioSession
- 有关sleep runloop
- 搭建Linux下邮件服务器(extmail+postfix+clamav)
- android面试题总结加强再加强版(二)
- HTML中Get和Post请求的简单了解
- KMP算法
- java基础<多线程>
- android面试题总结加强再加强版(三)
- 【文件】MFC序列化存储分析