Connecting Tech Pros Worldwide Forums | Help | Site Map

How to play sound in .net?

CM
Guest
 
Posts: n/a
#1: Nov 20 '05
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



james
Guest
 
Posts: n/a
#2: Nov 20 '05

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]


james
Guest
 
Posts: n/a
#3: Nov 20 '05

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]


CM
Guest
 
Posts: n/a
#4: Nov 20 '05

re: How to play sound in .net?


Thank you very much!
CM


CM
Guest
 
Posts: n/a
#5: Nov 20 '05

re: How to play sound in .net?


Thank you very much!
CM


CM
Guest
 
Posts: n/a
#6: Nov 20 '05

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]


CM
Guest
 
Posts: n/a
#7: Nov 20 '05

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]


james
Guest
 
Posts: n/a
#8: Nov 20 '05

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]


james
Guest
 
Posts: n/a
#9: Nov 20 '05

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]


MSN
Guest
 
Posts: n/a
#10: Nov 20 '05

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]


MSN
Guest
 
Posts: n/a
#11: Nov 20 '05

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]


Closed Thread


Similar Visual Basic .NET bytes