我正在尝试像这样实例化一个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,因此无法实例化。
有什么想法吗?
发布于 2018-02-28 00:19:36
将格式设置为kAudioFormatMPEG4AAC解决了这个问题:
[recordSetting setValue:[NSNumber numberWithInt:kAudioFormatMPEG4AAC] forKey:AVFormatIDKey];
https://stackoverflow.com/questions/49011703
复制相似问题