Lire les ID3-Tag d'un MP3

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;

type
TID3Tag = record
ID: string[3];
Titel: string[30];
Artist: string[30];
Album: string[30];
Year: string[4];
Comment: string[30];
Genre: byte;
end;

TForm1 = class(TForm)
Button1: TButton;
OpenDialog1: TOpenDialog;
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;

var
Form1: TForm1;
ID3Tag: TID3Tag;

implementation

{$R *.DFM}

procedure Lese_ID3Tag(Filename: string);
var
Buffer: array[1..128] of char;
F: file;


begin
AssignFile(F, Filename);
Reset(F, 1);
Seek(F, FileSize(F) - 128);
BlockRead(F, Buffer, SizeOf(Buffer));
CloseFile(F);
with ID3Tag do 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;


procedure TForm1.Button1Click(Sender: TObject);
begin
if Opendialog1.Execute then
begin
Lese_ID3Tag(opendialog1.filename);
showmessage(id3tag.ID);
showmessage(id3tag.Titel);
showmessage(id3tag.Artist);
showmessage(id3tag.Album);
showmessage(id3tag.Year);
showmessage(id3tag.Comment);
showmessage(id3tag.Genre);
end;
end;

end.
Ajouter un commentaire
Pseudo
Adresse email
Site internet (optionnel)
Votre commentaire
Fiche de l'article
Mise a jour16/11/2001
VisualisationVu 976 fois
PublicInternaute zz
CategorieDelphi - Trucs et astuces - Fichier
Auteur de l'article
Communauté Delphi Communauté Delphi
connecté le 02/11/2011
0 articles dans la section
Contacter l'auteur