Pa Shadowed je bio u pravu... tebi treba id3 tag... ja sam pre par meseci radio neki mp3 plejer na fakultetu, za neku vežbu, pa se nadam da ti mogu pomoći u ovome... naime, kreiraćeš modul u koji ćeš copy/paste dole navedeni kôd
...................................................................
Code (vb):Attribute VB_Name = "Module2"
Public Type Id3 'This type is standard for
Title As String * 30 ' Id3 Tags
Artist As String * 30 ' Although later versions
Album As String * 30 ' use comments for 28 bytes
sYear As String * 4 ' and they use the 2 remaining bytes for "TrackNumber"!
Comments As String * 30
Genre As Byte
End Type
Public id3Info As Id3 ' Declare a variable as the id3 type
Public GenreArray() As String ' we use this array to fill all the Genre's ( look in form load)
Public Const sGenreMatrix = "Blues|Classic Rock|Country|Dance|Disco|Funk|Grunge|" + _
"Hip-Hop|Jazz|Metal|New Age|Oldies|Other|Pop|R&B|Rap|Reggae|Rock|Techno|" + _
"Industrial|Alternative|Ska|Death Metal|Pranks|Soundtrack|Euro-Techno|" + _
"Ambient|Trip Hop|Vocal|Jazz+Funk|Fusion|Trance|Classical|Instrumental|Acid|" + _
"House|Game|Sound Clip|Gospel|Noise|Alt. Rock|Bass|Soul|Punk|Space|Meditative|" + _
"Instrumental Pop|Instrumental Rock|Ethnic|Gothic|Darkwave|Techno-Industrial|Electronic|" + _
"Pop-Folk|Eurodance|Dream|Southern Rock|Comedy|Cult|Gangsta Rap|Top 40|Christian Rap|" + _
"Pop/Punk|Jungle|Native American|Cabaret|New Wave|Phychedelic|Rave|Showtunes|Trailer|" + _
"Lo-Fi|Tribal|Acid Punk|Acid Jazz|Polka|Retro|Musical|Rock & Roll|Hard Rock|Folk|" + _
"Folk/Rock|National Folk|Swing|Fast-Fusion|Bebob|Latin|Revival|Celtic|Blue Grass|" + _
"Avantegarde|Gothic Rock|Progressive Rock|Psychedelic Rock|Symphonic Rock|Slow Rock|" + _
"Big Band|Chorus|Easy Listening|Acoustic|Humour|Speech|Chanson|Opera|Chamber Music|" + _
"Sonata|Symphony|Booty Bass|Primus|Porn Groove|Satire|Slow Jam|Club|Tango|Samba|Folklore|" + _
"Ballad|power Ballad|Rhythmic Soul|Freestyle|Duet|Punk Rock|Drum Solo|A Capella|Euro-House|" + _
"Dance Hall|Goa|Drum & Bass|Club-House|Hardcore|Terror|indie|Brit Pop|Negerpunk|Polsk Punk|" + _
"Beat|Christian Gangsta Rap|Heavy Metal|Black Metal|Crossover|Comteporary Christian|" + _
"Christian Rock|Merengue|Salsa|Trash Metal|Anime|JPop|Synth Pop"
' Thank you Leigh Bowers
' We can use the split function to fill this into an array
Public Function GetId3(Filename As String)
Dim Tag As String * 3 ' We use this variable to make sure the file has an ID3TAG
Open Filename For Binary As #1 ' we open the file as binary for total control (we need it for the Genre part)
Get #1, FileLen(Filename) - 127, Tag ' Id3 tags are at the end of the mp3 file(and as the type shows it is 128 bytes)
If Tag = "TAG" Then ' "TAG" is put at position filesize-127 to show that this file indeed contains an Id3
Get #1, FileLen(Filename) - 124, id3Info ' if the file has a tag, we put it into our earlier declared variable id3info
Else
MsgBox "This Mp3 Does Not Contain an ID3 Tag", , " Contains no Tag" ' if the "TAG" wasnt at position filesize-127
End If
Close #1 ' close the file
' Now about the Genre
' It works like this, it contains a code in numbers ranging form 1 to 147
' each of these numbers represents a certain Genre like "HipHop" = 7 etc etc.
' the guy who maid the Id3 Tags made a list for the codes and there were originally 80 of them
' then the dudes at winamp extended this so today there are about 150
' this is a pain in the ass to figure out, still there are some info about this on the www.
' Now, a very cool person by the name of Leigh Bowers, has done this. you can search for the code
' on planet source, "MP3Snatch v2.0", but that code has a couple of flaws in the genre part as it uses
' a string*21 instead of a Byte, and on that code you cant write the tag, only read it.
' so i have included Leighs code wich has 147 of the Genre's, very cool.
' if you want the Genre directly, try filling a combobox with the GenreArray and then use combo1.listindex to match the Genre(code) (number)
End Function
Public Function SaveId3(Filename As String, Mp3Info As Id3)
Dim Tag As String * 3 ' We use this variable to make sure the file has an ID3TAG
Open Filename For Binary As #1 ' we open the file as binary for total control (we need it for the Genre part)
Get #1, FileLen(Filename) - 127, Tag ' Id3 tags are at the end of the mp3 file(and as the type shows it is 128 bytes)
If Tag = "TAG" Then ' "TAG" is put at position filesize-127 to show that this file indeed contains an Id3
Put #1, FileLen(Filename) - 124, Mp3Info ' if the file has a tag, we put our new information in the file
Else
Put #1, FileLen(Filename) - 127, "TAG" ' else we put the "TAG" there first,
Close #1
Call SaveId3(Filename, Mp3Info) ' then we call this function again so we fill the info this time
End If
Close #1 ' close the file
' Remember when filling the Mp3info variable
' set the genre part to the number corresponding to the Genre
' it will save it as 1 byte
End Function
........................................................................
i da... zaboravi sam reći... da bi ovaj modul uopšte funkcionisao, trebaće ti i novi form! ja ću ti copy/paste sada full kôd za njegovo kreiranje (čak ćeš dobiti i gotove objekte :D ) <<nadam se>>
.............................................................................
Code (vb):
VERSION 5.00
Begin VB.Form Form3
Caption = "Form3"
ClientHeight = 3135
ClientLeft = 60
ClientTop = 450
ClientWidth = 4350
LinkTopic = "Form3"
ScaleHeight = 3135
ScaleWidth = 4350
StartUpPosition = 3 'Windows Default
Begin VB.ListBox List1
Height = 255
Left = 120
TabIndex = 17
Top = 3240
Width = 3255
End
Begin VB.CommandButton CmdUnload
Caption = "OK"
Height = 375
Left = 3000
TabIndex = 16
Top = 2640
Width = 1095
End
Begin VB.CommandButton Command2
Caption = "Izmeni"
Height = 375
Left = 1560
TabIndex = 15
Top = 2640
Width = 975
End
Begin VB.CommandButton Command1
Caption = "Ucitaj"
Height = 375
Left = 120
TabIndex = 14
Top = 2640
Width = 975
End
Begin VB.Frame Frame1
Caption = "Tag Editor"
Height = 3135
Left = 0
TabIndex = 0
Top = 0
Width = 4335
Begin VB.ComboBox Combo1
Height = 315
Left = 960
TabIndex = 13
Text = "Combo1"
Top = 2160
Width = 2295
End
Begin VB.TextBox Text6
Height = 285
Left = 3360
TabIndex = 12
Text = "Text6"
Top = 2160
Width = 735
End
Begin VB.TextBox Text5
Height = 285
Left = 960
TabIndex = 11
Text = "Text5"
Top = 1800
Width = 3135
End
Begin VB.TextBox Text4
Height = 285
Left = 960
TabIndex = 10
Text = "Text4"
Top = 1440
Width = 3135
End
Begin VB.TextBox Text3
Height = 285
Left = 960
TabIndex = 9
Text = "Text3"
Top = 1080
Width = 3135
End
Begin VB.TextBox Text2
Height = 285
Left = 960
TabIndex = 8
Text = "Text2"
Top = 720
Width = 3135
End
Begin VB.TextBox Text1
Height = 285
Left = 960
TabIndex = 7
Text = "Text1"
Top = 360
Width = 3135
End
Begin VB.Label Label6
Caption = "Zanr"
Height = 255
Left = 120
TabIndex = 6
Top = 2160
Width = 975
End
Begin VB.Label Label5
Caption = "Komentar"
Height = 255
Left = 120
TabIndex = 5
Top = 1800
Width = 855
End
Begin VB.Label Label4
Caption = "Godina"
Height = 255
Left = 120
TabIndex = 4
Top = 1440
Width = 735
End
Begin VB.Label Label3
Caption = "Album"
Height = 255
Left = 120
TabIndex = 3
Top = 1080
Width = 735
End
Begin VB.Label Label2
Caption = "Izvodjac"
Height = 255
Left = 120
TabIndex = 2
Top = 720
Width = 735
End
Begin VB.Label Label1
Caption = "Naziv"
Height = 255
Index = 0
Left = 120
TabIndex = 1
Top = 360
Width = 615
End
End
End
Attribute VB_Name = "Form3"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub CmdUnload_Click()
Unload Me
End Sub
Private Sub Command1_Click()
On Error GoTo hmm
GetId3 List1
Text1 = id3Info.Title
Text2 = id3Info.Artist
Text3 = id3Info.Album
Text4 = id3Info.sYear
Text5 = id3Info.Comments
Combo1.ListIndex = id3Info.Genre
Exit Sub
hmm: If Err.Number = 380 Then MsgBox "Error reading 'Genre' information", , " Error"
End Sub
Private Sub Command2_Click()
id3Info.Title = Text1 'ako zelis izvuci osnovne podatke da ti se scrooluju negde na plejeru
id3Info.Artist = Text2 'onda ih izvlacis iz ovih ovde linija kôd-a
id3Info.Album = Text3
id3Info.sYear = Text4
id3Info.Comments = Text5
id3Info.Genre = Combo1.ListIndex
On Error GoTo well
SaveId3 List1, id3Info
MsgBox "Successfully saved the MP3 tag", , " Success"
Exit Sub
well:
If Err.Number = 75 Then
MsgBox "File is Write Protected", , " Error"
Else
MsgBox Err.Description, , " Error"
End If
End Sub
Private Sub Form_Load()
Left = (Screen.Width - Width) \ 2
Top = (Screen.Height - Height) \ 2
'Load the genre data in combobox
GenreArray = Split(sGenreMatrix, "|")
For i = LBound(GenreArray) To UBound(GenreArray)
Combo1.AddItem GenreArray(i)
Next i
End Sub
..................................................................................................
Nadam se da sam ti pomogao! :D
[Ovu poruku je menjao Shadowed dana 16.01.2010. u 19:14 GMT+1]
Some people, when confronted with a problem, think: "I know, I'll use regular expressions."
Now they have two problems!
-Jamie Zawinsky