我一直试图让两个声音同时播放(一个是循环播放,一个是从按键开始),但是一个声音将取消另一个声音,当我再次尝试播放时我会收到错误(ThreadStateException未处理)
关于堆栈溢出有一个类似的问题,但没有一个真正有效的答案
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();
}
有人可以帮助我了解正在发生的事情并提供可能的解决方案吗?