简体   繁体   English

System.Media.SoundPlayer,播放多个声音吗?

[英]System.Media.SoundPlayer, Playing more than 1 sound?

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. 它将播放一个声音,但是使用相同的“ PlaySound”,它将基本上停止最后播放的声音,而只是启动一个新线程播放新声音。 Is there a way to actually stop this and play more than one sound(s)? 有没有一种方法可以真正阻止这种情况并播放多个声音?

Take a look at: 看一眼:

Play multiple sounds using SoundPlayer nc-net 使用SoundPlayer nc-net 播放多种声音

Note the solution with mciSendString at the bottom. 注意底部带有mciSendString的解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM