C# 用 DirectX Sound 播放音乐文章时的异常

来源:互联网 发布:gta5漂移数据mod 编辑:程序博客网 时间:2024/06/05 16:08



Value does not fall within the expected range.

C#播放音乐创建 SecondaryBuffer 辅助的 buffer 时出现了异常,开始不清楚什么原因,后来才发现,应该是语音文件的格式不对,这种方式只能播放 Wav 文件格式(PCM格式),所以随便选一个语音文件应该是不行的,如果没有现成的语音文件,可以考虑用 windows 的 录音机来录一个。

 
 

 

异常  
System.ArgumentException: Value does not fall within the expected range.
   at Microsoft.DirectX.DirectSound.Buffer.CreateBufferFromFile(String fileName, BufferDescription desc, Device parent)
  
   at Microsoft.DirectX.DirectSound.SecondaryBuffer..ctor(String fileName, Device parent)