Hi All,
This is snippet of my code.
Private Sub cmdStart_Click ()
m_lngPlayFromElementNo = 5
m_lngPlayToElementNo =15
m_myPlayThread = New Thread(AddressOf PlaySelectedAudio)
m_myPlayThread.Start()
End Sub
Private Sub PlaySelectedAudio()
Dim lngCounter As Long
m_blnIsPlayStop = False
m_objAudioRecorderPlayer.OpenExistingFile(m_strTem pWaveFileName)
For lngCounter = m_lngPlayFromElementNo To m_lngPlayToElementNo
Dim lngPlayFromTime As Long = 0
Dim lngPlayToTime As Long = 0
lngPlayFromTime = Val(objWordData.arrWordDataTable(lngCounter, 6)) *
10
lngPlayToTime = Val(objWordData.arrWordDataTable(lngTempCounter, 6))
* 10
m_objAudioRecorderPlayer.StartPlaying(lngPlayFromT ime,
lngPlayToTime)
m_myPlayThread.Sleep((lngPlayToTime - lngPlayFromTime))
' Start playing and wait until complete.
If m_blnIsPlayStop = True Then GoTo StopThread
Next
StopThread:
m_objAudioRecorderPlayer.StopPlaying()
m_objAudioRecorderPlayer.CloseFile()
End Sub
Public Sub cmdStop_Click()
m_blnIsPlayStop = True
End Sub
I am using "mciSendString" API for Audio functionality.
While control is in Thread and file is playing myThread is in sleep state.
Now if user clicks on STOP button thread should stop playing wave file.
Please tell me how to do that.
Thank all of you for your reply.
Thanks and Regards,
Sakharam Phapale
"Cor Ligthert" <no************@planet.nl> wrote in message
news:eH**************@TK2MSFTNGP11.phx.gbl...
Sakharam,
Show us as well how you start the wav file, when it is with a
process.start it will in my opinion not help you much using the thread. Than that
process will probably directly be started and the mythread directly close.
Beside that some comments inline
Private myThread As Thread
Sub cmdStart_Click()
myThread = New Thread(AddressOf PlayAudio)
myThread.Start
End Sub
Sub PlayAudio()
Open wave file
Play wave file
Close wave file
Thread.Abort
This one above is useless End Sub
Sub cmdStop_Click()
Close wave file
This one above should be impossible Thread.Abort
With this you mean probably
MyThread.abort, End Sub
I hope this gives some ideas?
Cor