【问题标题】:iphone sdk: initialization of a AVAudioRecorder returns niliphone sdk: AVAudioRecorder 的初始化返回 nil
【发布时间】:2010-05-18 09:41:52
【问题描述】:

我想用 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,ID 确实有效!

【问题讨论】:

    标签: iphone avaudiorecorder


    【解决方案1】:

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

    在常量部分。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-14
      • 1970-01-01
      相关资源
      最近更新 更多