当我尝试播放声音文件“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());
}