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

anon

New member
Joined
Mar 16, 2011
Messages
2
Programming Experience
Beginner
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.

VB.NET:
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
        trvMain.SelectedNode.Expand()
    Else
        ' 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:

Menthos

Well-known member
Joined
Jul 18, 2006
Messages
276
Programming Experience
10+
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