does anyone know how to play wave file, WITHOUT using any special control for it (with api maybe...)?
Printable View
does anyone know how to play wave file, WITHOUT using any special control for it (with api maybe...)?
Like this:
'--[Form1.frm]------------------------
option Explicit
Const pathWavFiles = "C:\WinNT\Media\"
private Sub Command1_Click()
PlayWav "tada.wav"
End Sub
Sub PlayWav(SoundName as string)
Dim tmpSoundName as string
Dim wFlags%, X%
tmpSoundName = pathWavFiles & SoundName
wFlags% = SND_ASYNC Or SND_NODEFAULT
X% = sndPlaySound(tmpSoundName, wFlags%)
End Sub
'-------------------------------------
'--[Module1.bas]----------------------
' WAV Sound values
Global Const SND_SYNC = &H0
Global Const SND_ASYNC = &H1
Global Const SND_NODEFAULT = &H2
Global Const SND_LOOP = &H8
Global Const SND_NOSTOP = &H10
#If Win32 then
public Declare Function sndPlaySound& _
Lib "winmm.dll" Alias "sndPlaySoundA" _
(byval lpszSoundName as string, byval uFlags as Long)
#else
public Declare Function sndPlaySound% _
Lib "mmsystem.dll" (byval lpszSoundName _
as string, byval uFlags as Integer)
#End If 'WIN32
'-------------------------------------
hope this helps,
John
John Pirkey
MCSD
www.ShallowWaterSystems.com
'forms declarations:
Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA"(ByVal lpszSoundName as String, ByVal uFlags as Long) As Long
'CODE
Dim filename as String
Dim rc as Long
filename = "C:\windows\media\the microsoft sound.wav"
rc = sndPlaySound(filename, 1)
' put that peave of code ^ there in whatever you want when to play the wave file
Subzero