Mp3有个Tag,你可以看看我写过的一段程序
type
TMP3Tag = record
idTAG : array [0..2] of Char;
idSongName :array [0..29] of Char;
idArtist :array [0..29] of Char;
end;
function GetNameFromTag(Mp3File:TFileName):string;
var
Mp3Stream : TFileStream;
ID3 : TMP3Tag;
begin
ZeroMemory(@ID3,SizeOf(ID3));
Mp3Stream := TFileStream.Create(Mp3File,fmOpenRead);
Mp3Stream.Seek(-128, soFromEnd);
Mp3Stream.Read(ID3, SizeOf(ID3));
Mp3Stream.Free;
if ID3.idTAG ='TAG' then
begin
if Trim(ID3.idArtist)='' then
Result := Trim(ID3.idSongName)
else
Result := Trim(ID3.idArtist) + '-' + Trim(ID3.idSongName);
if UpperCase(ExtractFileExt(Result)) <> '.MP3' then
Result := Result + '.mp3';
end
else
Result := Mp3File;
end;