Reputation: 183
I'm trying to write a simple console application that plays a MP3 file using CSCore library. In the documentation it says that the Playback state will automatically change to Stopped once the file is finished playing which seems to be the outcome after a Stop() method is automatically called by CSCore at the end of the file stream. The Stop() method calls StopNative() where the exception arises.
Below is the code I've written:
static MMDevice mmdev = MMDeviceEnumerator.DefaultAudioEndpoint(DataFlow.Render, Role.Multimedia);
static AudioSessionManager AuSem;
static AudioSessionEnumerator AuSeEn;
static CSCore.SoundOut.ISoundOut soundout;
static void Main(string[] args)
{
string file = Directory.GetCurrentDirectory() + "\\bruh.mp3";
soundout = new CSCore.SoundOut.DirectSoundOut();
AuSem = AudioSessionManager2.FromMMDevice(mmdev);
AuSeEn = AuSem.QueryInterface<AudioSessionManager2>().GetSessionEnumerator();
IWaveSource AudioSource = CSCore.Codecs.CodecFactory.Instance.GetCodec(file);
soundout.Initialize(AudioSource);
soundout.Play();
}
The Exception that arise after playing is finished is:
The Exception point during debugging is:
I've noticed that the StopNative() is called 2 times successfully before the exception rises. Here I want to admit that I'm totally a newbie in pointers and do not understand what exactly is written in StopNative().
I also like to mention that I've already tried contacted CSCore owner regarding the same problem and he gave me a link to his article which is beyond my understanding.
Any help will be appreciated.
Thank you.
Upvotes: 0
Views: 57