I'm trying to code a simple audio playback test game (which will be used in my actual project), and everything works fine, except for the fact that after the audio has finished playing, the game will crash with a 'stopped working' dialog.
Here's the code that's used to load and play the audio. Regardless of whether it's in LoadContent or not, the crash still happens.
List<SoundEffect> soundEffects; FileStream soundStream = new FileStream("test.wav", FileMode.Open); soundEffects.Add(SoundEffect.FromStream(soundStream)); soundStream.Dispose(); SoundEffectInstance soundeffectinstance = soundEffects.CreateInstance(); soundeffectinstance.Volume = 0.35F; soundeffectinstance.Play();
The audio file is a 2 seconds long beep. The game works fine, and the graphics draw fine too. I should also mention that the SoundEffectInstance's State property doesn't seem to work properly as well.
I'm using Visual Studio 2010 with .NET 4.0, and MonoGame framework 22.214.171.1249 (MonoGame.Framework.WindowsDX, from NuGet), because that's the only thing I can use without Visual Studio telling me to upgrade to .NET 4.5.
I am unable to debug, as when I debug, the 'stopped working' dialog appears again (for some reason I cannot debug any projects directly through the Debug option in VS), and the debugger hook gets confused.
Is this an upstream issue, or is there just something wrong with the way I load the audio file? (P.S. I'm not using the Content Pipeline due to the nature of my project)