N
N
noytmant2020-10-10 17:48:04
C++ / C#
noytmant, 2020-10-10 17:48:04

C# SoundPlayer streams?

In general, at the start of the form, I play music. But there is also a sound on the buttons, when I press them, the background music is interrupted. How to make it so that when you press a button there is a sound, but the background music does not stop

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Pavlov, 2020-10-10
@Stalker31

Create a stream when you click on the button and start the sound in it, then end the stream.

N
noytmant, 2020-10-10
@noytmant

In general, I found a solution.
In order for you to play background music, and the buttons were also used with sound without interrupting the background music. I advise you to use WMPLib for background music, which you can connect through NuGet package management.
Next, write the following code:

public WMPLib.WindowsMediaPlayer WMP = new WMPLib.WindowsMediaPlayer();

Well, in fact, when loading the form, already register the following code:
WMP.URL = "Путь до .mp3 файла";
WMP.controls.play();

That's all, these are two different libraries that will not interfere with each other, SoundPlayer for buttons, WMP for background music, you can do it all in streams, as they said above, but I'm slow-witted xD

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question