I've been trying to have two sounds playing at the same time (one which is looping and one that starts on keypress) but one sound will cancel the other out and when I try to play them again I get errors (ThreadStateException was unhandled)
There was a similar question asked on stack overflow but there wasn't a really a valid answer
public partial class Form1 : Form
{
Thread BackgroundSoundThread = new Thread(BST);
Thread LaserSoundThread = new Thread(LST);
}
static void BST()
{
System.Media.SoundPlayer sPlayer = new System.Media.SoundPlayer();
sPlayer.SoundLocation = "Game Ambient Forest loop.wav";
sPlayer.PlayLooping();
}
static void LST()
{
System.Media.SoundPlayer LaserSound = new System.Media.SoundPlayer();
LaserSound.SoundLocation = "Single Laser.wav";
LaserSound.Play();
}
private void Form1_Load(object sender, EventArgs e)
{
BackgroundSoundThread.Start();
}
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
LaserSoundThread.Start();
}
Can someone help me understand what's going on and offer a possible solution?