Hi,
i have just learned how i am able to play a sound in a loop. I used exactly the same method to stop the sound - this works properly in the emulator. If i copy the executable to my device the sound also plays properly, but it dont stops any more 
Here are the sound messages:
The function declaration
|
|
Public Declare Function WCE_PlaySound Lib "CoreDll.dll" Alias "PlaySound" (ByVal szSound As String, ByVal hMod As IntPtr, ByVal flags As Integer) As Integer
Public Declare Function WCE_PlaySoundBytes Lib "CoreDll.dll" Alias "PlaySound" (ByVal szSound() As Byte, ByVal hMod As IntPtr, ByVal flags As Integer) As Integer
|
|
|
The two methods wrapping the function declaraions
|
Sub playSoundFile(ByVal name As String, ByVal PlayLoop As Boolean) Const snd_filename = &H20000 Const snd_loop = &H8
Dim flag As Long
flag = snd_filename If PlayLoop Then flag = flag Or snd_loop WCE_PlaySound(name, IntPtr.Zero, flag)
End Sub
Sub stopPlayingSound() Const SND_ASYNC = &H1 ' play asynchronously Const SND_NODEFAULT = &H2 ' silence (!default) if sound not found Const SND_NOWAIT = &H2000 ' don't wait if the driver is busy Const SND_FILENAME = &H20000 ' name is file name
Dim flag As Long
flag = SND_ASYNC Or SND_NODEFAULT Or SND_NOWAIT Or SND_FILENAME WCE_PlaySound("", IntPtr.Zero, flag) End Sub
|
|
|
And the call of the function wrapper:
|
playSoundFile("\Storage Card\alarm1.wav", True) stopPlayingSound() |
|
|
Stop sound
mandokev
According to documentation, NULL would stop the sound, not an empty string you’re passing:
http://msdn.microsoft.com/library/default.asp url=/library/en-us/wcewave/html/_wcesdk_win32_playsound.asp
Please try this:
WCE_PlaySound(Nothing, IntPtr.Zero, flag)
Saravana