|
-
Jul 17th, 2008, 05:03 AM
#1
Thread Starter
Junior Member
To check playback completion
hello everybody, i am doing a project in which i need to play two wav files one after other when command button is clicked. what i want to know is how check playback is completion. here is my code
Code:
Private Sub Command2_Click()
MMControl1.FileName = "E:\files\1_E.wav"
MMControl1.Command = "Open"
MMControl1.Command = "Play"
'what code to be inserted here
MMControl1.Command = "close"
MMControl1.FileName = "E:\files\4_E.wav"
MMControl1.Command = "Open"
MMControl1.Command = "Play"
'what code to be inserted here
MMControl1.Command = "close"
End Sub
thanks
-
Jul 17th, 2008, 03:57 PM
#2
Re: To check playback completion
Not tested this but try the "MMControl1_Done (NotifyCode As Integer)" event to check for completion of playback.
If you've got MSDN put "Multimedia MCI control" into keyword search in the Index tab.
Code:
From MSDN:
Occurs when an MCI command for which the Notify property is True finishes.
Syntax
Private Sub MMControl_Done (NotifyCode As Integer)
Remarks
The NotifyCode argument indicates whether the MCI command succeeded. It can take any of the following settings.
Value Setting/Result
1 mciSuccessful - Command completed successfully.
2 mciSuperseded - Command was superseded by another command.
4 mciAborted - Command was aborted by the user.
8 mciFailure - Command failed.
-
Jul 17th, 2008, 11:18 PM
#3
Thread Starter
Junior Member
Re: To check playback completion
i tried sir but it doesn't works. here is code
Code:
Option Explicit
Dim play_completion As Boolean
MMControl1.FileName = CurDir$ & "\files\tune.wav"
MMControl1.Command = "Open"
MMControl1.Command = "Play"
play_completion = False
While (play_completion = False) ' wait until play is completed.
Wend
MMControl1.Command = "Close"
MMControl1.FileName = CurDir$ & "\files\T.wav"
MMControl1.Command = "Open"
MMControl1.Command = "Play"
Private Sub MMControl1_Done(NotifyCode As Integer)
play_completion = True
End Sub
first file is played and its wait forever in while loop because it doesn't fires MMcontrol1_Done event. please help me.
-
Jul 18th, 2008, 04:56 AM
#4
Re: To check playback completion
Your prog gets locked-up because there is nothing in the loop that allows other events to fire. Use DoEvents. i.e.
vb Code:
Option Explicit
'Form level code.
Private play_completion As Boolean
Private Sub Form_Click()
MMControl1.FileName = "C:\Temp\wmpaud9.wav"
MMControl1.Command = "Open"
MMControl1.Command = "Play"
play_completion = False
While (play_completion = False) 'Wait until play is completed.
DoEvents '<-------------------------------------------------
Wend
MMControl1.Command = "Close"
MMControl1.FileName = "C:\Temp\S11.wav"
MMControl1.Command = "Open"
MMControl1.Command = "Play"
End Sub
Private Sub MMControl1_Done(NotifyCode As Integer)
Me.Caption = "NotifyCode = : " & NotifyCode
play_completion = True
End Sub
-
Jul 18th, 2008, 11:18 PM
#5
Thread Starter
Junior Member
Re: To check playback completion
thanks u very much sir. i noticied a small error , when i click the form for the first time, first file is not played but second file is played. when i click the form again , both files are played and it works fine. i order to eliminate i added two commands
vb Code:
MMControl1.Command = "Play"
MMControl1.Command = "Close"
during form load event and it works fine. is it a correct way?. thanks again.
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
|