Hey.. I amm trying to figure out how to make a command button play a sound clip. If someone could help me out, that would be great. Thanks!
Printable View
Hey.. I amm trying to figure out how to make a command button play a sound clip. If someone could help me out, that would be great. Thanks!
Use the MCISENDSTRING API call - theres a help and example page on this at :
http://www.vbapi.com/ref/m/mcisendstring.html
Alright.. well.. I went to that page and set up my program as directed. Now when I click on my command buttons that should be playing the wav files, i get this error message:
MMSYSTEM263 This is not a registered MCI device.
Can anyone help me? or provide me with an alternate method?
Or you can use the PlaySound API function.
Code:Option Explicit
Private Declare Function PlaySound Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal lpszName As String, ByVal _
hModule As Long, ByVal dwFlags As Long) As Long
Private Const SND_SYNC = &H0 ' Play synchronously (default).
Private Const SND_ASYNC = &H1 ' Play asynchronously (see note below).
Private Const SND_NODEFAULT = &H2 ' Do not use default sound.
Private Const SND_MEMORY = &H4 ' lpszSoundName points to a memory file.
Private Const SND_LOOP = &H8 ' Loop the sound until next sndPlaySound.
Private Const SND_NOSTOP = &H10 ' Do not stop any currently playing sound.
Private Const SND_PURGE = &H40 ' purge non-static events for task
Private Sub Form_Load()
'Play a WAV File
PlaySound "C:\welcome.wav", 0&, SND_ASYNC Or SND_NODEFAULT
'Play a WAV file with loop
'PlaySound "C:\welcome.wav", 0&, SND_ANSYC Or SND_LOOP
'Stop playing a WAV file
'PlaySound "C:\welcome.wav", 0&, SND_PURGE
End Sub
dont say "sequencer" in the line, say "wave" or "audio" I think that's yer problem...