How to play sound in .net? | | |
Hi,
I used to use the following code to play sound in VB6:
Public Declare Function sndPlaySound32 Lib "winmm.dll" Alias "sndPlaySoundA"
_
(ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
call sndPlaySound32("c:\WinNt\Media\ding.wav", 0)
However, .net don't recognize "call", and generate a syntax error. I just
wonder how to play sound in .net?
Thanks!
CM | | | | re: How to play sound in .net?
try this:
'//Win32API
'//Both integer args and return were originally Longs - .NET Integer = vb6
Long
Declare Function PlaySound Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal lpszName As String, _
ByVal hModule As Integer, _
ByVal dwFlags As Integer) As Integer
Friend Sub PlayAudio(ByVal FileName As String)
'//call win32api function to play audio (wav) file alert
Dim retval As Integer
retval = PlaySound(FileName, 0, 1)
'last param is SND_SYNC as integer
'value set to 0 plays sound Synchronously (waits until sound ends before
playing next)
'value set to 1 plays sound Asynchronously (does not wait to play next
sound)
End Sub
"CM" <cm111@hotmail.com> wrote in message
news:u6T7gJNHEHA.3576@TK2MSFTNGP10.phx.gbl...[color=blue]
> Hi,
>
> I used to use the following code to play sound in VB6:
>
> Public Declare Function sndPlaySound32 Lib "winmm.dll" Alias[/color]
"sndPlaySoundA"[color=blue]
> _
>
> (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
>
> call sndPlaySound32("c:\WinNt\Media\ding.wav", 0)
>
> However, .net don't recognize "call", and generate a syntax error. I just
> wonder how to play sound in .net?
>
>
>
> Thanks!
>
> CM
>
>[/color] | | | | re: How to play sound in .net?
try this:
'//Win32API
'//Both integer args and return were originally Longs - .NET Integer = vb6
Long
Declare Function PlaySound Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal lpszName As String, _
ByVal hModule As Integer, _
ByVal dwFlags As Integer) As Integer
Friend Sub PlayAudio(ByVal FileName As String)
'//call win32api function to play audio (wav) file alert
Dim retval As Integer
retval = PlaySound(FileName, 0, 1)
'last param is SND_SYNC as integer
'value set to 0 plays sound Synchronously (waits until sound ends before
playing next)
'value set to 1 plays sound Asynchronously (does not wait to play next
sound)
End Sub
"CM" <cm111@hotmail.com> wrote in message
news:u6T7gJNHEHA.3576@TK2MSFTNGP10.phx.gbl...[color=blue]
> Hi,
>
> I used to use the following code to play sound in VB6:
>
> Public Declare Function sndPlaySound32 Lib "winmm.dll" Alias[/color]
"sndPlaySoundA"[color=blue]
> _
>
> (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
>
> call sndPlaySound32("c:\WinNt\Media\ding.wav", 0)
>
> However, .net don't recognize "call", and generate a syntax error. I just
> wonder how to play sound in .net?
>
>
>
> Thanks!
>
> CM
>
>[/color] | | | | re: How to play sound in .net?
Thank you very much!
CM | | | | re: How to play sound in .net?
Thank you very much!
CM | | | | re: How to play sound in .net?
Hi, James:
It seems can only play .wav file. How to play .rm or other sound file?
Thanks!
CM
"james" <mod2software@nyc.rr.com> wrote in message
news:uCeW3VNHEHA.3776@tk2msftngp13.phx.gbl...[color=blue]
> try this:
>
> '//Win32API
> '//Both integer args and return were originally Longs - .NET Integer = vb6
> Long
> Declare Function PlaySound Lib "winmm.dll" _
> Alias "PlaySoundA" (ByVal lpszName As String, _
> ByVal hModule As Integer, _
> ByVal dwFlags As Integer) As Integer
>
> Friend Sub PlayAudio(ByVal FileName As String)
> '//call win32api function to play audio (wav) file alert
> Dim retval As Integer
> retval = PlaySound(FileName, 0, 1)
> 'last param is SND_SYNC as integer
> 'value set to 0 plays sound Synchronously (waits until sound ends before
> playing next)
> 'value set to 1 plays sound Asynchronously (does not wait to play next
> sound)
> End Sub
>
> "CM" <cm111@hotmail.com> wrote in message
> news:u6T7gJNHEHA.3576@TK2MSFTNGP10.phx.gbl...[color=green]
> > Hi,
> >
> > I used to use the following code to play sound in VB6:
> >
> > Public Declare Function sndPlaySound32 Lib "winmm.dll" Alias[/color]
> "sndPlaySoundA"[color=green]
> > _
> >
> > (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
> >
> > call sndPlaySound32("c:\WinNt\Media\ding.wav", 0)
> >
> > However, .net don't recognize "call", and generate a syntax error. I[/color][/color]
just[color=blue][color=green]
> > wonder how to play sound in .net?
> >
> >
> >
> > Thanks!
> >
> > CM
> >
> >[/color]
>
>[/color] | | | | re: How to play sound in .net?
Hi, James:
It seems can only play .wav file. How to play .rm or other sound file?
Thanks!
CM
"james" <mod2software@nyc.rr.com> wrote in message
news:uCeW3VNHEHA.3776@tk2msftngp13.phx.gbl...[color=blue]
> try this:
>
> '//Win32API
> '//Both integer args and return were originally Longs - .NET Integer = vb6
> Long
> Declare Function PlaySound Lib "winmm.dll" _
> Alias "PlaySoundA" (ByVal lpszName As String, _
> ByVal hModule As Integer, _
> ByVal dwFlags As Integer) As Integer
>
> Friend Sub PlayAudio(ByVal FileName As String)
> '//call win32api function to play audio (wav) file alert
> Dim retval As Integer
> retval = PlaySound(FileName, 0, 1)
> 'last param is SND_SYNC as integer
> 'value set to 0 plays sound Synchronously (waits until sound ends before
> playing next)
> 'value set to 1 plays sound Asynchronously (does not wait to play next
> sound)
> End Sub
>
> "CM" <cm111@hotmail.com> wrote in message
> news:u6T7gJNHEHA.3576@TK2MSFTNGP10.phx.gbl...[color=green]
> > Hi,
> >
> > I used to use the following code to play sound in VB6:
> >
> > Public Declare Function sndPlaySound32 Lib "winmm.dll" Alias[/color]
> "sndPlaySoundA"[color=green]
> > _
> >
> > (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
> >
> > call sndPlaySound32("c:\WinNt\Media\ding.wav", 0)
> >
> > However, .net don't recognize "call", and generate a syntax error. I[/color][/color]
just[color=blue][color=green]
> > wonder how to play sound in .net?
> >
> >
> >
> > Thanks!
> >
> > CM
> >
> >[/color]
>
>[/color] | | | | re: How to play sound in .net?
rm needs it's own api I believe. sorry can't help there
"CM" <cm111@hotmail.com> wrote in message
news:uqeze5NHEHA.3284@TK2MSFTNGP11.phx.gbl...[color=blue]
> Hi, James:
> It seems can only play .wav file. How to play .rm or other sound file?
> Thanks!
> CM
>
> "james" <mod2software@nyc.rr.com> wrote in message
> news:uCeW3VNHEHA.3776@tk2msftngp13.phx.gbl...[color=green]
> > try this:
> >
> > '//Win32API
> > '//Both integer args and return were originally Longs - .NET Integer =[/color][/color]
vb6[color=blue][color=green]
> > Long
> > Declare Function PlaySound Lib "winmm.dll" _
> > Alias "PlaySoundA" (ByVal lpszName As String, _
> > ByVal hModule As Integer, _
> > ByVal dwFlags As Integer) As Integer
> >
> > Friend Sub PlayAudio(ByVal FileName As String)
> > '//call win32api function to play audio (wav) file alert
> > Dim retval As Integer
> > retval = PlaySound(FileName, 0, 1)
> > 'last param is SND_SYNC as integer
> > 'value set to 0 plays sound Synchronously (waits until sound ends before
> > playing next)
> > 'value set to 1 plays sound Asynchronously (does not wait to play next
> > sound)
> > End Sub
> >
> > "CM" <cm111@hotmail.com> wrote in message
> > news:u6T7gJNHEHA.3576@TK2MSFTNGP10.phx.gbl...[color=darkred]
> > > Hi,
> > >
> > > I used to use the following code to play sound in VB6:
> > >
> > > Public Declare Function sndPlaySound32 Lib "winmm.dll" Alias[/color]
> > "sndPlaySoundA"[color=darkred]
> > > _
> > >
> > > (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
> > >
> > > call sndPlaySound32("c:\WinNt\Media\ding.wav", 0)
> > >
> > > However, .net don't recognize "call", and generate a syntax error. I[/color][/color]
> just[color=green][color=darkred]
> > > wonder how to play sound in .net?
> > >
> > >
> > >
> > > Thanks!
> > >
> > > CM
> > >
> > >[/color]
> >
> >[/color]
>
>[/color] | | | | re: How to play sound in .net?
rm needs it's own api I believe. sorry can't help there
"CM" <cm111@hotmail.com> wrote in message
news:uqeze5NHEHA.3284@TK2MSFTNGP11.phx.gbl...[color=blue]
> Hi, James:
> It seems can only play .wav file. How to play .rm or other sound file?
> Thanks!
> CM
>
> "james" <mod2software@nyc.rr.com> wrote in message
> news:uCeW3VNHEHA.3776@tk2msftngp13.phx.gbl...[color=green]
> > try this:
> >
> > '//Win32API
> > '//Both integer args and return were originally Longs - .NET Integer =[/color][/color]
vb6[color=blue][color=green]
> > Long
> > Declare Function PlaySound Lib "winmm.dll" _
> > Alias "PlaySoundA" (ByVal lpszName As String, _
> > ByVal hModule As Integer, _
> > ByVal dwFlags As Integer) As Integer
> >
> > Friend Sub PlayAudio(ByVal FileName As String)
> > '//call win32api function to play audio (wav) file alert
> > Dim retval As Integer
> > retval = PlaySound(FileName, 0, 1)
> > 'last param is SND_SYNC as integer
> > 'value set to 0 plays sound Synchronously (waits until sound ends before
> > playing next)
> > 'value set to 1 plays sound Asynchronously (does not wait to play next
> > sound)
> > End Sub
> >
> > "CM" <cm111@hotmail.com> wrote in message
> > news:u6T7gJNHEHA.3576@TK2MSFTNGP10.phx.gbl...[color=darkred]
> > > Hi,
> > >
> > > I used to use the following code to play sound in VB6:
> > >
> > > Public Declare Function sndPlaySound32 Lib "winmm.dll" Alias[/color]
> > "sndPlaySoundA"[color=darkred]
> > > _
> > >
> > > (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
> > >
> > > call sndPlaySound32("c:\WinNt\Media\ding.wav", 0)
> > >
> > > However, .net don't recognize "call", and generate a syntax error. I[/color][/color]
> just[color=green][color=darkred]
> > > wonder how to play sound in .net?
> > >
> > >
> > >
> > > Thanks!
> > >
> > > CM
> > >
> > >[/color]
> >
> >[/color]
>
>[/color] | | | | re: How to play sound in .net?
I couldn't get this to work on web pages.
Does this work on web pages?
"james" <mod2software@nyc.rr.com> wrote in message
news:uCeW3VNHEHA.3776@tk2msftngp13.phx.gbl...[color=blue]
> try this:
>
> '//Win32API
> '//Both integer args and return were originally Longs - .NET Integer = vb6
> Long
> Declare Function PlaySound Lib "winmm.dll" _
> Alias "PlaySoundA" (ByVal lpszName As String, _
> ByVal hModule As Integer, _
> ByVal dwFlags As Integer) As Integer
>
> Friend Sub PlayAudio(ByVal FileName As String)
> '//call win32api function to play audio (wav) file alert
> Dim retval As Integer
> retval = PlaySound(FileName, 0, 1)
> 'last param is SND_SYNC as integer
> 'value set to 0 plays sound Synchronously (waits until sound ends before
> playing next)
> 'value set to 1 plays sound Asynchronously (does not wait to play next
> sound)
> End Sub
>
> "CM" <cm111@hotmail.com> wrote in message
> news:u6T7gJNHEHA.3576@TK2MSFTNGP10.phx.gbl...[color=green]
> > Hi,
> >
> > I used to use the following code to play sound in VB6:
> >
> > Public Declare Function sndPlaySound32 Lib "winmm.dll" Alias[/color]
> "sndPlaySoundA"[color=green]
> > _
> >
> > (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
> >
> > call sndPlaySound32("c:\WinNt\Media\ding.wav", 0)
> >
> > However, .net don't recognize "call", and generate a syntax error. I[/color][/color]
just[color=blue][color=green]
> > wonder how to play sound in .net?
> >
> >
> >
> > Thanks!
> >
> > CM
> >
> >[/color]
>
>[/color] | | | | re: How to play sound in .net?
I couldn't get this to work on web pages.
Does this work on web pages?
"james" <mod2software@nyc.rr.com> wrote in message
news:uCeW3VNHEHA.3776@tk2msftngp13.phx.gbl...[color=blue]
> try this:
>
> '//Win32API
> '//Both integer args and return were originally Longs - .NET Integer = vb6
> Long
> Declare Function PlaySound Lib "winmm.dll" _
> Alias "PlaySoundA" (ByVal lpszName As String, _
> ByVal hModule As Integer, _
> ByVal dwFlags As Integer) As Integer
>
> Friend Sub PlayAudio(ByVal FileName As String)
> '//call win32api function to play audio (wav) file alert
> Dim retval As Integer
> retval = PlaySound(FileName, 0, 1)
> 'last param is SND_SYNC as integer
> 'value set to 0 plays sound Synchronously (waits until sound ends before
> playing next)
> 'value set to 1 plays sound Asynchronously (does not wait to play next
> sound)
> End Sub
>
> "CM" <cm111@hotmail.com> wrote in message
> news:u6T7gJNHEHA.3576@TK2MSFTNGP10.phx.gbl...[color=green]
> > Hi,
> >
> > I used to use the following code to play sound in VB6:
> >
> > Public Declare Function sndPlaySound32 Lib "winmm.dll" Alias[/color]
> "sndPlaySoundA"[color=green]
> > _
> >
> > (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
> >
> > call sndPlaySound32("c:\WinNt\Media\ding.wav", 0)
> >
> > However, .net don't recognize "call", and generate a syntax error. I[/color][/color]
just[color=blue][color=green]
> > wonder how to play sound in .net?
> >
> >
> >
> > Thanks!
> >
> > CM
> >
> >[/color]
>
>[/color] |  | Similar Visual Basic .NET bytes | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,510 network members.
|