简体   繁体   English

C#WinForms如何同时播放2种声音

[英]C# WinForms how to play 2 sounds in the same time

I am using the command: SoundPlayer cave = new SoundPlayer(WindowsFormsApplication5.Properties.Resources.Cave_Music; to play a melody in the background, however if I want to add let's say a Beep in the same time with the melody, the melody stops. I couldn't find any answers on older questions of the same time, so how do I play 2 sounds in the same time? Prefferably booth of them from a Resorce. 我正在使用以下命令: SoundPlayer cave = new SoundPlayer(WindowsFormsApplication5.Properties.Resources.Cave_Music;在后台播放旋律,但是,如果我想添加一个Beep与旋律同时播放,则旋律会停止。我找不到同时回答较旧问题的任何答案,那么我该如何同时播放2种声音呢?

Thanks alot ! 非常感谢 !

I highly recommend to use DirectSound or similar API for such purposes. 为此,我强烈建议使用DirectSound或类似的API。

Also, you can implement this using System.Windows.Media.MediaPlayer class. 另外,您可以使用System.Windows.Media.MediaPlayer类实现此功能。

The multi-threaded example is here . 多线程示例在此处

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

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