I'm trying to figure out why NAudio is raising the following exception:
System.ArgumentOutOfRangeException was unhandled
Message: An unhandled exception of type 'System.ArgumentOutOfRangeException'
occurred in NAudio.Vorbis.dll
Additional information: Specified argument out of range.
What I'm trying to do is creating a sort of fire and forget class for playing audios, here's the class:
public class FFSoundPlayer
{
private readonly WaveOutEvent outputDevice;
private WaveMixerStream32 mixer;
private System.IO.Stream silenceStream;
private FFSoundPlayer()
{
outputDevice = new WaveOutEvent();
mixer = new WaveMixerStream32();
System.Reflection.Assembly a = System.Reflection.Assembly.GetExecutingAssembly();
silenceStream = a.GetManifestResourceStream("ProperPath.silence.ogg");
VorbisWaveReader wv = new VorbisWaveReader(silenceStream);
LoopWaveStream silence = new LoopWaveStream(wv);
mixer.AddInputStream(silence);
mixer.AutoStop = false;
outputDevice.Init(mixer);
outputDevice.Play();
}
public static FFSoundPlayer Instance = new FFSoundPlayer();
public void AddWave(WaveStream wave)
{
mixer.AddInputStream(wave);
}
}
LoopWaveStream is just a WaveStream that reset the position when it reaches the end of the stream.
After I send a few files to thru the AddWave method I get the exception from NAudio. Any ideas? Am I doing it the proper way?
Thanks