我正在尝试像这样实例化一个AVAudioRecorder:
NSMutableDictionary* recordSetting = [[NSMutableDictionary alloc]init];
[recordSetting setValue:[NSNumber numberWithInt:kAudioFormatMPEGLayer3] forKey:AVFormatIDKey];
[recordSetting setValue:[NSNumber numberWithFloat:44100.0] forKey:AVSampleRateKey];
[recordSetting setValue:[NSNumber numberWithInt: 2] forKey:AVNumberOfChannelsKey];
NSError* error = nil;
NSURL* url = [NSURL URLWithString:filePath];
self.recorder = [[AVAudioRecorder alloc] initWithURL:url settings:recordSetting error:&error];
但似乎我在错误中得到kAudioFormatUnsupportedDataFormatError
,因此无法实例化。
有什么想法吗?
答案 0 :(得分:0)
将格式设置为kAudioFormatMPEG4AAC
解决了这个问题:
[recordSetting setValue:[NSNumber numberWithInt:kAudioFormatMPEG4AAC] forKey:AVFormatIDKey];