我有频繁播放相同声音的问题。如果我经常点击按钮,我会收到错误“已经分配waveoutOpen调用”。如何清洁waveOut?怎么样?这是我的代码:
public WaveFileReader reader1;
它的按钮:
if (radioButton1.Checked == true)
{
reader2 = new WaveFileReader(Application.StartupPath + "\\Dzwieki\\Piano\\D piano.wav");
}
else if (radioButton2.Checked == true)
{
reader2 = new WaveFileReader(Application.StartupPath + "\\Dzwieki\\Organ\\D organ.wav");
}
z2 = new NAudio.Wave.WaveOut();
z2.Init(reader2);
z2.Play();