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
Re: Music Search & Display
Brilliant . I Will Have A Read Up On It :D
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
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
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
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.