Re: SoundPlayer vs PlaySound

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi,

I assume you are using .NETCF v3.5 beta as prior versions don't have the System.Media classes. The way this class works is it loads in the file internally and plays from the local cache of data. PlaySound simply plays directly from the given file path (or memory buffer). You can work around this by calling the Load() or LoadAsync() methods elsewhere in your code prior to needing the sound. If the load is already done Play should perform much better. Currently Play is having to first load the file which explains the delay.

Peter

--
Peter Foot
Microsoft Device Application Development MVP
www.peterfoot.net | www.inthehand.com
In The Hand Ltd - .NET Solutions for Mobility

"Kingherc" <Kingherc@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:1F845B3D-0E1D-49B4-8DD9-C718D5EDF80F@xxxxxxxxxxxxxxxx
Hello there,

I am programming a simple game for Windows Mobile, managed code C# with .NET
compact framework. In the game, I want to play some sounds (which I've stored
as sound resources in my project) when some actions occur. I found two ways:
The Media.Soundplayer .NET class and the PlaySound API method. I tried both
ways and there is a problem:

The API call to PlaySound just works fine, doesn't have any glitch.
The SoundPlayer.Play method has a serious glitch. The game stucks for about
a second (or half a second) before the sound begins to play. Is there
something wrong with the SoundPlayer.Play method, or am I doing something
wrong?

.



Relevant Pages

  • Re: Premium Willy Beans
    ... you can play it mostly like a load of Sonic levels, ... most impressive thing about the game is that they've actually managed to ... and a load of well thought-through online features. ...
    (uk.games.video.misc)
  • Re: Printing Problems with Remote Desktop
    ... now you lost me on the plug and play. ... when I get to the office and load the printer information. ... >> for my home computer into the work computer. ...
    (microsoft.public.windowsxp.newusers)
  • Re: Mozaki Blocks Delux
    ... > How do I load and Play this game on a computer that is NOT ... > connected to the internet? ...
    (microsoft.public.games.zone)
  • DOS based program
    ... I have an old game that is DOS based that I used to play on my old Windows 98 ... computer that I can't figure out how to load on my new Windows XP system. ... The game was made way back in 1997. ...
    (microsoft.public.windowsxp.newusers)
  • Re: Company of Heroes questions
    ... Never had this load lag with any other games, ... I click its icon to the time I am able to play. ... I have an old box, Sempron 2600, 1 gig, TI 4200 vid, and the game loads ... may want to try a defrag, or re-install the game into a clean partition ...
    (comp.sys.ibm.pc.games.strategic)