Play and stop playing a wav file

vincentnl

Active member
Joined
Mar 29, 2003
Messages
40
Location
Netherlands
I am programming a schoolproject, which is to be for the elderly.

It involves a lot of spoken text (wav files).

But when the user clicks something, the wavfile should stop playing , and another should play.

The solution proposed on this forum :

Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long

works for playing wav-files, but I can not stop a wav-file that is playing.

What is the best solution for this?
 
well i really dont know what the solution is i just thought id throw out some ideas. One thing u could try it to set a variable when u start playing the wav file. something like
Code:
 dim p as boolean = PlaySound
and have it when the user clicks a button it will set p to 0 stopping play, then have it play the new wav file. I really dont know EXACTLY what it needs to be just thought id give an idea :) hope that helps
 
its better to use mciSendString to play the wav , you have much more control :) eg:
Code:
    Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Integer, ByVal hwndCallback As Integer) As Integer
/// just below windows generated code ^^^^
//////////////////////////////////////////////////////////

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim x As Integer = mciSendString("Open D:\Knock.Wav type waveaudio alias Knock", Nothing, Nothing, Nothing)
        Dim i As Integer = mciSendString("Play Knock", Nothing, Nothing, Nothing)
        ///opens the wav and plays it ^^^^
        ///then to close it....
        i = mciSendString("Stop Knock", Nothing, Nothing, Nothing)
        ///this stops it when its playing ^^^^
    End Sub
hope it helps.
 
Back
Top