BrainDrain Posted January 26, 2007 Share Posted January 26, 2007 (edited) 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, 2007 by BrainDrain Link to comment Share on other sites More sharing options...
LLXX Posted January 26, 2007 Share Posted January 26, 2007 ...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. Link to comment Share on other sites More sharing options...
BrainDrain Posted January 28, 2007 Author Share Posted January 28, 2007 (edited) 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, 2007 by BrainDrain Link to comment Share on other sites More sharing options...
Tarun Posted February 1, 2007 Share Posted February 1, 2007 Would you mind posting your solution? Link to comment Share on other sites More sharing options...
BrainDrain Posted February 2, 2007 Author Share Posted February 2, 2007 ID3 version 2 or 3 is used in the files, I'm still actually figuiring out how to get proper ID3 v2/3 data. Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now