This project has moved and is read-only. For the latest updates, please go here.

Null error on Stop()

Aug 1, 2015 at 6:39 PM

I'm trying to just play a file (for learning purposes) but the Stop() command sometimes throws a null error, while sometimes do nothing.

This is a very, very simple class:
class audioEngine

    private DirectSoundOut waveOut;
    private AudioFileReader audioCorte;

    public void cortePlay(string corte)

        waveOut = new DirectSoundOut();
        var audioCorte = new AudioFileReader(corte);
        waveOut.PlaybackStopped += OnPlaybackStopped;


    private void OnPlaybackStopped(object sender, EventArgs e)


    public void estadoPlayer()
        if (waveOut != null
                && waveOut.PlaybackState != PlaybackState.Stopped)




What i'm missing there? I just want to play/stop a file...
Aug 4, 2015 at 2:31 PM
are you calling Stop after disposing WaveOut?
Marked as answer by knob2001 on 8/4/2015 at 1:08 PM
Aug 4, 2015 at 9:09 PM

Probably that was the case... i figured out some hours later, sorry.