0

当我尝试播放声音文件“Windows Critical Stop.wav”时,出现以下异常:exec {"Sound API only supports playing PCM wave files."} System.Exception {System.InvalidOperationException}

我了解 PCM 是什么,我只是不知道如何:1)播放声音文件,2)先验地确定它不是 PCM 并且不会播放,并阻止选择文件。

这是我正在使用的代码:

SoundPlayer player = new SoundPlayer();
player.SoundLocation = FileNameTextBox.Text;

try
{
    player.Play();
}
catch (Exception exec)
{
    MessageBox.Show("Sound could not be played: " + exec.ToString());
}
4

2 回答 2

2

Wave 文件的编码方式可能不同(即使使用 GSM 编解码器),因此只需检查使用什么编解码器来跳过特定的编解码器。只需检查 AudioFormat 位。

https://ccrma.stanford.edu/courses/422/projects/WaveFormat/

于 2009-12-27T22:01:16.157 回答
-1

您必须使用此播放器,您拥有的代码是系统损坏程序 Microsoft 管理员,

于 2010-01-25T21:49:38.947 回答