Skip to content
View in the app

A better way to browse. Learn more.

MSFN

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Delphi: ID3 tag over 30 characters is cut off

Featured Replies

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 by BrainDrain

...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.
  • Author

Thank goodness he got banned :P. 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 by BrainDrain

  • 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

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.