How do you can you simply play audio files (ie .wav) when a command is clicked?
Thanks in advance.
yellowTIGER
Printable View
How do you can you simply play audio files (ie .wav) when a command is clicked?
Thanks in advance.
yellowTIGER
put this code in a module (or replace public with private and place anywhere...):
public Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (byval lpszSoundName as string, byval uFlags as Long) as Long
public Const SND_ASYNC = &H1
public Const SND_LOOP = &H8
public Const SND_MEMORY = &H4
public Const SND_NODEFAULT = &H2
public Const SND_SYNC = &H0
This is all the declaration you need to play a .wav file. Use code of this sort to play a file called "C:\test.wav" when command1 is clicked:
private Sub Command1_Click()
sndPlaySound "C:\test.wav", SND_ASYNC
End Sub
This will play the sound and immediately continue to execute code. If you put the flag SND_SYNC instead of SND_ASYNC, code execution will stop until the sound has finished playing (be careful with this one; is you put this kind of sound in a loop, you may hang your system!!!). It's fast and easy. I hope this info was useful!