NAudio: How can I get an event that tells me that the MP3 file reached the end?

Posted by Rookian on Stack Overflow See other posts from Stack Overflow or by Rookian
Published on 2010-04-03T13:02:26Z Indexed on 2010/04/03 13:13 UTC
Read the original article Hit count: 357

Filed under:
|
|

I tried to use this:

private void CreateDevice()
{
    _playbackDevice = new WaveOut();
    _playbackDevice.PlaybackStopped += PlaybackDevicePlaybackStopped;
}

void PlaybackDevicePlaybackStopped(object sender, EventArgs e)
{
    if (OnPlaybackStopped != null)
    {
        OnPlaybackStopped(this, e);
    }
}

But it never invoked.

Then I tried to use the PlaybackState by polling the property with a timer:

public PlaybackState PlaybackState
{
    get
    {
        if (_playbackDevice == null)
            return default(PlaybackState);

        return _playbackDevice.PlaybackState;
    }
}

But when the song ends it does not change to "stopped". But when I call Stopped it changes correctly.

Can someone help me?

© Stack Overflow or respective owner

Related posts about naudio

Related posts about mp3