|
|
Title | Play a sound while displaying a progress bar |
Keywords | sound, WAV, WaveAudio, MMC, ellapsed time |
Categories | Multimedia, Controls |
|
|
Use a Timer and examine the MCI control's Position and Length properties to determine how far through the file the program has gone.
|
|
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.
ProgressBar1.Value = 100
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()
ProgressBar1.Value = MMControl1.Position / _
MMControl1.Length * 100
End Sub
|
|
|
|
|
|