|
-
Sep 6th, 2000, 07:02 PM
#1
How do i get a .wav sound to play, I've tried this:
In the general declarations:
Private Const SND_ASYNC = &H1
Private Const SND_NODEFAULT = &H1
Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
and in the form_load:
strWavFile = App.Path & "\mywavfile.wav"
Call sndPlaySound(strWavFile, SND_ASYNC And SND_NODEFAULT)
end it doesn't seem to work. Can anyone help?
-
Sep 6th, 2000, 07:04 PM
#2
_______
<?>
Code:
'Play A sound
'Paste this code into a bas module
'
'API Function to play the sound
'
Declare Function sndPlaySound Lib "winmm" Alias _
"sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long
'
' play synchronously (default)
Public Const SND_SYNC = &H0
' play asynchronously
Public Const SND_ASYNC = &H1
' loop the sound until next
Public Const SND_LOOP = &H8
'=====================================================
'Paste this code into the main
'from your main program (button or load or whatever):
'call the function using your wave file & location..replace "A:\whoosh.wav"
'
Call sndPlaySound(ByVal "a:\whoosh.wav", SND_ASYNC)
'to stop it playing
call sndPlaySound("")
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Sep 6th, 2000, 07:18 PM
#3
Use the PlaySound api function instead of the sndPlaySound api function.
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 wav
PlaySound "C:\MyFile.wav", 0&, &H1
End Sub
Private Sub Command2_Click()
'Stop wav
PlaySound "C:\MyFile.wav", 0&, &H4
'or is it:
'PlaySound " ", 0&, &H1
End Sub
-
Sep 6th, 2000, 07:29 PM
#4
_______
<?>
There is no difference in the sound effect..just that playsound is the latter version destined to replace sndSound
The same deal as [Let X = 12] and [x = 12]..both work..one is just old...I must be showing my age..using old code.
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Sep 7th, 2000, 12:56 AM
#5
Conquistador
they both work fine, it's just a choice of your preference!
i think that's tautology?!?
i.e
it's free and complimentary?
-
Jul 11th, 2001, 12:37 AM
#6
Hyperactive Member
sndPlaySound vs PlaySound
I don't know if this has any relevence, but it's qiute obvious that the PlaySound function is a superset of the old sndPlaySound function involved with the early 16 bit windows. And when they made PlaySound it was made 32 bit. So you ask what the difference is, I tell you. sndPlaySound : 16 bit, PLaySound : 32 bit.
Visual Basic 6.0 Enterprise
Visual C++ 6.0 Professional
Wak 
-
Jul 11th, 2001, 09:45 AM
#7
Use the PlaySound api function instead of the sndPlaySound api function.
There's no difference in simply playing a WAV file. The main difference is that PlaySound lets you play sounds stored as resources.
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
|