advancing

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lee123
    Contributor
    • Feb 2007
    • 556

    advancing

    if you have a list box with music in them how do you have it advance to the next one down to the next song when the one is over?

    lee123
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    try to increase the listindex by 1.

    Comment

    • lee123
      Contributor
      • Feb 2007
      • 556

      #3
      well i really don't know if this is right because i tried doing this and it didn't work

      Code:
      Private Sub List1_Click()
          WindowsMediaPlayer1.URL = List1.Text
          List1.ListIndex 1    
      End Sub
      if this isn't right then how is it done, or do i stick this code in somewhere else? because when you try this:

      Code:
      Private Sub List1_Click()
          WindowsMediaPlayer1.URL = List1.Text
          List1.ListIndex + 1    
      End Sub
      it won't except the "+" sign

      lee123

      Comment

      • lee123
        Contributor
        • Feb 2007
        • 556

        #4
        By the way i am using vb6 and a windows media player in my project

        lee123

        Comment

        • QVeen72
          Recognized Expert Top Contributor
          • Oct 2006
          • 1445

          #5
          Hi,

          I guess, you have to write the code in StatusChange() Event of the media player..
          Check for WMP.Status
          If WMP.Status = "Finished" Then


          Regards
          Veena

          Comment

          • lee123
            Contributor
            • Feb 2007
            • 556

            #6
            well i still can't get it to work now i have placed this in the "status change" and entered in this:

            Code:
            Private Sub WindowsMediaPlayer1_StatusChange()
                If WindowsMediaPlayer1.Status = "finished" Then
                    WindowsMediaPlayer1.URL = List1.Text
                    List1.ListIndex = List1.ListIndex + 1
                End If
            End Sub
            but nothing, mayby you can tell me whats wrong or what i can do.

            lee123

            Comment

            • debasisdas
              Recognized Expert Expert
              • Dec 2006
              • 8119

              #7
              try using this

              List1.ListIndex = List1.ListIndex + 1
              WindowsMediaPla yer1.URL = List1.list(list 1.listindex)



              do not forget to check listcount before incrementing the listindex

              Comment

              • lee123
                Contributor
                • Feb 2007
                • 556

                #8
                so do i put this in the WindowsmediaPla yer
                like this:
                Code:
                Private Sub WindowsMediaPlayer1_StatusChange()
                    If WindowsMediaPlayer1.Status = "finished" Then
                        List1.ListCount
                        List1.ListIndex = List1.ListIndex + 1
                        WindowsMediaPlayer1.URL = List1.List(List1.ListIndex)
                    End If
                End Sub
                or in the listbox itself like this:

                Code:
                Private Sub List1_Click()
                     WindowsMediaPlayer1.URL = List1.Text
                    List1.ListCount
                End Sub
                or i don't think i understand what you mean or how the listcount works. i have searched in my books but the closes i have come to it is what i have listed here.

                lee123

                Comment

                • lee123
                  Contributor
                  • Feb 2007
                  • 556

                  #9
                  well i got it to go to the next one down but keep getting this error:

                  Code:
                  runtime error '380'
                  invalid property value
                  but this is what i have done:

                  Code:
                  Private Sub WindowsMediaPlayer1_StatusChange()
                      If WindowsMediaPlayer1.Status = "Finished" Then
                          List1.ListIndex = List1.ListIndex + 1
                          WindowsMediaPlayer1.URL = List1.List(List1.ListIndex)
                          List1.ListIndex = List1.ListCount + 1
                   End If
                  can this be fixed to where i don't have an error? I have tried doing this error handler

                  Code:
                  On Error Resume Next
                  But that didn't work either what else can i do? or is this the way the code is suppose to be like?

                  lee123

                  Comment

                  • QVeen72
                    Recognized Expert Top Contributor
                    • Oct 2006
                    • 1445

                    #10
                    Hi,

                    You need to Check if it is not the Last Index in the List..

                    [code=vb]
                    If List1.ListIndex < (List1.ListCoun t-1) Then
                    List1.ListIndex = List1.ListIndex + 1
                    End If
                    [/code]

                    Regards
                    Veena

                    Comment

                    • lee123
                      Contributor
                      • Feb 2007
                      • 556

                      #11
                      well after doing what you told me it still doesn't work now my code looks like this:

                      Code:
                      Private Sub WindowsMediaPlayer1_StatusChange()
                          If WindowsMediaPlayer1.Status = "Finished" And List1.ListIndex < (List1.ListCount - 1) Then
                              List1.ListIndex = List1.ListIndex + 1
                              WindowsMediaPlayer1.URL = List1.List(List1.ListIndex)
                          End If
                      End Sub
                      is this wrong or do i stick the piece of code you have presented in your last entry in the listbox it self like this

                      Code:
                      Private Sub List1_Click()
                          If List1.ListIndex < (List1.ListCount - 1) Then
                              List1.ListIndex = List1.ListIndex + 1
                          End If
                           WindowsMediaPlayer1.URL = List1.Text
                      End Sub
                      because both ways don't work. it advances to the next one but it don't play. is that because of the way i have this code?

                      lee123

                      Comment

                      • lee123
                        Contributor
                        • Feb 2007
                        • 556

                        #12
                        mayby if i show all the code for this you can help me figure out why this won't play after the first one is done

                        here it is:

                        Code:
                        Private Sub Add_Click()
                            MyPlayList.AddItem Combo1.Text & "" & Text1.Text
                        End Sub
                        Private Sub cmdClear_Click()
                            MyPlayList.Clear  'To clear the Play list
                            Text1.Text = ""
                        End Sub
                        Private Sub cmdNext_Click()
                            MyPlayList.ListIndex = MyPlayList.ListIndex + 1 'This for to scroll down to the next one
                        End Sub
                        Private Sub cmdPrevious_Click()
                            MyPlayList.ListIndex = MyPlayList.ListIndex - 1 'This is to scroll to the previous one up
                        End Sub
                        Private Sub Dir1_Change()
                            File1.Path = Dir1.Path
                        End Sub
                        Private Sub Drive1_Change()
                            Dir1.Path = Drive1.Drive
                        End Sub
                        Private Sub File1_Click()
                            Text1.Text = File1
                        End Sub
                        Private Sub MyPlayList_Click()
                            WindowsMediaPlayer1.URL = MyPlayList.List(MyPlayList.ListIndex)
                        End Sub
                        Private Sub WindowsMediaPlayer1_PlaylistChange(ByVal Playlist As Object, ByVal change As WMPLibCtl.WMPPlaylistChangeEventType)
                            If MyPlayList.ListIndex = (MyPlayList.ListCount - 1) Then
                                WindowsMediaPlayer1_StatusChange
                            End If
                        End Sub
                        Private Sub WindowsMediaPlayer1_StatusChange()
                            On Error Resume Next
                            Dim Answer As Integer
                            If WindowsMediaPlayer1.Status = "Finished" Then
                                Answer = MsgBox("Shall I Continue?", vbQuestion + vbYesNo, "Continue?")
                                If Answer <> vbYes Then End
                                MyPlayList.ListIndex = MyPlayList.ListIndex + 1
                                WindowsMediaPlayer1.URL = MyPlayList.List(MyPlayList.ListIndex)
                            End If
                        End Sub
                        well there is what i have in this project now how can i get it to play the next one down automatically when a song is done that is loaded in the playlist somebody anybody?

                        lee123

                        Comment

                        Working...