Results 1 to 7 of 7

Thread: Music Search & Display

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2006
    Posts
    293

    Music Search & Display

    I need some advice on how to do this.
    the app i want to make to do is search for music on my network drive then display the Artist & song name in listbox etc.

    Basically i want to know how i would go about doing such a search on
    > mp3 files
    > Retrieve file path
    > Retrieve Information about the file (Artist, Song)

    Thanks In Advance

    Alex

  2. #2
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Re: Music Search & Display

    There are functions in System.IO to get a list of files from a directory, namely System.IO.Directory.GetFiles. You can specify to only look for *.mp3. And it returns the fill path for those files.

    You then need to read the data from the MP3 header to get the artist, title, ... There is nothing built into the framework for that, but there are plenty of examples on how to do that:

    http://www.codeproject.com/KB/vb/mp3id3v1.aspx

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2006
    Posts
    293

    Re: Music Search & Display

    Brilliant . I Will Have A Read Up On It

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2006
    Posts
    293

    Re: Music Search & Display

    I got this code

    Code:
    vate Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
            searchPattern = txtSearch.Text
                  For Each FileName As String In My.Computer.FileSystem.GetFiles("M:\Shared\Alexs Music\", searchPattern, FileIO.SearchOption.SearchAllSubDirectories)
                lstArtist.Items.Add(FileName.ToArray)
            Next
        End Sub
    but whatever i search for like "whatever" or "eminem" for instance it errors and says conversion for string to integer , is there a better way of searching for a mp3 file

  5. #5
    Frenzied Member stateofidleness's Avatar
    Join Date
    Jan 2009
    Posts
    1,780

    Re: Music Search & Display

    Well, it looks like you made up your own parameter for the GetFiles method. The first param is the directory path and the second is how to search it. There is no param for "search pattern" so we can start by taking that out.

    A VERY simple approach to this (and HEAVILY dependent on how your mp3's are named) is to search the path of the file to see if it contains the artist's name or song title. Something like:

    vb.net Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         lstArtist.Clear()
    3.  
    4.         Dim searchPattern As String = txtSearch.Text
    5.         For Each FileName As String In My.Computer.FileSystem.GetFiles("E:\Downloads\", FileIO.SearchOption.SearchAllSubDirectories)
    6.             If FileName.Contains(searchPattern) And FileName.Contains(".mp3") Then
    7.                 lstArtist.Items.Add(FileName.ToString)
    8.             End If
    9.         Next
    10.     End Sub

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2006
    Posts
    293

    Re: Music Search & Display

    Thanks you for that code. Im just trying it out now.

    just a question though. I have around 10,000 Mp3's which is around 30-40GB

    If i wanted to put them into a DB, is there a easy way that would be easy to import data from the each file (artist , song name and path) instead on typing each one. and would using a DB be quicker than searching the windows system

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2006
    Posts
    293

    Re: Music Search & Display

    Is it possible to create a program , that will search for every .mp3 file , retrieve the information (artist, song title and file path) and then insert it in a database. i have a class from the link to code that Negative0 Provided.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width