vb6.0版视频播放器程序代码

Dim i As Integer
Dim pa, a, k As String

Private Sub Form_Load()
Randomize
End Sub

Private Sub btnOpen_Click()

   Dim song As String

With CommonDialog1
.FileName = “”
.Filter = “.mp4;.avi;.wmv;.mov|.mp4;.avi;.wmv;.mov”
.Flags = 512
.ShowOpen
song = .FileName
End With

If song = “” Then Exit Sub
a = “”
For i = Len(song) To 1 Step -1
k = Mid(song, i, 1)
If k = " " Then '多首歌的分隔符
txtVideoFileList.AddItem a
a = “”
ElseIf k = “” Then '一首歌时歌名与路径的分隔符
txtVideoFileList.AddItem a
pa = Left(song, i)
Exit Sub
Else
a = k & a
End If
Next i

End Sub

Private Sub btnPlay_Click()
MediaPlayer1.URL = pa & txtVideoFileList.Text '播放
End Sub

Private Sub btnStop_Click()
MediaPlayer1.Controls.stop '停止

End Sub

Private Sub btnPause_Click()
MediaPlayer1.Controls.pause '暂停
End Sub

Private Sub btnResume_Click()
MediaPlayer1.Controls.play '继续
End Sub

Private Sub btnRandom_Click()
Dim selectedIndex As Integer
selectedIndex = Int(Rnd * txtVideoFileList.ListCount)
txtVideoFileList.ListIndex = selectedIndex
MediaPlayer1.URL = txtVideoFileList.List(selectedIndex)
End Sub

Private Sub btnSequence_Click()
If txtVideoFileList.ListIndex <> -1 Then
If txtVideoFileList.ListIndex < txtVideoFileList.ListCount - 1 Then
txtVideoFileList.ListIndex = txtVideoFileList.ListIndex + 1
Else
txtVideoFileList.ListIndex = 0
End If
MediaPlayer1.URL = txtVideoFileList.List(txtVideoFileList.ListIndex)
End If
End Sub

Private Sub btnLoop_Click()
MediaPlayer1.settings.setMode “loop”, True '循环播放
MediaPlayer1.Controls.play
End Sub

Private Sub btnNext_Click()
If txtVideoFileList.ListIndex < txtVideoFileList.ListCount - 1 Then
txtVideoFileList.ListIndex = txtVideoFileList.ListIndex + 1
End If
MediaPlayer1.URL = txtVideoFileList.List(txtVideoFileList.ListIndex)
End Sub

Private Sub btnPrevious_Click()
If txtVideoFileList.ListIndex > 0 Then
txtVideoFileList.ListIndex = txtVideoFileList.ListIndex - 1
End If
MediaPlayer1.URL = txtVideoFileList.List(txtVideoFileList.ListIndex)
End Sub

Private Function GetIndex(MyArray() As String, MyString As String) As Integer
'查找字符串在字符串数组中的索引值
Dim i As Integer
For i = LBound(MyArray) To UBound(MyArray)
If MyArray(i) = MyString Then
GetIndex = i
Exit Function
End If
Next
End Function

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

EYYLTV

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值