我只想顯示audioOutput_PlaybackStopped中的messagebox。任何人都可以幫忙?我用Naudio。playbackstopped not raised -Naudio
這裏是我的代碼:
public void playRecordedUser()
{
pcm = new WaveChannel32(new WaveFileReader(@"D:\2.wav"));
//.PadWithZeroes = false;
reductionStream = new BlockAlignReductionStream(pcm);
waveOutDevice = new DirectSoundOut();
waveOutDevice.PlaybackStopped += new EventHandler<StoppedEventArgs>(audioOutput_PlaybackStopped);
waveOutDevice.Init(reductionStream);
waveOutDevice.Play();
// pcm.Close();
// waveOutDevice.Dispose();
}
void audioOutput_PlaybackStopped(object sender, StoppedEventArgs e)
{
MessageBox.Show("hey");
waveOutDevice.Stop();
reductionStream.Close();
waveOutDevice.Dispose();
waveOutDevice = null;
pcm.Close();
}
這比你需要的要複雜得多。只需使用AudioFileReader。根本不要使用BlockAlignReductionStream。 –
如何使用?對不起,我只是使用NAudio的新功能。感謝您的回答:) – user3098141
我的問題是我不能再次用我的代碼記錄。它說@「D:\ 2.wav」正在被另一個進程使用。我只是想停止任何過程,所以我試圖使用播放停止。但仍然不會工作。 – user3098141