iOS开发(OC)——录音
2016-07-08 13:38
302 查看
//录音需要的字典 NSMutableDictionary *settings = [NSMutableDictionary dictionary]; [settings setValue:[NSNumber numberWithFloat:44100.0] forKey:AVSampleRateKey]; [settings setValue:[NSNumber numberWithInt:kAudioFormatLinearPCM] forKey:AVFormatIDKey]; [settings setValue:[NSNumber numberWithInt:1] forKey:AVNumberOfChannelsKey]; [settings setValue:[NSNumber numberWithInt:16] forKey:AVLinearPCMBitDepthKey]; [settings setValue:[NSNumber numberWithBool:NO] forKey:AVLinearPCMIsBigEndianKey]; [settings setValue:[NSNumber numberWithBool:NO] forKey:AVLinearPCMIsFloatKey]; recoder = [[AVAudioRecorder alloc] initWithURL:[NSURL fileURLWithPath:[self recordFilePath]] settings:settings error:nil]; //开始准备录音,使用此方法可以减少录音的延迟时间 [recoder prepareToRecord]; [recoder record];
//录音存放地址
-(NSString *)recordFilePath{ NSString *recordFile = @"record.wav";//wav格式iOS和android通用 NSString *documentPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; NSString *recordFlod = [documentPath stringByAppendingPathComponent:@"RecordFlod"]; if (![[NSFileManager defaultManager] fileExistsAtPath:recordFlod]) { [[NSFileManager defaultManager] createDirectoryAtPath:recordFlod withIntermediateDirectories:YES attributes:nil error:nil]; } recordFile = [recordFlod stringByAppendingPathComponent:recordFile]; return recordFile; }
相关文章推荐
- Android App调用MediaRecorder实现录音功能的实例
- Android录音时获取分贝值的方法代码实例
- Android简单的利用MediaRecorder进行录音的实例代码
- android编程实现电话录音的方法
- Android录音应用实例教程
- ios下录音
- AVAudioRecorder 录音
- BroadcastReceiver实现android来去电录音功能(外录)
- IOS录音发送
- iOS利用GCDAsyncSocket发送语音,以及语音wav转码amr
- iOS利用GCDAsyncSocket发送语音,以及语音wav转码amr
- Android使用录音(WAV格式)
- html5实现录音、拍摄功能
- android 录音和播放录音
- 在IM中拿来就用的录音Demo
- python-利用pyaudio进行声音录制及简单实例代码分享
- alsa编程播放wav
- android录音开发
- [iOS备忘录]使用蓝牙耳机headset录音
- iOS下录音功能的实现