Re: SoundPlayer vs PlaySound
- From: "Peter Foot [MVP]" <feedback@xxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 21 Aug 2007 15:53:56 +0100
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?
.
- Prev by Date: Memory problems with Compact Framework
- Next by Date: Re: Memory problems with Compact Framework
- Previous by thread: Memory problems with Compact Framework
- Next by thread: System.IO.IOException using GPS COM port
- Index(es):
Relevant Pages
|