Discussion:
Extended file information
(too old to reply)
Don Loukes
2003-11-13 22:56:14 UTC
Permalink
I am writing a juke box program using VB5 on a Windows XP Pro operating
system. Using VB I can retrieve file names from the hard drive but I need
to be able to read the extended file information to get Artist, Album,
Title, etc.

There must be a way of doing it using the windows API, but how?

If anyone can answer this, please include sufficient VB code as I am not
very good at using Declare statements.

Thanks
Don.
Slaatje
2003-11-14 08:49:27 UTC
Permalink
Don Loukes heeft geschreven in bericht ...
Post by Don Loukes
I am writing a juke box program using VB5 on a Windows XP Pro operating
system. Using VB I can retrieve file names from the hard drive but I need
to be able to read the extended file information to get Artist, Album,
Title, etc.
There must be a way of doing it using the windows API, but how?
If anyone can answer this, please include sufficient VB code as I am not
very good at using Declare statements.
Thanks
Don.
This reads the Mp3 tag:

Private Type ID3Data

Tag As String * 3
Title As String * 30
Artist As String * 30
Album As String * 30
Year As String * 4
Notes As String * 30
Genre As String * 1

End Type





Private Function ExtractID3(MP3path As String) As ID3Data

Open MP3path For Binary As #1

Get #1, LOF(1) - 127, ExtractID3

Close #1


End Function

Private Sub Command1_Click()
d
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()
Dim FP As String

FP = File1.Path
If Right(FP, 1) <> "\" Then FP = FP & "\"
FP = FP & File1.FileName


If ExtractID3(FP).Tag = "TAG" Then
Label1 = ExtractID3(FP).Title
Label2 = ExtractID3(FP).Artist
Label3 = ExtractID3(FP).Album
Label4 = ExtractID3(FP).Year
Label5 = GetGenre(Asc(ExtractID3(FP).Genre))
Label6 = ExtractID3(FP).Notes
Frame1.Caption = "TAG available"
Else
Frame1.Caption = "TAG not available"
Label1 = ""
Label2 = ""
Label3 = ""
Label4 = ""
Label5 = ""
Label6 = ""
End If
End Sub

Private Function GetGenre(G As Integer) As String

GetGenre = "unknown"
Select Case G
Case 0
GetGenre = "Blues"
Case 1
GetGenre = "Classic Rock"
Case 2
GetGenre = "Country"
Case 3
GetGenre = "Dance"
Case 4
GetGenre = "Disco"
Case 5
GetGenre = "Funk"
Case 6
GetGenre = "Grunge"
Case 7
GetGenre = "Hip-Hop"
Case 8
GetGenre = "Jazz"
Case 9
GetGenre = "Metal"
Case 10
GetGenre = "New Age"
Case 11
GetGenre = "Oldies"
Case 12
GetGenre = "Other"
Case 13
GetGenre = "Pop"
Case 14
GetGenre = "R&B"
Case 15
GetGenre = "Rap"
Case 16
GetGenre = "Reggae"
Case 17
GetGenre = "Rock"
Case 18
GetGenre = "Techno"
Case 19
GetGenre = "Industrial"
Case 20
GetGenre = "Alternative"
Case 21
GetGenre = "Ska"
Case 22
GetGenre = "Death Metal"
Case 23
GetGenre = "Pranks"
Case 24
GetGenre = "Soundtrack"
Case 25
GetGenre = "Euro-Techno"
Case 26
GetGenre = "Ambient"
Case 27
GetGenre = "Trip-Hop"
Case 28
GetGenre = "Vocal"
Case 29
GetGenre = "Jazz+Funk"
Case 30
GetGenre = "Fusion"
Case 31
GetGenre = "Trance"
Case 32
GetGenre = "Classical"
Case 33
GetGenre = "Instrumental"
Case 34
GetGenre = "Acid"
Case 35
GetGenre = "House"
Case 36
GetGenre = "Game"
Case 37
GetGenre = "Sound Clip"
Case 38
GetGenre = "Gospel"
Case 39
GetGenre = "Noise"
Case 40
GetGenre = "AlternRock"
Case 41
GetGenre = "Bass"
Case 42
GetGenre = "Soul"
Case 43
GetGenre = "Punk"
Case 44
GetGenre = "Space"
Case 45
GetGenre = "Meditative"
Case 46
GetGenre = "Instrumental Pop"
Case 47
GetGenre = "Instrumental Rock"
Case 48
GetGenre = "Ethnic"
Case 49
GetGenre = "Gothic"
Case 50
GetGenre = "Darkwave"
Case 51
GetGenre = "Techno-Industrial"
Case 52
GetGenre = "Electronic"
Case 53
GetGenre = "Pop-Folk"
Case 54
GetGenre = "Eurodance"
Case 55
GetGenre = "Dream"
Case 56
GetGenre = "Southern Rock"
Case 57
GetGenre = "Comedy"
Case 58
GetGenre = "Cult"
Case 59
GetGenre = "Gangsta"
Case 60
GetGenre = "Top 40"
Case 61
GetGenre = "Christian Rap"
Case 62
GetGenre = "Pop/Funk"
Case 63
GetGenre = "Jungle"
Case 64
GetGenre = "Native American"
Case 65
GetGenre = "Cabaret"
Case 66
GetGenre = "New Wave"
Case 67
GetGenre = "Psychadelic"
Case 68
GetGenre = "Rave"
Case 69
GetGenre = "Showtunes"
Case 70
GetGenre = "Trailer"
Case 71
GetGenre = "Lo-Fi"
Case 72
GetGenre = "Tribal"
Case 73
GetGenre = "Acid Punk"
Case 74
GetGenre = "Acid Jazz"
Case 75
GetGenre = "Polka"
Case 76
GetGenre = "Retro"
Case 77
GetGenre = "Musical"
Case 78
GetGenre = "Rock & Roll"
Case 79
GetGenre = "Hard Rock"

End Select
End Function


Private Function d()
Dim s As String
Open "C:\Documents and Settings\MEHDI\My Documents\mp3genre.txt" For Binary
As 1
For n = 0 To 79
Line Input #1, l
s = s & "case " & n & vbCrLf & "getgenre = "
i = InStr(1, l, "'")
j = InStr(i + 1, l, "'")
s = s & Chr(34) & Mid(l, i + 1, j - i - 1) & Chr(34) & vbCrLf
Next
Close 1

Open "sc.txt" For Binary As 1
Put 1, , s
Close 1


End Function

Continue reading on narkive:
Loading...