Home > Archive > Smartphone Developer Forum > February 2005 > MissingMethodException error when playing WAV from embedded resour
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
MissingMethodException error when playing WAV from embedded resour
|
|
| sagewithin 2005-02-15, 9:04 pm |
| Hi everyone:
I'm trying to play a WAV file that is an embedded resource, but I am getting
a MissingMethodException. The code is below. Can anyone help me figure out
why? This is a smartphone 2003 app being built with VB.NET. Thanks in
advance!
Public Class SoundRes
'API call for playing sounds in memory
Private Declare Function PlaySound Lib "winmm.dll" (ByVal data() As Byte, _
ByVal hMod As IntPtr, ByVal hwFlags As Integer) As Integer
Private Const SND_ASYNC As Integer = &H1 'Play asynchronously
Private Const SND_MEMORY As Integer = &H4 'Play wav in memory
Private Const SND_NODEFAULT As Integer = &H2 'Play wav in memory
Shared Sub New()
Dim WavStrm As IO.Stream = _
Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("FriendorLover.HIT.WAV")
ReDim ClickSound(CType(WavStrm.Length, Integer))
WavStrm.Read(ClickSound, 0, Int(CType(WavStrm.Length, Integer)))
End Sub
'Play embedded .wav resource
Public Sub PlayWav(ByVal WavResource As Byte())
PlaySound(WavResource, IntPtr.Zero, SND_ASYNC Or SND_MEMORY Or SND_NODEFAULT)
End Sub
End Class
Then to play the sound:
Dim mysound As New SoundRes
mysound.PlayWav(ClickSound)
| |
| Peter Foot [MVP] 2005-02-15, 9:04 pm |
| On WindowsCE the Playsound method is in the coredll.dll library - you need
to alter your P/Invoke declaration.
Peter
--
Peter Foot
Windows Embedded MVP
www.inthehand.com | www.opennetcf.org
"sagewithin" <sagewithin@discussions.microsoft.com> wrote in message
news:15B75043-4C5C-416F-B42B-7B80E5BE5CEE@microsoft.com...
> Hi everyone:
> I'm trying to play a WAV file that is an embedded resource, but I am
> getting
> a MissingMethodException. The code is below. Can anyone help me figure out
> why? This is a smartphone 2003 app being built with VB.NET. Thanks in
> advance!
>
> Public Class SoundRes
>
> 'API call for playing sounds in memory
> Private Declare Function PlaySound Lib "winmm.dll" (ByVal data() As Byte,
> _
> ByVal hMod As IntPtr, ByVal hwFlags As Integer) As Integer
> Private Const SND_ASYNC As Integer = &H1 'Play asynchronously
> Private Const SND_MEMORY As Integer = &H4 'Play wav in memory
> Private Const SND_NODEFAULT As Integer = &H2 'Play wav in memory
>
> Shared Sub New()
> Dim WavStrm As IO.Stream = _
> Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("FriendorLover.HIT.WAV")
> ReDim ClickSound(CType(WavStrm.Length, Integer))
> WavStrm.Read(ClickSound, 0, Int(CType(WavStrm.Length, Integer)))
> End Sub
>
> 'Play embedded .wav resource
> Public Sub PlayWav(ByVal WavResource As Byte())
> PlaySound(WavResource, IntPtr.Zero, SND_ASYNC Or SND_MEMORY Or
> SND_NODEFAULT)
> End Sub
> End Class
>
> Then to play the sound:
> Dim mysound As New SoundRes
> mysound.PlayWav(ClickSound)
|
|
|
|
|