1
If AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsMediaEnded Then

 ListBox1.SelectedIndex += 1

 AxWindowsMediaPlayer1.URL = ListBox1.SelectedItem

 AxWindowsMediaPlayer1.Ctlcontrols.play()
End If

It changes the index of the listbox, but it doesn't play the next file. The file exist and there's no problem playing it the normal way. Does anybody know what's wrong?

Ňɏssa Pøngjǣrdenlarp
  • 38,411
  • 12
  • 59
  • 178
Jhaezz John
  • 21
  • 1
  • 6

1 Answers1

0

Solution is must to add timer"

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

also the following code work . first add timer to playlist and past following code

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 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
betrice mpalanzi
  • 1,436
  • 12
  • 16
  • 2
    Why would you have to start a timer in a tick event? It's already running, no? – LarsTech Feb 09 '17 at 18:45
  • i create media player things i do i add timer to playlist and eneble = true then i use my code to auto select next song its work. i start timer to make interval when song stopped means song end, timer start and select another index to list box.. sory for bad english – betrice mpalanzi Feb 10 '17 at 00:09