This project has moved. For the latest updates, please go here.

why the PlaybackStopped event doesn't work?

May 4, 2014 at 7:46 AM
Edited May 4, 2014 at 7:50 AM
I want to get a message when the play is stopped, but the PlaybackStopped event doesn't work.
the code :
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private WaveOut waveOutDevice;
    private WaveStream activeStream;
    private WaveChannel32 inputStream;

    private void Form1_Load(object sender, EventArgs e)
    {
        string path = @"D:\1.mp3";
        waveOutDevice = new WaveOut();
        waveOutDevice.DesiredLatency = 100;
        waveOutDevice.PlaybackStopped += waveOutDevice_PlaybackStopped;
        activeStream = new Mp3FileReader(path);
        inputStream = new WaveChannel32(activeStream);
        waveOutDevice.Init(inputStream);
        waveOutDevice.Play();
    }

    private void waveOutDevice_PlaybackStopped(object sender, StoppedEventArgs e)
    {
        MessageBox.Show("stopped.");
    }
}
when the play is stopped, there is no message box appeared.
anybody know why, thanks.
Coordinator
May 6, 2014 at 8:57 AM
It's because you're playing a never-ending audio stream. Set WaveChannel32.PadWithZeroes to false to fix this.