Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Simultaneous Sounds

328 views
Skip to first unread message

rlr...@newsgroups.nospam

unread,
Apr 26, 2007, 5:59:58 PM4/26/07
to
I'm using the .Net 2.0 SoundPlayer class for the sound effects in my app.  But it doesn't seem to allow simultaneous sounds...  I'm even executing the instantiation and play on a separate thread.  But sound two never gets played.  Anyone have much experience with this?
 
Thanks.
 
J

Walter Wang [MSFT]

unread,
Apr 26, 2007, 9:14:15 PM4/26/07
to
Hi,

The .NET 2.0 SoundPlayer class internally uses winmm API PlaySound
(http://msdn2.microsoft.com/en-us/library/ms712879.aspx) to play the wave
file and this API cannot play multiple wave files simultaneously in a
process.

To workaround this, you will either use DirectX or use Windows Media Player
to play the wave files:

1) Reference c:\windows\system32\wmp.dll
2) Use following code:

WMPLib.WindowsMediaPlayer wp = new WMPLib.WindowsMediaPlayer();
wp.URL = @"c:\1.wav";

WMPLib.WindowsMediaPlayer wp2 = new WMPLib.WindowsMediaPlayer();
wp2.URL = @"c:\2.wav";

This will play the two wave files simultaneously.

Here's some tutorials on using Managed DirectX to play sound:

#Managed DirectX Tutorial Part 2 - Samus Running - The Code Project -
Multimedia
http://www.codeproject.com/cs/media/mdxtutorial2.asp

#DirectX:DirectSound:Tutorials:VBNET:DX9:Playing Sounds - GPWiki
http://gpwiki.org/index.php/VBNET:DirectSound

Hope this helps.

Sincerely,
Walter Wang (waw...@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

rlr...@newsgroups.nospam

unread,
Apr 27, 2007, 1:49:20 PM4/27/07
to
Great info. Thanks.


"Walter Wang [MSFT]" <waw...@online.microsoft.com> wrote in message
news:QObRslGi...@TK2MSFTNGHUB02.phx.gbl...

0 new messages