music finder

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sniperelite
    New Member
    • Mar 2008
    • 7

    music finder

    i had to create a program for a programming class final, it breaks dow like this. i have 2 textboxes for user input, a drivelistbox which is linked to a dirlistbox which is also linked to a filelistbox so the user can choose the drive his music is on then find the folder the music is in and if others are like me you have so much music it takes for ever to find the artist or song you are looking for so i made a button that searchs the filelistbox for files that contain the strings input above in the textboxes and puts the results into a listbox on the far right. now the problem i am running into is i have put a media player control on the form so that when the user clicks the song he/she wants to listen to it will play in the media player control, the file in the listbox apparently does not have the path for the file so the media player will not play the selected file if someone could please help me out with the coding to allow the media player to trace the filepath so that the file playes i would be very very greatful.
  • VBWheaties
    New Member
    • Feb 2008
    • 145

    #2
    Originally posted by sniperelite
    i had to create a program for a programming class final, it breaks dow like this. i have 2 textboxes for user input, a drivelistbox which is linked to a dirlistbox which is also linked to a filelistbox so the user can choose the drive his music is on then find the folder the music is in and if others are like me you have so much music it takes for ever to find the artist or song you are looking for so i made a button that searchs the filelistbox for files that contain the strings input above in the textboxes and puts the results into a listbox on the far right. now the problem i am running into is i have put a media player control on the form so that when the user clicks the song he/she wants to listen to it will play in the media player control, the file in the listbox apparently does not have the path for the file so the media player will not play the selected file if someone could please help me out with the coding to allow the media player to trace the filepath so that the file playes i would be very very greatful.
    You want to combine the FileListBox text with the FileListBox.Pat h property to get the full path to the file:

    Code:
       Dim sPath As String 
       sPath = FileListBox1.Path & "\" & FileListBox1

    Comment

    • sniperelite
      New Member
      • Mar 2008
      • 7

      #3
      Originally posted by VBWheaties
      You want to combine the FileListBox text with the FileListBox.Pat h property to get the full path to the file:

      Code:
         Dim sPath As String 
         sPath = FileListBox1.Path & "\" & FileListBox1
      you are a life saver i have searched and search and came up empty. agian thank you for your help and wisdome....

      Comment

      • sniperelite
        New Member
        • Mar 2008
        • 7

        #4
        now there is only one other thing i need to do with it and that is to make it go to the next song in the list. any ideas on how to do that???

        Comment

        • VBWheaties
          New Member
          • Feb 2008
          • 145

          #5
          Originally posted by sniperelite
          now there is only one other thing i need to do with it and that is to make it go to the next song in the list. any ideas on how to do that???
          Check out the EndOfStream event which might fire when the song completes.
          Not being sure, I just looked at the controls events so experiment with the MANY events this control has.

          To see the events, simply double-click the media player control in the designer and click the drop down at the top-right. You'll have to take it from there. Hope that helps.

          Comment

          • sniperelite
            New Member
            • Mar 2008
            • 7

            #6
            i have tryed several different declaration for the media player and still nothing atm the listbox and media player private subs looks like this...


            Private Sub lbResults_Selec tedIndexChanged (ByVal sender As System.Object, ByVal e As System.EventArg s) Handles lbResults.Selec tedIndexChanged
            Dim path As String = Me.FileListBox1 .Path & "\" & Me.lbResults.Se lectedItem

            AxWindowsMediaP layer1.URL = path
            AxWindowsMediaP layer1.Ctlcontr ols.play()

            End Sub

            Private Sub AxWindowsMediaP layer1_PlayStat eChange(ByVal sender As Object, ByVal e As AxWMPLib._WMPOC XEvents_PlaySta teChangeEvent) Handles AxWindowsMediaP layer1.PlayStat eChange
            If AxWindowsMediaP layer1.playStat e = WMPLib.WMPPlayS tate.wmppsMedia Ended Then
            If Me.lbResults.Se lectedIndex < Me.lbResults.It ems.Count - 1 Then
            Me.lbResults.Se lectedIndex = Me.lbResults.Se lectedIndex + 1
            Else
            Me.lbResults.Se lectedIndex = 0
            End If
            End If
            End Sub

            after this runs through it goes to the next song in the listbox and says opening media but nothing happens...

            Comment

            • VBWheaties
              New Member
              • Feb 2008
              • 145

              #7
              Originally posted by sniperelite
              i have tryed several different declaration for the media player and still nothing atm the listbox and media player private subs looks like this...


              Private Sub lbResults_Selec tedIndexChanged (ByVal sender As System.Object, ByVal e As System.EventArg s) Handles lbResults.Selec tedIndexChanged
              Dim path As String = Me.FileListBox1 .Path & "\" & Me.lbResults.Se lectedItem

              AxWindowsMediaP layer1.URL = path
              AxWindowsMediaP layer1.Ctlcontr ols.play()

              End Sub

              Private Sub AxWindowsMediaP layer1_PlayStat eChange(ByVal sender As Object, ByVal e As AxWMPLib._WMPOC XEvents_PlaySta teChangeEvent) Handles AxWindowsMediaP layer1.PlayStat eChange
              If AxWindowsMediaP layer1.playStat e = WMPLib.WMPPlayS tate.wmppsMedia Ended Then
              If Me.lbResults.Se lectedIndex < Me.lbResults.It ems.Count - 1 Then
              Me.lbResults.Se lectedIndex = Me.lbResults.Se lectedIndex + 1
              Else
              Me.lbResults.Se lectedIndex = 0
              End If
              End If
              End Sub

              after this runs through it goes to the next song in the listbox and says opening media but nothing happens...
              Try this piece of code before setting the URL and before Controls.Play

              Code:
                 AxMediaPlayer1.AutoStart = False
              Another thing: try programming your completion check in EndOfStream event because the PlayStateChange event is called several times and I think you'll find bottlenecks since there are several change events fired (you can see this by putting Debug.Print "PlayStateChang e event fired!" in the event).

              Comment

              • sniperelite
                New Member
                • Mar 2008
                • 7

                #8
                with the controle i use "AxWindowsMedia Player1" the autostart option is not available.

                Comment

                • VBWheaties
                  New Member
                  • Feb 2008
                  • 145

                  #9
                  Originally posted by sniperelite
                  with the controle i use "AxWindowsMedia Player1" the autostart option is not available.
                  Strange. What I would do is download the Windows Media Player SDK. With it you get documentation and probably some samples to work with.

                  Comment

                  • sniperelite
                    New Member
                    • Mar 2008
                    • 7

                    #10
                    ok i went and downloaded and installed windows media player 11 sdk and took a look at the information it provided and am now more confused than befor lol if you could give me some guidence on where to look withing the information that would be a great help. again i would like to thank you for all your help.

                    Comment

                    • VBWheaties
                      New Member
                      • Feb 2008
                      • 145

                      #11
                      Originally posted by sniperelite
                      ok i went and downloaded and installed windows media player 11 sdk and took a look at the information it provided and am now more confused than befor lol if you could give me some guidence on where to look withing the information that would be a great help. again i would like to thank you for all your help.
                      Here is some documentation for interacting with the WMP control in Visual Studio:


                      Then, here is the google results with developers that have developed similarly:

                      Comment

                      • sniperelite
                        New Member
                        • Mar 2008
                        • 7

                        #12
                        i thank you for your extensive help, i have looked over all the provided links and for some reasion i still cant figure out how to get it to load the next song in the listbox. it selects it and says loading media but never plays it, i tryed a do while loop but that didnt work any other ideas???

                        Comment

                        Working...