1.引用System.Media名稱空間下的類SoundPlayer SoundPlayer player = new SoundPlayer(); 2.方法調用Play(); public void Play() { player.SoundLocation = @".\x0pbk-swz4q.w ...
1.引用System.Media名稱空間下的類SoundPlayer
SoundPlayer player = new SoundPlayer();
2.方法調用Play();
public void Play()
{
player.SoundLocation = @".\x0pbk-swz4q.wav";//讀取音頻文件
player.Load();//同步模式
player.Play();
if (MessageBox.Show("播放音樂中,通過旋轉耳機上的旋鈕測試音量,若聲音播放正常則選是,反之否", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
{
DisplaylistboxMSG("Headset測試結果為異常");
}
else
{
DisplaylistboxMSG("Headset測試結果為正常");
}
player.Stop();//停止播放
player.Dispose();
}