IOS录制音频 我用的是AVAudioRecorder这个控件,默认录制为caf格式文件,可用第三方lame转成mp3格式文件
使用前先引用框架 <AVFoundation/AVFoundation.h
>
1.录音用的控件是AVAudioRecorder,录音的主要代码:
recordedFile=[NSURL URLWithString:[NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat: @"%@.%@", @"aaa",@"caf"]]];//录音文件的位置
recorder = [[AVAudioRecorder alloc] initWithURL:recordedFile settings:recordSetting error:nil];
[recorder setDelegate:self];
[recorder prepareToRecord];
[recorder record];
2.录音完成后,引用了lame之后,转化的过程核心代码:
NSString *cafFilePath =[NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.