采用的AVAudioRecorder这个框架来进行录音
这个录音跟官方网站上的speakHere有些区别,最大的区别是,这个必须要录制完成才能处理文件,而speakhere示例是可以实现边录制边上传的效果。
#import
#import
引入框架,这是使用录音功能的基本配备
先说明一点,默认AVAudioRecorder录制后的格式是.caf,而大部分的播放器都是不支持这个格式的,下面一段设置是可以让录制格式是wav的格式
NSDictionary *recordSetting = [[NSDictionary alloc] initWithObjectsAndKeys:
NSURL *recordedTmpFile = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathCom
//Setup the recorder to use this file and record to it.
AVAudioRecorder *recorder = [[ AVAudioRecorder alloc] initWithURL:recordedTmpFile settings:recordSetting error:&error];
[recorder prepareToRecord];
[recorder record];
下面代码应该是当前.m文件加载时候就设置
AVAudioSession * audioSession = [AVAudioSession sharedInstance];
[audioSession setCategory:AVAudioSessionCategoryPl
[audioSession setActive:YES error: &error];//设置当前应用音频活跃性