【发布时间】:2012-04-27 10:45:06
【问题描述】:
如何在视图中录制音频并在父视图中弹出后获取保存的音频文件?
我在故事板中使用嵌入式导航控制器。
我的子视图中有这段代码。
NSArray *dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docsDir = [dirPaths objectAtIndex:0];
tempFilePath = [NSURL fileURLWithPath:[docsDir stringByAppendingPathComponent:[NSString stringWithFormat: @"record.%@", @"caf"]]];
NSMutableDictionary* recordSetting = [[NSMutableDictionary alloc] init];
[recordSetting setValue :[NSNumber numberWithInt:kAudioFormatAppleIMA4] forKey:AVFormatIDKey];
[recordSetting setValue:[NSNumber numberWithFloat:44100.0] forKey:AVSampleRateKey];
[recordSetting setValue:[NSNumber numberWithInt: 2] forKey:AVNumberOfChannelsKey];
audioRecorder = [[ AVAudioRecorder alloc] initWithURL:tempFilePath settings:recordSetting error:nil];
[audioRecorder setDelegate:self];
[audioRecorder prepareToRecord];
[audioRecorder record];
现在,我要如何在我的父控制器中获取它?
【问题讨论】:
-
我是否记录了这项权利并将其保存到文档中?
标签: ios ios5 core-audio