Hi guys, well this is my first code snippet for SteinSOFT.net, and my English is not the best, so stay cool ;-).
Let’s begin: At first you have to put the following code in your type, like this:
type TID3Tag = record ID:string[3]; Titel:string[30]; Artist:string[30]; Album:string[30]; Year:string[4]; Comment:string[30]; Genre:byte; end;
It’s nothing complicated, here we only define the types.
var
Form1: TForm1;
ID3Tag:TID3Tag;
No comment.
Now let’s create the function that is going to read the ID3-Tag informations from the mp3 song:
procedure Read_ID3Tag(Filename:string); var Buffer:array[1..128] of char; F:file; begin AssignFile(F, Filename); Reset(F,1); Seek(F,FileSize(F)-128); // going on the // beginning of the ID3-Tag in the file BlockRead(F, Buffer, SizeOf(Buffer)); // Reading the ID3-Tag that’s // cached in the buffer CloseFile(F); With ID3Tag do // now we are going to copy the informations into // variables, there’s no more to explain, I think // everything is clear, if not you can contact me begin ID:=copy(Buffer,1,3); Titel:=copy(Buffer,4,30); Artist:=copy(Buffer,34,30); Album:=copy(Buffer,64,30); Year:=copy(Buffer,94,4); Comment:=copy(Buffer,98,30); Genre:=ord(Buffer[128]); end; end;
Tada now you have all the informations of the ID3-Tag v1, and you can now put them in Labels or Edits, whatever you want. If you have any questions, feel free to ask them in the message board. You can also visit my homepage, www.seck.lu, for some Delphi software written by me.