SoundPlayer 和 Windows 7 wav 文件
当我尝试播放声音文件“Windows Critical Stop.wav”时,出现以下异常: exec {“Sound API 仅支持播放 PCM 波形文件。”} 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());
}
When I try to play the sound file "Windows Critical Stop.wav" I get the following exception: exec {"Sound API only supports playing PCM wave files."} System.Exception {System.InvalidOperationException}
I understand what PCM is, I just do not know how to either: 1) play the sound file, 2) determine a priori that it is not PCM and will not play, and block the file from being chosen.
Here is the code I am using:
SoundPlayer player = new SoundPlayer();
player.SoundLocation = FileNameTextBox.Text;
try
{
player.Play();
}
catch (Exception exec)
{
MessageBox.Show("Sound could not be played: " + exec.ToString());
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Wave 文件可以采用不同的编码方式(即使使用 GSM 编解码器),因此只需检查使用哪种编解码器即可跳过特定编解码器。只需检查音频格式位即可。
https://ccrma.stanford.edu/courses/422/projects/WaveFormat/< /a>
Wave files can be encoded differently (even with the GSM codec), so just examine what codec is used to skip a particular one. Just check the AudioFormat bits.
https://ccrma.stanford.edu/courses/422/projects/WaveFormat/
你必须使用这个播放器,你拥有的代码是系统破坏者
微软管理员,
You have to use this player the code you have is a system damager
Microsoft admin,