|
|
Title | Play a sound while displaying ellapsed time |
Keywords | sound, WAV, WaveAudio, MMC, ellapsed time |
Categories | Multimedia, Controls |
|
|
Use a Timer and examine the MCI control's Position property to find the ellapsed time. When you reach a certain time, you could trigger some other event. Using that technique, you can synchronize your program to the sound.
|
|
Private Sub Form_Load()
' Prepare the MCI control for WaveAudio.
MMControl1.Notify = False
MMControl1.Wait = True
MMControl1.Shareable = False
MMControl1.DeviceType = "WaveAudio"
MMControl1.TimeFormat = mciFormatMilliseconds
End Sub
' Open the device and play the sound.
Private Sub cmdPlay_Click()
' Disable this button.
cmdPlay.Enabled = False
' Set the file name.
MMControl1.FileName = txtFilename.Text
' Open the MCI device.
MMControl1.Wait = False
MMControl1.Command = "Open"
' Play the sound without waiting.
MMControl1.Wait = False
MMControl1.Command = "Play"
' Enable the timer.
tmrSound.Enabled = True
End Sub
' Close the device when the sound is done.
Private Sub MMControl1_Done(NotifyCode As Integer)
' Disable the timer.
tmrSound.Enabled = False
' Close the device.
MMControl1.Command = "Close"
' Reenable the button.
cmdPlay.Enabled = True
End Sub
' Display the time through the sound clip.
Private Sub tmrSound_Timer()
Dim txt As String
txt = MMControl1.Position \ 1000 & " seconds"
If lblEllapsed.Caption <> txt Then lblEllapsed.Caption _
= txt
End Sub
|
|
|
|
|
|