vb的MCI控件如何实现循环播放?

2024-12-21 06:16:55
推荐回答(2个)
回答1:

你应在 MCI 的 StatusUpdate 事件中检测控件的 mode 属性,
MCI 的 StatusUpdate 事件与 Timer 控件非常相似。

Private Sub Form_Load()
'设置MDI控件的 StatusUpdate 事件触发时间为 0.1 秒
MMControl1.UpdateInterval = 100
End Sub

Private Sub MMControl1_StatusUpdate()
dim F As String
If MMControl1.Mode = 525 Then
If List1.ListCount < 1 Then Exit Sub
If List1.ListIndex >= List1.ListCount - 1 Then
List1.ListIndex = 0
Else
List1.ListIndex = List1.ListIndex + 1
End If
F = "C:\WINDOWS\Media\" & List1.List(List1.ListIndex)'此处根据需要修改
call PlayFile(f)'你的播放过程,我的例子为 PlayFile
End If
End Sub

Private Sub PlayFile(F As String)
MMControl1.Command = "Close"
MMControl1.Notify = False
MMControl1.Wait = True
MMControl1.Shareable = False
MMControl1.DeviceType = "WaveAudio"
MMControl1.filename = F

MMControl1.Command = "Open"
DoEvents
MMControl1.Command = "Play"
End Sub

回答2:

判断到头拉重新来呗