Registriert seit: 22. Sep 2003
1.123 Beiträge
Delphi 12 Athens
|
Re: MP3-ID3Tag
30. Sep 2003, 11:50
Delphi-Quellcode:
function readID3Tag(FileName: string): TID3Tag;
var
Buffer: array[1..128] of char;
F: File;
mp3hdrread: array[1..4] of byte;
mp3hdr: longint absolute mp3hdrread;
tempbyte, bitrateindex, versionindex: byte;
bitrate, version, layer, groese: longint;
begin
AssignFile(F, Filename);
Reset(F,1);
groese := filesize(f);
blockread(f,mp3hdrread,4);
tempbyte := mp3hdrread[1];
mp3hdrread[1] := mp3hdrread[4];
mp3hdrread[4] := tempbyte;
tempbyte := mp3hdrread[2];
mp3hdrread[2] := mp3hdrread[3];
mp3hdrread[3] := tempbyte;
reset(f,1);
Seek(F,FileSize(F)-128);
BlockRead(F, Buffer, SizeOf(Buffer));
CloseFile(F);
bitrateindex := ((mp3hdr shr 12) and $F);
versionindex := ((mp3hdr shr 19) and $3);
case versionindex of
0: version := 3;
1: version := 0; //unbekannt
2: version := 2;
3: version := 1;
end;
layer := 4 - ((mp3hdr shr 17) and $3);
if version <> 0 then
bitrate := MPEG_BIT_RATES[version][layer][bitrateindex]
else
bitrate := 128;
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]);
sample := sample_rates[version][((mp3hdr shr 10) and $3)];
dauer := (groese * 8) div ((bitrate) * 1000);
bits := bitrate;
vers := version;
layers := layer;
end;
end;
wenn dir das weiterhilft...
nur die dauer geht net richtig
[edit=sakura]Bitte selbständig die Delphi-Tags setzen Mfg, sakura[/edit]
|
|
Zitat
|