|
-
Jun 10th, 2000, 12:01 PM
#1
Thread Starter
Member
how can i play a wav sound in a vb program.
i am using media player control but that only for win 98.
plus if i put the sound in the same directory as the program (after it's compiled to exe) it can't find them. i didn't sepecify a path to look in. i just wrote the sound name.
i've tried sound recorder control but it didn't work. (some error)
is there a another way to play wave sounds that is compatible with windows 95.
thank you
I Use Visual Basic 5.0 Enterprise Edition SP3
-
Jun 10th, 2000, 12:09 PM
#2
Code:
Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Public Const SND_ASYNC = &H1
Public Const SND_NODEFAULT = &H2
Put the above code in the General Declarations of a module. Then, to play a file, use:
Call sndPlaySound("C:\MyFile.wav", SND_ASYNC Or SND_NODEFAULT)
To stop all wave sounds currently playing, use:
Call sndPlaySound(vbNullString, SND_NODEFAULT)
-
Jun 10th, 2000, 12:19 PM
#3
Thread Starter
Member
Thank you very much
but will it work if you don't specify a path. (in other words, will it look for the sound in the same directory as the program is, if i don't put a path for it?)
I Use Visual Basic 5.0 Enterprise Edition SP3
-
Jun 10th, 2000, 12:51 PM
#4
If it is in your directory:
Code:
Call sndPlaySound(App.path & "\MyFile.wav", SND_ASYNC Or SND_NODEFAULT)
If it is a different directory:
Code:
Call sndPlaySound("C:\Windows\MyFile.wav", SND_ASYNC Or SND_NODEFAULT)
-
Jun 10th, 2000, 09:48 PM
#5
And if the file is not found, I makes the standard Beep sound.
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
|