Click here to Skip to main content
11,790,613 members (60,564 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: VB mp3

I'm making an mp3 player using the AxWindowsMediaPlayer but I haven't figured out how to make one song play followed by the next without using wmp.playlist. And when I tried using the playlist I ran into a problem. I have a listbox with the files on the playlist and I want to be able to double click on an item and play it. If I change the player.currentMedia on the listbox1.doubleClick event, the player forgets about the previous playlist and just plays the one file until it finishes. I tried comparing the playlist.item index to the listbox.selectedindex and then move to the next song (or previous) as many times as needed to get to the right song selected on the listbox. I came up with this code but it's not working properly, it just advances to the next item on the playlist whenever i double click any item on the listbox.
If Player.playState = WMPPlayState.wmppsPlaying Then 'And TrackBar1.Value = 1 Then
            For i = 0 To Player.currentPlaylist.count - 1
                If Player.currentMedia.isIdentical(Player.currentPlaylist.Item(i)) Then
                    If i < ListBox1.SelectedIndex Then
                        MsgBox(i.ToString + vbCrLf + ListBox1.SelectedIndex.ToString)
                        While i < ListBox1.SelectedIndex
                            i += 1
                        End While
                    End If
                    If i > ListBox1.SelectedIndex Then
                        While i > ListBox1.SelectedIndex
                            i -= 1
                        End While
                    End If
                    'Label3.Text = "Currently Playing Media Index: " & i.ToString
                    'MsgBox("Currently Playing Media Index: " & i.ToString)
                End If
        End If
If the playlist index is greater than the listbox.selectedindex (I selected a song that's before the one that's playing) it works just fine. It's when I try to select a song that's after the one that's playing that it won't work. Any ideas?
I've been searching the web trying to find examples but I just find simple code that plays one song. Nothing about loop playing or shuffle playing or anything.
If someone has a better idea of how I could do this it would be of great help to me!
Posted 3-Nov-11 15:09pm
Edited 3-Nov-11 21:18pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 1,154
1 Maciej Los 825
2 KrunalRohit 686
3 ppolymorphe 660
4 CPallini 621

Advertise | Privacy | Mobile
Web03 | 2.8.1509028.1 | Last Updated 6 Nov 2011
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100