Can you use .wav file in a windows form app?

felipe

Member
Joined
Nov 5, 2003
Messages
7
i was wondering if there was a control that would let you play a .wav file when a certain event happends?

i found a windows media player control but you have to open the file yourself, im looking for something that will act automaticly and be triggered by an event procedure.

is there anything like this available in VB.Net?
 
You can use ...
Code:
Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long

use this to play it...
 PlaySound(Application.StartupPath & "\soundFile.wav", 0&, 0&)
 
thanks a lot for the reply guys,

i tried the above code and set it up to a click event on the mouse,
i am getting a sound but its a default windows sound, the one you get when an error message box shows up.
i put a try/catch block around the function call of PlaySound and it doesnt trigger anything.

any ideas?
 
ok, i fixed the last problem, one last thing though. The program is paused until the .wav file is done playing. Is there any variable or constant which can be used to control this action?
 
If you look up that function in MSDN youll see there is a flag you can pass it to play the sound asynchronously.
 
Back
Top