type
TID3Tag = packed record // 128 字节
TAGID: array[0..2] of char; // 3 字节: 必须是TAG
Title: array[0..29] of char; // 30 字节: 歌曲标题
Artist: array[0..29] of char; // 30 字节: 歌曲的艺术家
Album: array[0..29] of char; // 30 字节: 歌曲专辑
Year: array[0..3] of char; // 4 字节: 出版年
Comment: array[0..29] of char; // 30 字节: 评论
Genre: byte; // 1 字节: 种类标识
end;
为读取ID3-Tag信息并在一个对话框中显示,试试这个函数:
procedure TForm1.Button1Click(Sender: TObject);
const
_mp3file='G:/Mp3/Miscellaneous/ATC - Around The World.mp3';
var
id3tag: Tid3tag;
mp3file: Tfilestream;
begin
mp3file:=Tfilestream.create(_mp3file,fmOpenRead);
try
mp3file.position:=mp3file.size-128; // 跳到id3-tag
mp3file.Read(id3tag,SizeOf(id3tag));
showmessage(' Title: '+id3tag.title+#13+
' Artist: '+id3tag.artist+#13+
' Album: '+id3tag.album+#13+
' Year: '+id3tag.year+#13+
' Comment: '+id3tag.comment+#13+
' Genre-ID: '+inttostr(id3tag.genre)
);
finally
mp3file.free;
end;
end;