Results 1 to 5 of 5

Thread: To check playback completion

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2008
    Posts
    27

    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

  2. #2
    Fanatic Member schoolbusdriver's Avatar
    Join Date
    Jan 2006
    Location
    O'er yonder
    Posts
    1,020

    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.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jul 2008
    Posts
    27

    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.

  4. #4
    Fanatic Member schoolbusdriver's Avatar
    Join Date
    Jan 2006
    Location
    O'er yonder
    Posts
    1,020

    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:
    1. Option Explicit
    2.  
    3. 'Form level code.
    4.  
    5. Private play_completion As Boolean
    6.  
    7. Private Sub Form_Click()
    8.    MMControl1.FileName = "C:\Temp\wmpaud9.wav"
    9.    MMControl1.Command = "Open"
    10.    MMControl1.Command = "Play"
    11.    play_completion = False
    12.    While (play_completion = False) 'Wait until play is completed.
    13.       DoEvents '<-------------------------------------------------
    14.    Wend
    15.    MMControl1.Command = "Close"
    16.    MMControl1.FileName = "C:\Temp\S11.wav"
    17.    MMControl1.Command = "Open"
    18.    MMControl1.Command = "Play"
    19. End Sub
    20.  
    21. Private Sub MMControl1_Done(NotifyCode As Integer)
    22.    Me.Caption = "NotifyCode = : " & NotifyCode
    23.    play_completion = True
    24. End Sub

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jul 2008
    Posts
    27

    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:
    1. MMControl1.Command = "Play"
    2.  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
  •  



Click Here to Expand Forum to Full Width