Search Tools Links Login

Play .WAV (example 1)


Check if soundcard exist and then play a wave-file. http://137.56.41.168:2080/VisualBasicSource/vb4playwav.txt

Original Author: Found on the World Wide Web

API Declarations

Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Public Declare Function waveOutGetNumDevs Lib "winmm" () As Long
Global Const SND_SYNC = &H0 'just after the sound is ended exit function
Global Const SND_ASYNC = &H1 'just after the beginning of the sound exit function
Global Const SND_NODEFAULT = &H2 'if the sound cannot be found no error message
Global Const SND_LOOP = &H8 'repeat the sound until the function is called again
GLOBAL Const SND_NOSTOP = &H10 'if currently a sound is played the function will return without playing the selected sound
Global Const Flags& = SND_ASYNC Or SND_NODEFAULT

Code

'Add the following code to the Command1_Click event on a form:
Private Sub Command1_Click()
'Add the following code to the Command1_Click event:
  Dim i As Long
  Const SoundFileName$ = "c:sb16sampless_16_44.wav"
  i = waveOutGetNumDevs()
  If i > 0 Then  'There is at least one sound device.
i& = sndPlaySound(SoundFileName$, Flags&)
  Else
   Beep
  End If
End Sub

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 92 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.