我想问一下如何将哇音保存到变量中。在程序中,我有 3 个按钮,单击时我想播放不同的声音。现在我得到了它
`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);
}
谢谢