Play function can't release IO handle.

May 5, 2010 at 2:38 AM

I do it in this way:

AudioPlayer player = new AudioPlayer();

player.LoadFile(filename);       
player.StartPosition = PositionToTimeSpan(waveControl1.LeftPosition);
player.EndPosition = PositionToTimeSpan(waveControl1.RightPosition);
player.Play(); 

But after play wave file. It didn't release IO handle, so I can't delete it in other process.

Coordinator
May 5, 2010 at 6:43 AM

do you dispose of your AudioPlayer after playback has finished?

Mark

May 5, 2010 at 6:49 AM

Waveout.disposed can't solve out my problem. I added inStream.close() and it's working.

public class AudioPlayer

{

...

public void Stop()
        {
            waveOut.Stop();
            inStream.Position = 0;
            inStream.Close();
        }

}

Thank mark.