Im working on a text game in c#. But i wanted to have multiple sounds at once. So i tried to use SoundPlayer. But whenever i loaded up another sound, it just cut off the other one. If that makes sense. Im new to programming, so please try to explain like im 5!
Asked
Active
Viewed 685 times
0
-
@RyanWilson And how would you make a new soundplayer? I dont get it. – Enrico Diaz Dec 20 '19 at 21:40
-
You can prototype with Beep and see if you can play them together. You can consider extending to others – Clint Dec 20 '19 at 21:50
-
can you add some clear examples of what you tried? – Cornel Raiu Dec 20 '19 at 23:04
2 Answers
0
If you have say 2 different sounds that you want to play together.
Below example is for Console.Beep, which can be extended to other sounds
You can replace Console.Beep() with other sounds that you want to play
using System.Threading;
using System.Threading.Tasks;
Add above 2 to your Namespace
//First sound you want to play
var first = await Task.Run(() => Console.Beep());
//Optional Delay
await Task.Delay(500); //Does not halt the current thread
//Second sound you want to play
var second = await Task.Run(() => Console.Beep(500,1000));

Clint
- 6,011
- 1
- 21
- 28
-
sorry, i know i have to sound like a complete idiot here but i honestly dont know. Why am i getting an error for the whole thing? – Enrico Diaz Dec 20 '19 at 21:57
-
sure. uhh it says "cannot assign void to an implicitly-typed variable" – Enrico Diaz Dec 20 '19 at 22:02
-
-
0
I had been struggling with the same issue.....
The short answer is you can't. The system will only permit one channel to the sound interface within any given process. As such, when you start a new sound, the previous one terminates.

Ninad Kulkarni
- 11
- 2