System.Media.SoundPlayer,播放超过 1 个声音?
有没有办法在背景音乐响起时播放多种声音?
我的方式是:
public static void PlaySound(string filename)
{
SoundPlayer player = new SoundPlayer();
player.SoundLocation = filename;
player.Play();
}
它将播放一个声音,但使用相同的“PlaySound”,它基本上会停止播放的最后一个声音,并启动一个新线程播放新声音。有没有办法真正阻止这种情况并播放多个声音?
Is there a way to play more than one sound while let's say the background music is going?
The way I have it is:
public static void PlaySound(string filename)
{
SoundPlayer player = new SoundPlayer();
player.SoundLocation = filename;
player.Play();
}
Which will play one sound, but using the same "PlaySound" it will basically stop the last sound played and just start a new thread playing the new sound. Is there a way to actually stop this and play more than one sound(s)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看一下:
使用 SoundPlayer 播放多种声音
nc-net
请注意底部带有 mciSendString 的解决方案。
Take a look at:
Play multiple sounds using SoundPlayer
n-c-net
Note the solution with mciSendString at the bottom.