龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > 软件开发 > VB开发 >

用MMControl控件播放M3U文件的实现(3)

时间:2009-12-30 15:42来源:未知 作者:admin 点击:
分享到:
Private Sub Timer1_Timer() 进度条的Max和Value值 ProgressBar1.Max = MaxVal ProgressBar1.Value = MMControl1.Position End Sub Private Sub PlayNext() 播放下一首 Timer1.Enabled = False ProgressB

Private Sub Timer1_Timer()
'进度条的Max和Value值
ProgressBar1.Max = MaxVal
ProgressBar1.Value = MMControl1.Position
End Sub

Private Sub PlayNext() '播放下一首
Timer1.Enabled = False
ProgressBar1.Value = 0
MyInd = MyInd + 1 '当然加1了
If MyInd >= List1.ListCount Then MyInd = 0
Call PlayMe '呵呵,偷懒一下吧
List1.ListIndex = MyInd
End Sub

Private Sub OpenM3u() '打开M3U文件并存入内存
On Error GoTo M3uErr
Dim AllLines As New Collection '内存中集全
Dim CurrentLine As Long '当前行集合索引
Dim nextLine As String '从文件中读出的每一行
Dim InFile As Integer '文件的描述符
InFile = FreeFile
Open sF For Input As InFile '打开文件
While Not EOF(InFile)
Line Input #InFile, nextLine
AllLines.Add nextLine
Wend
Close InFile
Dim i As Integer
'以下为提取各行
For i = 0 To AllLines.Count - 1
CurrentLine = CurrentLine + 1
If AllLines.Count < CurrentLine Then
CurrentLine = 1
End If
If AllLines.Count > 0 Then '当然要加入列表框啦
List1.AddItem AllLines.Item(CurrentLine)
End If
Next i
MMControl1.FileName = List1.List(0) '老M终于有文件要处理了
List1.ListIndex = 0
' 列表框第一项高亮――老M就是靠它来判断下一首是什么
Exit Sub
M3uErr:
'......我累了
End Sub

最后想提醒一下:由于MMControl控件直接对MCI发出各种指令,在编程时需要格外谨慎,否则……去尝试一下吧!

精彩图集

赞助商链接