Is there a way to play two sounds at the same time?
I know that SoundPlayer
isn't able to do this.
I can't use SoundEffect
as I believe it's only part of XNA.
The two required sounds will be called at unknown and random times. The sound needs to be be controlled after it is played. i.e., the sound must be able to be stopped before it has finished playing.
check
PlaySound
method here http://msdn.microsoft.com/en-us/library/aa909766.aspx, and its flagSND_ASYNC
.From http://alvas.net/alvas.audio,samples.aspx#sample7 and http://alvas.net/alvas.audio,samples.aspx#sample6
or mix audio data before playing How to mix to mix two audio file..
Reference
PresentationCore
andWindowsBase
and try this...EDIT I received a downvote probably because at first glance this looks like it will play the second sound after the first is finished. It doesn't, they are played by windows asynchronously. The sleep is there so if you test this code verbatim you can hear the sounds play together, it wouldn't be noticeable without the delay since they are the same sound.
This code demonstrates the two sounds playing on separate threads on top of each other, which is sort of pointless since the playback doesn't block anyway
http://msdn.microsoft.com/en-us/library/system.windows.media.mediaplayer.stop.aspx The class also has the control you need to stop playback
Solution : Hi, I was developing a WP8 App and i needed multiple sounds to play simultaneously, the solutions mentioned above didnt work for me, So i used the XNA framwork. here is the link
http://msdn.microsoft.com/en-us/library/ff842408.aspx
and then play ur sound files like this...
For looping...
Note: the files must be in ".wav" (PCM, 8 or 16-bit, 8KHz to 48KHz, mono or stereo) format
The "MediaPlayer" object will not let you play two sounds at once, even if you create two instances. You will need to bring in the native windows API "mciSendString".