I'm trying to instantiate an AVAudioRecorder like this:
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];
But it seems I'm getting a kAudioFormatUnsupportedDataFormatError
in the error and therefore fail to instantiate.
Any idea?
Setting the format to kAudioFormatMPEG4AAC
solved this issue:
[recordSetting setValue:[NSNumber numberWithInt:kAudioFormatMPEG4AAC] forKey:AVFormatIDKey];