当我尝试设置音频配置编写器输入时,我收到错误:
-[__NSCFNumber length]: unrecognized selector sent to instance 0xbcdab0
我的代码:
NSObject[] values = new NSObject[]
{
NSNumber.FromFloat(44100.0f),
NSNumber.FromInt32((int)MonoTouch.AudioToolbox.AudioFormatType.MPEG4AAC),
NSNumber.FromInt32(2),
NSNumber.FromInt32((int)AVAudioQuality.Medium)
};
//Set up the NSObject Array of keys that will be combined with the values to make the NSDictionary
NSObject[] keys = new NSObject[]
{
AVAudioSettings.AVSampleRateKey,
AVAudioSettings.AVFormatIDKey,
AVAudioSettings.AVNumberOfChannelsKey,
AVAudioSettings.AVChannelLayoutKey
};
//Set Settings with the Values and Keys to create the NSDictionary
NSDictionary audiosettings = NSDictionary.FromObjectsAndKeys (values, keys);
writeraudioInput = new AVAssetWriterInput (AVMediaType.Audio, audiosettings);
答案 0 :(得分:1)
好像您正在设置AVChannelLayoutKey
的关键字,并且值为AVAudioQuality
的类型。它们彼此没有对应关系。 AVChannelLayoutKey
的值应该包含AudioChannelLayout的结构。
评论最后一个键和最后一个值。或者填写并传递AudioChannelLayout
结构。
答案 1 :(得分:0)
您正在使用松散类型的基于NSDictionary的API。
如果您使用带有AudioSettings参数的其他构造函数,以后可以避免这些错误,这可以方便地为您提供智能感知。