January 26, 200719 yr This code:type TID3Tag = record ID: string[3]; Titel: string[30]; Artist: string[30]; end;var Form1: TForm1;implementation{$R *.dfm}function readID3Tag(FileName: string): TID3Tag;var FS: TFileStream; Buffer: array [1..128] of Char;begin FS := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite); try FS.Seek(-128, soFromEnd); FS.Read(Buffer, 128); with Result do begin ID := Copy(Buffer, 1, 3); Titel := Copy(Buffer, 4, 30); Artist := Copy(Buffer, 34, 30); end; finally FS.Free; end;end;procedure TfrmMain.Button1Click(Sender: TObject);begin if OpenDialog1.Execute then begin with readID3Tag(OpenDialog1.FileName) do begin LlbID.Caption := 'ID: ' + ID; LlbTitel.Caption := 'Titel: ' + Titel; LlbArtist.Caption := 'Artist: ' + Artist; end; end;end;From here extracts the song and artist tags correctly, however if either is over 30 characters the rest of the artist or song tag is chopped off... An example I'm looking at now is "Glamorous Indie Rock & Roll [2004]" as a ID3 song tag. It comes out as "Glamorous Indie Rock _Roll [2". Does anyone know how I could make this work correctly? Edited January 26, 200719 yr by BrainDrain
January 26, 200719 yr ...with a little use of the Brain?Titel: string[30]; Artist: string[30]; end;var Form1: TForm1;implementation{$R *.dfm}function readID3Tag(FileName: string): TID3Tag;var FS: TFileStream; Buffer: array [1..128] of Char;begin FS := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite); try FS.Seek(-128, soFromEnd); FS.Read(Buffer, 128); with Result do begin ID := Copy(Buffer, 1, 3); Titel := Copy(Buffer, 4, 30); Artist := Copy(Buffer, 34, 30);...and I don't even know much about Delphi.
January 28, 200719 yr Author Thank goodness he got banned . I got a reply via PM from someone here that helped a lot.EDIT: The ID3 version 1 tags are up against each other... e.g. [artistdata...................songdata...................]Using his method, setting the number of chars to recieve to 35 for the artist name would give [artistdata.................songd]His method is one of the first I tried. Edited January 28, 200719 yr by BrainDrain
February 2, 200719 yr Author ID3 version 2 or 3 is used in the files, I'm still actually figuiring out how to get proper ID3 v2/3 data.
Create an account or sign in to comment