I am currently working on my own implementation of the waveout api because i want to understand how naudio works and so on... :)
So I've reached a point now where everything with waveout works really fine. But I have a little problem that I can't fix. So I had a look on the naudio source. The source naudio is very different (may a bit better) but there is also the same problem. So
I've written a little example where the bug occours.
The Problem ist you can't dispose and create a new WaveOut device in a small time.
Try out this code:
WaveOut waveOut; private void button1_Click(object sender, EventArgs e) { OpenFileDialog ofn = new OpenFileDialog(); ofn.ShowDialog(); if (waveOut != null) { waveOut.Stop(); waveOut.Dispose(); } waveOut = new WaveOut(this.Handle); Mp3FileReader reader = new Mp3FileReader(ofn.FileName); waveOut.Init(reader); waveOut.Play(); }
If you try out this code you will get a object is null exception. I fixed that but after that there will be other problems like you are opening a new waveout while closing the old one...
So is there a way to fix that problem. I had a look on that for now more than 2 hours but I found no solution.
btw. it is very very interesting what is behind this greate libary.^^