📄 data16.dat
字号:
使用MMControl控件播放媒体文件
本例设计了一个多媒体播放器,它能够播放WAV、MIDI和AVI文件。
Private Sub Check2_Click()
If Check2.Value = 1 Then
'关闭AVI文件的声音
MMControl1.Silent = True
Else
'打开AVI文件的声音
MMControl1.Silent = False
End If
End Sub
Private Sub ComClose_Click()
MMControl1.Command = "close"
End Sub
Private Sub ComPlay_Click()
MMControl1.Command = "close"
DiaOpen.Filter = "Wav文件|*.wav|MIDI文件|*.mid|AVI文件|*.avi"
DiaOpen.ShowOpen
MMControl1.FileName = DiaOpen.FileName
MMControl1.Command = "open"
MMControl1.Command = "play"
LabFile.Caption = DiaOpen.FileName
End Sub
Private Sub Form_Load()
'初始化
MMControl1.Visible = False
MMControl1.Notify = True
MMControl1.Shareable = False
MMControl1.TimeFormat = 0
End Sub
Private Sub Form_Unload(Cancel As Integer)
MMControl1.Command = "close"
End Sub
Private Sub MMControl1_StatusUpdate()
'计算文件总长度,单位为秒
LabLen.Caption = MMControl1.Length / 1000
'动态显示当前的播放位置
LabPlay.Caption = MMControl1.Position / 1000
End Sub
Private Sub MMControl1_Done(NotifyCode As Integer)
'如果文件播放结束
If MMControl1.Position = MMControl1.Length Then
'倒回止文件的起点
MMControl1.Command = "prev"
'如果选择了自动重复播放
If Check1.Value = 1 Then
MMControl1.Command = "play"
End If
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -