vb 音乐播放器不能自动播放下一首。
DimabAsStringPrivateSubCommand1_Click()DimsongAsStringWithCommonDialog1.FontName="".F...
Dim ab As String
Private Sub Command1_Click()
Dim song As String
With CommonDialog1
.FontName = ""
.Filter = "*.mp3|*.mp3;*.wma|*.wma;*.avi|*.avi"
.ShowOpen
song = .FileName
End With
If song = "" Then Exit Sub
a = ""
For i = Len(song) To 1 Step -1
b = Mid(song, i, 1)
If b = "" Then
List1.AddItem a
a = ""
ElseIf b = "\" Then
List1.AddItem a
ab = Left(song, i)
Exit Sub
Else
a = b & a
End If
Next i
End Sub
Private Sub Command2_Click()
If List1.ListIndex = 0 Then
Label2.Caption = "第一个"
Else
List1.ListIndex = List1.ListIndex - 1
WindowsMediaPlayer1.URL = ab & List1.Text
End If
End Sub
Private Sub Command3_Click()
If List1.ListCount - 1 <> List1.ListIndex Then
List1.ListIndex = List1.ListIndex + 1
WindowsMediaPlayer1.URL = ab & List1.Text
Else
Label2.Caption = "最后一个"
End If
End Sub
Private Sub Command4_Click()
WindowsMediaPlayer1.URL = ab & List1.Text
End Sub
Private Sub Form_Load() '打开程序时自动打开保存的文件名及路径
Dim ss As String
List1.Clear
If Dir(App.Path & "\MusicList.txt") <> "" Then
Open App.Path & "\MusicList.txt" For Input As #1
If Not EOF(1) Then
Line Input #1, ab
Do Until EOF(1)
Line Input #1, ss
List1.AddItem ss
Loop
End If
Close #1
End If
End Sub
Private Sub Form_Unload(Cancel As Integer) '退出程序时保存文件名及路径
Dim i As Long
Open App.Path & "\MusicList.txt" For Output As #1
Print #1, ab
For i = 0 To List1.ListCount - 1
Print #1, List1.List(i)
Next
Close #1
End Sub
Private Sub List1_DblClick()
Form1.Caption = "播放列表" + ab & List1.Text
WindowsMediaPlayer1.URL = ab & List1.Text
End Sub
Public Sub WindowsMediaPlayer1_PlayStateChange(ByVal NewState As Long)
If WindowsMediaPlayer1.playState = wmppsMediaEnded Then
List1.ListIndex = List1.ListIndex + 1
List1_DblClick
End If
End Sub 展开
Private Sub Command1_Click()
Dim song As String
With CommonDialog1
.FontName = ""
.Filter = "*.mp3|*.mp3;*.wma|*.wma;*.avi|*.avi"
.ShowOpen
song = .FileName
End With
If song = "" Then Exit Sub
a = ""
For i = Len(song) To 1 Step -1
b = Mid(song, i, 1)
If b = "" Then
List1.AddItem a
a = ""
ElseIf b = "\" Then
List1.AddItem a
ab = Left(song, i)
Exit Sub
Else
a = b & a
End If
Next i
End Sub
Private Sub Command2_Click()
If List1.ListIndex = 0 Then
Label2.Caption = "第一个"
Else
List1.ListIndex = List1.ListIndex - 1
WindowsMediaPlayer1.URL = ab & List1.Text
End If
End Sub
Private Sub Command3_Click()
If List1.ListCount - 1 <> List1.ListIndex Then
List1.ListIndex = List1.ListIndex + 1
WindowsMediaPlayer1.URL = ab & List1.Text
Else
Label2.Caption = "最后一个"
End If
End Sub
Private Sub Command4_Click()
WindowsMediaPlayer1.URL = ab & List1.Text
End Sub
Private Sub Form_Load() '打开程序时自动打开保存的文件名及路径
Dim ss As String
List1.Clear
If Dir(App.Path & "\MusicList.txt") <> "" Then
Open App.Path & "\MusicList.txt" For Input As #1
If Not EOF(1) Then
Line Input #1, ab
Do Until EOF(1)
Line Input #1, ss
List1.AddItem ss
Loop
End If
Close #1
End If
End Sub
Private Sub Form_Unload(Cancel As Integer) '退出程序时保存文件名及路径
Dim i As Long
Open App.Path & "\MusicList.txt" For Output As #1
Print #1, ab
For i = 0 To List1.ListCount - 1
Print #1, List1.List(i)
Next
Close #1
End Sub
Private Sub List1_DblClick()
Form1.Caption = "播放列表" + ab & List1.Text
WindowsMediaPlayer1.URL = ab & List1.Text
End Sub
Public Sub WindowsMediaPlayer1_PlayStateChange(ByVal NewState As Long)
If WindowsMediaPlayer1.playState = wmppsMediaEnded Then
List1.ListIndex = List1.ListIndex + 1
List1_DblClick
End If
End Sub 展开
2个回答
展开全部
Private Sub MediaPlayer1_EndOfStream(ByVal Result As Long)
If Me.XPRadioButton1.Value = True Then '循环播放
If Me.List1.ListIndex = Me.List1.ListCount - 1 Then
List1.ListIndex = 0
Else
Me.List1.ListIndex = Me.List1.ListIndex + 1
End If
End If
If Me.XPRadioButton2.Value = True Then '只播放一次
If Me.List1.ListIndex = Me.List1.ListCount - 1 Then
Me.MediaPlayer1.Stop
Else
Me.List1.ListIndex = List1.ListIndex + 1
End If
End If
If Me.XPRadioButton1.Value = True Then '循环播放
If Me.List1.ListIndex = Me.List1.ListCount - 1 Then
List1.ListIndex = 0
Else
Me.List1.ListIndex = Me.List1.ListIndex + 1
End If
End If
If Me.XPRadioButton2.Value = True Then '只播放一次
If Me.List1.ListIndex = Me.List1.ListCount - 1 Then
Me.MediaPlayer1.Stop
Else
Me.List1.ListIndex = List1.ListIndex + 1
End If
End If
更多追问追答
追问
我用的是 WindowsMediaPlayer
那个方法不管用
追答
我用的就是WindowsMediaPlayer呀,你只要把要播放的文件添加到LIST1中,选择任一个文件播放完后就可自动播放下一个的,我一直在用的。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询