Question Looping audio files in tree view with windows media player COM


New member
Mar 16, 2011
Programming Experience
I am attempting to play a set of audio files continuously using a tree view. I am having troubles looping through an array to play one song after another in the selected parent node. It seems to work if I only use one song in the array but it doesn't want to actually loop through and keep playing; it goes through the loop but once the first song is over it stops. I am unsure if looping through an array in the AfterSelect sub routine is the best
way of doing this, any other suggestions are greatly appreciated.

Here is the entire Sub routine for the AfterSelect on the tree view.
trvMain is the name of the entire tree view.
wmpMain is the Windows Media Player COM.
trvJazzHancock is the parent node for the two audio files I'm attempting to loop.

Private Sub trvMain_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles trvMain.AfterSelect
      ' When parent node is selected, the node expands to display child nodes.
    If trvMain.SelectedNode.Name.ToLower.StartsWith("trv") Then
        ' Sets URL to the path of the audio files.
        wmpMain.URL = IO.Path.GetFullPath("..\..\music\" & trvMain.SelectedNode.Name.ToString)

        Exit Sub
    End If
     ' Case containing a loop to play Maiden Voyage followed by Dolphin Dance.
 Select Case trvMain.SelectedNode.Name
        Case "trvJazzHancock"
            ' loop method begins and plays song (0) and then song (1)
            Dim arMusic(2) As String
            arMusic(0) = IO.Path.GetFullPath("..\..\music\MaidenVoyage.wma")
            arMusic(1) = IO.Path.GetFullPath("..\..\music\05 Dolphin Dance.wma")
            For i = 0 To arMusic.Count - 1
                wmpMain.URL = arMusic(0)
            Next i

    End Select
End Sub
Last edited:


Well-known member
Jul 18, 2006
Programming Experience
You took the time to "bump" a question after only 30 minutes, yet didn't take the time to format the code you posted originally????
Top Bottom