As much as I tried I could not play both audios at the same time with the Class SoundPlayer
I think it seems to use the same instance to play the audio thing that when you do play()
it replaces the audio that is already being played (this it is a supposition to not find documentation of the flow that follows). Therefore, I recommend that you use the class MediaPlayer
. Then I'll explain how to use it.
Add references to be used
To use this class you must add two references to your project which are PresentationCore
and WindowsBase
, these references are found in the Assemblies.
Code
Already having the references you only add the using System.Windows.Media;
so you can use the class. As a special data you will not need to execute a Thread
to reproduce the sounds one over another but by initializing the object you will be able to reproduce it simultaneously.
SOen Source: Play two sounds simultaneusly
using System.Windows.Media;
private void button1_Click(object sender, EventArgs e)
{
MediaPlayer d = new MediaPlayer();
d.Open(new System.Uri(@"archivo2.wav"));
d.Play();
}
private void Form1_Load(object sender, EventArgs e)
{
MediaPlayer c = new MediaPlayer();
c.Open(new System.Uri(@"archivo1.wav"));
c.Play();
}