If AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsMediaEnded Then
ListBox1.SelectedIndex += 1
AxWindowsMediaPlayer1.URL = ListBox1.SelectedItem
AxWindowsMediaPlayer1.Ctlcontrols.play()
End If
它会更改列表框的索引,但不会播放下一个文件。 该文件存在,以正常方式播放没有问题。 有人知道什么是错的吗?
答案 0 :(得分:0)
解决方案必须添加计时器“
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As EventArgs) Handles Timer1.Tick
Dim item As Integer
item = ListBox1.SelectedIndex
If Form1.AxWindowsMediaPlayer1.playState = WMPPlayState.wmppsStopped Then
Me.ListBox1.SelectedIndex = item + 1
Form1.AxWindowsMediaPlayer1.URL = FileUrls(ListBox1.SelectedIndex)
Timer1.Start()
Else
Timer1.Start()
End If
end sub
还有以下代码工作。首先将计时器添加到播放列表和过去的代码
Private Sub Timer1_Tick(ByVal sender As System.Object,ByVal e As System.EventArgs)处理Timer1.Tick
If Form1.AxWindowsMediaPlayer1.playState = WMPPlayState.wmppsStopped Then
If ListBox1.SelectedIndex < ListBox1.Items.Count - 1 Then
ListBox1.SelectedIndex = ListBox1.SelectedIndex + 1
form1.axwindowmediaplayer1.url=listbox1.selectedindex
Else
'do nothing if no item to play
End If
End If
End Sub