iphone sdk: initialization of a AVAudioRecorder returns nil

ぐ巨炮叔叔 提交于 2019-12-12 04:45:02

问题


I want to initialize a AVAudioRecorder with the aac Format. To do so, I use the following code:

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];

why doesn't this work? Id does work, if I change aac into ima4!


回答1:


'aac' is not among the predefined format ids and so it doesnot work. U can have a look at the supported audiotype constants for getting a list of all these. They are availab here

at the Constants secion.



来源:https://stackoverflow.com/questions/2856058/iphone-sdk-initialization-of-a-avaudiorecorder-returns-nil

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!