iphone sdk:AVAudioRecorder的初始化返回nil

时间:2010-05-18 09:41:53

标签: iphone avaudiorecorder

我想用aac格式初始化AVAudioRecorder。为此,我使用以下代码:

soundFilePath = [soundFilePath stringByAppendingPathExtension:@"aac"];NSURL *url = 
[NSURL fileURLWithPath:soundFilePath isDirectory:FALSE];

NSMutableDictionary *recordSetting = [[NSMutableDictionary alloc] init];
[recordSetting setValue:[NSNumber numberWithInt: 'aac '] forKey:AVFormatIDKey];                                     
[recordSetting setValue:[NSNumber numberWithInt:AVAudioQualityMin] forKey:AVEncoderAudioQualityKey];                //Encoder Settings 
[recordSetting setValue:[NSNumber numberWithInt:AVAudioQualityMin] forKey:AVSampleRateConverterAudioQualityKey];    //Sample Rate Conversion Settings

_recorder = [[AVAudioRecorder alloc] initWithURL:url settings:recordSetting error:nil];

为什么这不起作用?如果我将aac改为ima4,我的确有效!

1 个答案:

答案 0 :(得分:0)

'aac'不属于预定义的格式ID,因此不起作用。 您可以查看支持的音频类型常量,以获取所有这些常量列表。它们可用here

在Constants secion。