DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Tue, 21 Aug 2007 03:46:01 -0700,    posted on: microsoft.public.dotnet.framework.compactframework        back       

Thread Index
  1    Kingherc
          2    Peter Foot [MVP]
                 3    Kingherc


SoundPlayer vs PlaySound   
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?
Date:Tue, 21 Aug 2007 03:46:01 -0700   Author:  

Re: SoundPlayer vs PlaySound   
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"  wrote in message 
news:1F845B3D-0E1D-49B4-8DD9-C718D5EDF80F@microsoft.com...

> 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? 
Date:Tue, 21 Aug 2007 15:53:56 +0100   Author:  

Re: SoundPlayer vs PlaySound   
Thanks Peter for your quick response,
& congrats for your MVP

Well, I had tried what you said, in two ways: loading the sound from a file, 
and loading the sound from a MemoryStream. They presented glitches. But in 
the end I found out what the real problem was: Not surprisingly, I was 
running the program always through Visual Studio (which monitors the program 
while debugging and imposes a certain load on it), and that was why the 
SoundPlayer presented glitches. I ran the program by itself and everything 
worked just fine. Thanks for your response.
I should comment that SoundPlayer was a very nice addition in v3.5.

"Peter Foot [MVP]" wrote:


> 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"  wrote in message 
> news:1F845B3D-0E1D-49B4-8DD9-C718D5EDF80F@microsoft.com...
> > 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? 
> 
Date:Tue, 21 Aug 2007 09:22:05 -0700   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us