I know how to play an audio file using the SoundPlayer class, but I have only been able to play one sound at a time. If I am playing a sound, and I try to play another sound, it stops the first one to play the second one. And that is with two separately declared SoundPlayer objects. So, is there some way to play two sounds simultaneously I want to be able to play background music and sound effects at the same time.

Playing sounds simultaneously
robhare
ah ok I see!
I don't think you can do this using the SoundPlayer classes (do not quote me) but perhaps using Managed DirectX. (SDK)
There also includes various samples and documentation of course on how to use the Managed DirectX classes etc...
http://msdn.microsoft.com/directx/sdk/
More specifically in there, take a look at the AudioVideoPlayerback namespaces
infact I just did to confirm. Once installed, add a reference to Microsoft.DirectX.AudioVideoPlayback then import the namespace (using Microsoft.DirectX.AudioVideoPlayback) then....
Audio theFirstFile = new Audio("fileName1.mp3");
Audio theSecondFile = new Audio("fileName2.mp3");
theFirstFile.Play();
theSecondFile.Play();
and both of the files will play at the same time without your application or rather the main thread (UI) from hanging. Does this help
GraemeH
WizMan
PublicError
how are you playing the file
you can play the sound in Async mode meaning it will carry on the executing of your program whilst doing its play sound in the background....by default it will not do this but wait until the sound has finished playing, then carry on. To do this:
System.Media.SoundPlayer thePlayer1 = new System.Media.SoundPlayer("FileName.wav");
thePlayer1.Play();
System.Media.SoundPlayer thePlayer2 = new System.Media.SoundPlayer("FileName2.wav");
thePlayer2.Play();
You also have an option of playing the sound in a loop if you like
thePlayer.PlayLooping();
and of course stop playing by calling the Stop method:
thePlayer.Stop();
does this help/give you some pointers