|
-
Aug 8th, 2000, 01:35 PM
#1
Thread Starter
New Member
If I have an alarm clock and when the alarm goes off at a specified time, I use the Beep function. How do I change the code to play a wave file instead of Beep function? Is there a simple way?
-
Aug 8th, 2000, 01:47 PM
#2
Use the PlaySound API.
Code:
Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
Private Sub Command1_Click()
'Play the WAV
PlaySound "C:\MyFile.wav", 0&, &H1
End Sub
-
Aug 8th, 2000, 02:05 PM
#3
If Megatron's code doesn't work, you could also use:
Code:
Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Global Const SND_ASYNC = &H1
Global Const SND_NODEFAULT = &H2
Sub Playwav(file)
SoundName$ = file
wFlags% = SND_ASYNC Or SND_NODEFAULT
X% = sndPlaySound(SoundName$, wFlags%): NoFreeze% = DoEvents()
End Sub
Usage:
'Play
'Playwav "C:\wavfile.wav"
'Stop
'Playwav " "
-
Aug 8th, 2000, 02:14 PM
#4
Keep in mind that sndPlaySound is superseded by PlaySound, hence it's obsolete.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|