【发布时间】:2012-12-12 15:52:01
【问题描述】:
我正在尝试使用 Microsoft.Xna.Framework 播放 wav 文件,但我无法解决此错误。
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 只能处理 8 位或 16 位、8KHz 至 48KHz、单声道或立体声的 PCM 音频。您的 wav 文件是否兼容 (blogs.msdn.com/b/ashtat/archive/2010/06/03/…)?
-
谢谢,这是完整的堆栈跟踪,因为它是第一次机会异常。我认为问题在于我的 wav 可能不是 PCM。有什么地方可以找到一个示例 PCM 音频文件进行测试?
-
验证了 PCM,还是有问题。
标签: windows-phone-7 xna windows-phone windows-phone-8