|
-
Sep 5th, 2009, 08:09 PM
#1
Thread Starter
Hyperactive Member
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
-
Sep 5th, 2009, 08:19 PM
#2
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
-
Sep 5th, 2009, 08:43 PM
#3
Thread Starter
Hyperactive Member
Re: Music Search & Display
Brilliant . I Will Have A Read Up On It
-
Sep 6th, 2009, 07:09 AM
#4
Thread Starter
Hyperactive Member
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
-
Sep 6th, 2009, 07:51 AM
#5
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:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
lstArtist.Clear()
Dim searchPattern As String = txtSearch.Text
For Each FileName As String In My.Computer.FileSystem.GetFiles("E:\Downloads\", FileIO.SearchOption.SearchAllSubDirectories)
If FileName.Contains(searchPattern) And FileName.Contains(".mp3") Then
lstArtist.Items.Add(FileName.ToString)
End If
Next
End Sub
Last edited by stateofidleness; Sep 6th, 2009 at 07:59 AM.
-
Sep 6th, 2009, 08:53 AM
#6
Thread Starter
Hyperactive Member
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
-
Sep 7th, 2009, 03:49 PM
#7
Thread Starter
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|