我試圖播放使用Microsoft.Xna.Framework的wav文件,但我無法解決此錯誤。在Microsoft.Xna.Framework.ni.dll中發生類型'System.ArgumentException'的異常
A first chance exception of type 'System.ArgumentException' occurred in Microsoft.Xna.Framework.ni.dll
An exception of type 'System.ArgumentException' occurred in Microsoft.Xna.Framework.ni.dll but was not handled in user code
下面是我的代碼:(上線發生的錯誤:TitleContainer.OpenStream(dingSoundFile)
)
SoundEffectInstance seiCircus;
string dingSoundFile = "/Html/sounds/tap.wav";
using (var stream = TitleContainer.OpenStream(dingSoundFile))
{
var effect = SoundEffect.FromStream(stream);
//create the instance
seiCircus = effect.CreateInstance();
FrameworkDispatcher.Update();
//play sound via the instance
seiCircus.Play();
}
哪條線拋出該異常?是否有內部異常?請發佈完整的堆棧跟蹤。聲音文件是否正確加載?請注意,SoundEffect只能處理PCM音頻8或16位,8KHz至48KHz,單聲道或立體聲。您的wav文件是否兼容(http://blogs.msdn.com/b/ashtat/archive/2010/06/03/soundeffect-creation-in-xna-game-studio-4.aspx)? – Ani
謝謝,這是完整的堆棧跟蹤,因爲它的第一次機會例外。我認爲問題是我的wav可能不是PCM。有什麼地方可以找到一個PCM音頻文件來測試嗎? – joe
XNA示例(http://xbox.create.msdn.com/en-US/education/tutorial/2dgame/getting_started)? – Ani