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

How can i play sound twice?

Sep 24, 2012 at 11:55 AM
Edited Sep 24, 2012 at 12:12 PM

I try to play sound twice by this code, but it isn't work. Why? I am using 1.5.9.0

private void Start1()
        {
            waveOutDevice = new WaveOut();
            mainOutputStream = CreateInputStream("0609.mp3");
            waveOutDevice.Init(mainOutputStream);
            waveOutDevice.Play();
        }

        private WaveStream CreateInputStream(string fileName)
        {
            WaveChannel32 inputStream;
            if(fileName.EndsWith(".mp3")) {
                WaveStream mp3Reader = new Mp3FileReader(fileName);
                inputStream = new WaveChannel32(mp3Reader);
            }
            else {
                throw new InvalidOperationException("Unsupported extension");
            }
            volumeStream = inputStream;
            return volumeStream;
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            waveOutDevice.Stop();
            waveOutDevice.Play();
        }
Error text 

Buffers already queued on play

Sep 25, 2012 at 7:20 AM

See my answer on StackOverflow