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

Null error on Stop()

Aug 1, 2015 at 5:39 PM
Hi.

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.Init(audioCorte);
        waveOut.Play();
        waveOut.PlaybackStopped += OnPlaybackStopped;



    }

    private void OnPlaybackStopped(object sender, EventArgs e)
    {
        waveOut.Dispose();

    }

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

            waveOut.Stop();

        }

    }

}
What i'm missing there? I just want to play/stop a file...
Coordinator
Aug 4, 2015 at 1: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 8:09 PM
Hi!.

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