Hi Guys / Gals - Is there any way to track your AxWindowsMediaPlayer1 when it reaches the end of the Playlist, I am doing a Play / Pause Button but it goes on looping the playlist endlessly, so I was just hoping if I can know it has reached the end of the playlist I can put a stop to it.

Or maybe there is a better way of implementing the Play / Pause Button

Your help will be greatly appreciated.

Thanks
Jim

Here is the code basically I have two populated list boxes and i select to play from which song to which song which makes up my Playlist.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim oMedia As WMPLib.IWMPMedia
Dim mp3fileName As String
Dim d As Integer

 FromSong = Song1.SelectedItem
 ToSong = Song2.SelectedItem

If My.Settings.songpath = "" Then
            MessageBox.Show("Please Select a Audio Folder")
        Else
            For d = FromSong To ToSong

                mp3fileName = mp3fileName + ".mp3"

                folderName = My.Settings.songpath
                oMedia = AxWindowsMediaPlayer1.newMedia(folderName & "\" & mp3fileName)
                oMedia.setItemInfo("Index", AxWindowsMediaPlayer1.currentPlaylist.count)
                AxWindowsMediaPlayer1.currentPlaylist.appendItem(oMedia)

            Next

        End If

        If Button1.Tag = "Play" Then
            Button1.Tag = "Pause"
            AxWindowsMediaPlayer1.Ctlcontrols.play()
            Button1.BackgroundImage = My.Resources.iconPause
        ElseIf Button1.Tag = "Pause" Then
            Button1.Tag = "Play"
            Button1.BackgroundImage = My.Resources.iconPlay
            AxWindowsMediaPlayer1.Ctlcontrols.pause()

        End If

End Sub

Hi, I am working on a project with AxWindowsMediaPlayer as well. Where you use ListBoxes
I use Listviews. In my project if the index of the current song is the same as the items
count in the listview it will stop.

If ListViewTracks.Items.SelectedIndices(0) = ListViewTracks.Items.Count Then
    ButtonStop.PerformClick()
End If
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.