News:

MyKidsDiary.in :: Capture your kids magical moment and create your Online Private Diary for your kids

Main Menu

The timer plays the sound asynchronously

Started by nandagopal, Dec 19, 2008, 05:34 PM

Previous topic - Next topic

nandagopal

To play the file, start a timer. The timer checks the MMC control's Mode and, if the mode is mciModeStop, it plays the file.

The timer plays the sound asynchronously so the program can execute steps while the sound is playing. IN particular, it can stop the sound immediately.


Private Sub Form_Load()
    ' Prepare the MCI control for WaveAudio.
    MMControl1.Notify = False
    MMControl1.Wait = True
    MMControl1.Shareable = False
    MMControl1.DeviceType = "WaveAudio"
End Sub

' Open the device and play the sound.
Private Sub cmdPlay_Click()
    If Timer1.Enabled Then
        Timer1.Enabled = False
        cmdPlay.Caption = "Play"

        ' Close the device.
        MMControl1.Command = "Close"
    Else
        Timer1.Enabled = True
        cmdPlay.Caption = "Stop"
   
        ' Set the file name.
        MMControl1.FileName = txtFile.Text

        ' Open the MCI device.
        MMControl1.Wait = True
        MMControl1.Command = "Open"
    End If
End Sub

Private Sub Timer1_Timer()
    ' See what mode the MCI control is in.
    If MMControl1.Mode = mciModeStop Then
        ' It's stopped. Play it again, Sam.
        MMControl1.Wait = True
        MMControl1.Command = "Prev"
        MMControl1.Command = "Play"
    End If
End Sub