VB icon

Play .WAV (example 1)

Email
Submitted on: 1/1/2015 11:22:00 AM
By: Found on the World Wide Web (from psc cd)  
Level: Not Given
User Rating: By 38 Users
Compatibility: VB 3.0, VB 4.0 (16-bit), VB 4.0 (32-bit), VB 5.0, VB 6.0
Views: 463
 
     Check if soundcard exist and then play a wave-file. http://137.56.41.168:2080/VisualBasicSource/vb4playwav.txt
 

Windows API/Global Declarations:

Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
'**************************************
'Windows API/Global Declarations for :Play .WAV (example 1)
'**************************************
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:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: Play .WAV (example 1)
' Description:Check if soundcard exist and then play a wave-file. http://137.56.41.168:2080/VisualBasicSource/vb4playwav.txt
' By: Found on the World Wide Web (from psc cd)
'**************************************

'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


Other 14 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Not Given category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.