VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Play .WAV (example 1)

by Found on the World Wide Web (15 Submissions)
Category: Windows System Services
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Date Added: Wed 3rd February 2021
Rating: (38 Votes)

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

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

Rate Play .WAV (example 1)

'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:\sb16\samples\s_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

Download this snippet    Add to My Saved Code

Play .WAV (example 1) Comments

No comments have been posted about Play .WAV (example 1). Why not be the first to post a comment about Play .WAV (example 1).

Post your comment

Subject:
Message:
0/1000 characters