簡體   English   中英

SoundPlayer和Windows 7 WAV文件

[英]SoundPlayer and Windows 7 wav file

當我嘗試播放聲音文件“ 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());
}

Wave文件的編碼方式可能不同(即使使用GSM編解碼器也是如此),因此只需檢查使用哪種編解碼器跳過特定編解碼器即可。 只需檢查AudioFormat位。

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

您必須使用此播放器,而您擁有的代碼是系統破壞者Microsoft管理員,

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM