Efter sigende skulle jeg kunne hente dem med noget ligende...
type
TID3Rec = packed record
Tag : array[0..2] of Char;
Title,
Artist,
Comment,
Album : array[0..29] of Char;
Year : array[0..3] of Char;
Genre : Byte;
end;
procedure TForm1.MP3ListClick(Sender: TObject);
var mp3File:string;
begin
file://if the list is empty don't do anything
if mp3List.Items.Count=0 then exit;
file://file is FolderName + FileName
mp3File := Concat(txtFolder.Caption,
mp3List.Items.Strings
[mp3List.ItemIndex]);
file://Chechk again if it exists
if not FileExists(mp3File) then begin
ShowMessage('MP3 file does not exist?!');
exit;
end;
file://used to display the ID3 tag information
FillID3TagInformation (mp3File,
edtTitle,
edtArtist,
edtAlbum,
edtYear,
edtGenre,
edtComment);
Progress.Max:=0;
mp3player.Close;
mp3player.FileName:=mp3File;
mp3player.Open;
Progress.Max := mp3player.Length;
end;
procedure TForm1.FillID3TagInformation(mp3File: string; Title, Artist,
Album, Year, Genre, Comment: TEdit);
var ID3 : TID3Rec;
fmp3: TFileStream;
begin
fmp3:=TFileStream.Create(mp3File, fmOpenRead);
try
fmp3.position:=fmp3.size-128;
fmp3.Read(ID3,SizeOf(ID3));
finally
fmp3.free;
end;
if ID3.Tag <> 'TAG' then begin
Title.Text:='Wrong or no ID3 tag information';
Artist.Text:='Wrong or no ID3 tag information';
Album.Text:='Wrong or no ID3 tag information';
Year.Text:='Wrong or no ID3 tag information';
Genre.Text:='Wrong or no ID3 tag information';
Comment.Text:='Wrong or no ID3 tag information';
end else begin
Title.Text:=ID3.Title;
Artist.Text:=ID3.Artist;
Album.Text:=ID3.Album;
Year.Text:=ID3.Year;
if ID3.Genre in [0..MaxID3Genre] then
Genre.Text:=ID3Genre[ID3.Genre]
else
Genre.Text:=IntToStr(ID3.Genre);
Comment.Text:=ID3.Comment
end;
end;
Syn's dog ikke rigtig det spiller - holder den vand ?
|