That depends on the device. If your device has a Media Player application capable of playing WAV files I'd do this.
Copy some WAV files with different encoding setting (8/16 bit, mono/stereo, 11.5kHz/22kHz/44.1Khz sampling rate) and see which one plays fine and which don't.
Just use the following code. You will of course have to modify unless you only want to play a notify wav
public void PlayNotify() { try { PlaySound(@"notify.wav", IntPtr.Zero, PlaySoundFlags.SND_FILENAME | PlaySoundFlags.SND_ASYNC); } catch (Exception e) { //Handle exception here } }
public enum PlaySoundFlags : int { SND_SYNC = 0x0000, /* play synchronously (default) */ SND_ASYNC = 0x0001, /* play asynchronously */ SND_NODEFAULT = 0x0002, /* silence (!default) if sound not found */ SND_MEMORY = 0x0004, /* pszSound points to a memory file */ SND_LOOP = 0x0008, /* loop the sound until next and PlaySound */ SND_NOSTOP = 0x0010, /* don't stop any currently playing sound */ SND_NOWAIT = 0x00002000, /* don't wait if the driver is busy */ SND_ALIAS = 0x00010000, /* name is a registry alias */ SND_ALIAS_ID = 0x00110000, /* alias is a predefined ID */ SND_FILENAME = 0x00020000, /* name is file name */ SND_RESOURCE = 0x00040004 /* name is resource name or atom */ }
You’re specifying wrong path to the file (e.g. have drive letter in it or using relative path which is not supported on devices), file does not exist or file is not in the acceptable format. The only acceptable format is uncompressed PCM.
Did you check all these things I've mention in the previous post
You’re specifying wrong path to the file (e.g. have drive letter in it or using relative path which is not supported on devices), file does not exist or file is not in the acceptable format. The only acceptable format is uncompressed PCM.
I've got a simular system in my apps, however it doesn't work if you try to play two sounds at once, (like music and a sound effect), does anyone know if it is even possible to play two or more sounds at once ( knowing that the sound buffer in PDAs may not support it)
It seems like I didn't use the resource as embedded though my reference string to it was using that syntax. However, it still doesn't work.
Build Action: Embedded Resource
The namespace is MyNS, the class is called Sound, and the file mysound.wav. The resource string would then be "MyNS.Sound.mysound.wav" - right That doesn't work....
Neither does it work to use Copy To Output Directory: "Copy Always" and only "mysound.wav"
This is a native function, it can't access managed resources. Either don't use resources (change action type to content so file would be deployed to the device) or load resource data into memory buffer and use different set of flags to play buffer content.
It is possible to play multiple sounds at the same time but you would need to use waveOut* API which are low level and require you to parse WAV file yourself. I believe OpenNetcf.org has a managed wrapper for that. Or you can wrap it up yourself if you have the skills.
I am trying to add Beep to my WinCE 4.2 application. I tried with both "MessageBeep" and "PlaySound" API's using interop. I could get them work on Emulotor but not on actual device. Is there any way to test playing sound file on device Or do I need to configure any perticulars to achieve the same
Sounds with C#.NET CF
Luminita
Hi Pal
That depends on the device. If your device has a Media Player application capable of playing WAV files I'd do this.
Copy some WAV files with different encoding setting (8/16 bit, mono/stereo, 11.5kHz/22kHz/44.1Khz sampling rate) and see which one plays fine and which don't.
Hope this makes sens
Michael
A__alex10
donna123
Just use the following code. You will of course have to modify unless you only want to play a notify wav
public void PlayNotify(){
try
{
PlaySound(@"notify.wav", IntPtr.Zero,
PlaySoundFlags.SND_FILENAME | PlaySoundFlags.SND_ASYNC);
}
catch (Exception e)
{
//Handle exception here
}
} public enum PlaySoundFlags : int
{
SND_SYNC = 0x0000, /* play synchronously (default) */
SND_ASYNC = 0x0001, /* play asynchronously */
SND_NODEFAULT = 0x0002, /* silence (!default) if sound not found */
SND_MEMORY = 0x0004, /* pszSound points to a memory file */
SND_LOOP = 0x0008, /* loop the sound until next and PlaySound */
SND_NOSTOP = 0x0010, /* don't stop any currently playing sound */
SND_NOWAIT = 0x00002000, /* don't wait if the driver is busy */
SND_ALIAS = 0x00010000, /* name is a registry alias */
SND_ALIAS_ID = 0x00110000, /* alias is a predefined ID */
SND_FILENAME = 0x00020000, /* name is file name */
SND_RESOURCE = 0x00040004 /* name is resource name or atom */
}
[
DllImport("coredll")]public static extern bool PlaySound( string szSound, IntPtr hMod, PlaySoundFlags flags );
White Hawk
You’re specifying wrong path to the file (e.g. have drive letter in it or using relative path which is not supported on devices), file does not exist or file is not in the acceptable format. The only acceptable format is uncompressed PCM.
Ravel
Have you tried searching for "Sound" here It returns bunch of usefull results with code samples and references to sound libraries you could use:
http://forums.microsoft.com/MSDN/Search/Search.aspx words=sound&localechoice=9&SiteID=1&searchscope=forumgroupscope&ForumGroupID=11
MarkTsai
But that didn't work either... i.e. to change action type to content
ghe
Did you check all these things I've mention in the previous post
You’re specifying wrong path to the file (e.g. have drive letter in it or using relative path which is not supported on devices), file does not exist or file is not in the acceptable format. The only acceptable format is uncompressed PCM.
LuckyL
_Pero_
Yes, I had try, but the result of search return me evry time a error...
anyway Thanks
Yustme
It seems like I didn't use the resource as embedded though my reference string to it was using that syntax. However, it still doesn't work.
Build Action: Embedded Resource
The namespace is MyNS, the class is called Sound, and the file mysound.wav. The resource string would then be "MyNS.Sound.mysound.wav" - right That doesn't work....
Neither does it work to use Copy To Output Directory: "Copy Always" and only "mysound.wav"
Astennu
This is a native function, it can't access managed resources. Either don't use resources (change action type to content so file would be deployed to the device) or load resource data into memory buffer and use different set of flags to play buffer content.
Giber
Thank you Michael,
It was more of a hardware thing. I got the fix from the manufacturer .
Thanks a lot for the support.
Pal
Dries vh
It is possible to play multiple sounds at the same time but you would need to use waveOut* API which are low level and require you to parse WAV file yourself. I believe OpenNetcf.org has a managed wrapper for that. Or you can wrap it up yourself if you have the skills.
Martin Smyth
Hi Ilya,
I am trying to add Beep to my WinCE 4.2 application. I tried with both "MessageBeep" and "PlaySound" API's using interop. I could get them work on Emulotor but not on actual device. Is there any way to test playing sound file on device Or do I need to configure any perticulars to achieve the same
Thank you.
Pal