2013-05-07 62 views
1

當我嘗試設置音頻配置作家輸入我得到一個錯誤:MonoTouch的 - 錯誤設置AVAssetWriterInput - 無法識別的選擇發送到實例

-[__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); 

回答

1

似乎你正在設置密鑰AVChannelLayoutKey和價值類型AVAudioQuality。他們不相互對應。 AVChannelLayoutKey的值應該包含AudioChannelLayout的結構。

註釋最後一個鍵和最後一個值。或者填寫並傳遞AudioChannelLayout結構。

+0

非常好,謝謝。 – Fabio 2013-05-07 13:19:59

0

您正在使用鬆散類型的基於NSDictionary的API。

如果您使用帶有AudioSettings參數的其他構造函數,它可以方便地爲您提供intellisense,您可以避免將來出現這些錯誤。

+0

我試過了,但沒有找到任何例子。你知道嗎? – Fabio 2013-05-09 18:01:46

相關問題