0
我想問如何將聲音保存到變量中。在節目中,我有3個按鈕,點擊時我想播放不同的聲音。現在我知道了這樣的將.waw聲音保存到變量中
`SoundPlayer playDeath = new SoundPlayer(Properties.Resources.death);
playDeath.Play();`
我試圖保存音頻到變量並播放,但沒有奏效。
SoundPlayer player = new SoundPlayer();
Bitmap sound;
sound = Properties.Resources.death;
player.Play(sound);
有沒有什麼辦法通過點擊按鈕來保存變量的聲音。例如
SoundPlayer player = new SoundPlayer();
private void button1_Click(object sender, EventArgs e)
{
sound = Properties.Resources.death;
player.Play(sound);
}
private void button2_Click(object sender, EventArgs e)
{
sound = Properties.Resources.levelUp;
player.Play(sound);
}
感謝