Analitcs

Pesquisar no conteúdo do blog.atlabs.com.br

quarta-feira, 23 de julho de 2014

DELPHI - TAG ID3 - Informações do Mp3 - Get Mp3Information

Reações: 


type
 TID3Rec = record
  Tag     : array[0..2] of Char;
  Title,
  Artist,
  Comment,
  Album   : array[0..29] of Char;
  Year    : array[0..3] of Char;
  Genre   : Byte;
  private
   class procedure FillID3TagInformation(mp3File, Title, Artist, Album, Year,
      Genre, Comment: String); static;
end;
class procedure TID3Rec.FillID3TagInformation(mp3File, Title, Artist, Album,
  Year, Genre, Comment: String);
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   := '';
    Artist  := '';
    Album   := '';
    Year    := '';
    Genre   := '';
    Comment := '';
 end
 else
 begin
   Title    := ID3.Title;
   Artist   := ID3.Artist;
   Album    := ID3.Album;
   Year     := ID3.Year;
   Comment  := ID3.Comment;
 end;
end;
function FillID3TagInformation_Artist(mp3File: String): String;
var
    ID3 : TID3Rec;
    fmp3: TFileStream;
    AStorageRegistryData : Array of Byte;
    S : String;
    I, J, Start, Finish : Integer;
begin
  fmp3:=TFileStream.Create(mp3File, fmOpenRead);
  FillChar(ID3, SizeOf(ID3), #0);
  Setlength(AStorageRegistryData, SizeOf(ID3));
  try
    fmp3.position := fmp3.size - 128;
    fmp3.ReadBuffer(AStorageRegistryData[0], 128);
{    fmp3.position := fmp3.size - 128;
    fmp3.Read(ID3, SizeOf(ID3));}
  finally
    fmp3.free;
  end;
  for I := 0 to Length(ID3.Tag) -1 do
    ID3.Tag[I] := Chr(Byte(AStorageRegistryData[i]));
  J := 0;
  Start  := Length(ID3.Tag);
  Finish := Length(ID3.Tag) + Length(ID3.Title);
  for I := Start to Finish -1 do
  begin
    ID3.Title[J] := Chr(Byte(AStorageRegistryData[i]));
    Inc(J);
  end;
  J := 0;
  Start  := Length(ID3.Tag) + Length(ID3.Title);
  Finish := Length(ID3.Tag) + Length(ID3.Title) + Length(ID3.Artist);
  for I := Start to Finish -1 do
  begin
    ID3.Artist[J] := Chr(Byte(AStorageRegistryData[i]));
    Inc(J);
  end;
  if ID3.Tag <> 'TAG' then
    Result := ''
 else
   Result  := ID3.Artist;
end;

Nenhum comentário:

Postar um comentário

Observação: somente um membro deste blog pode postar um comentário.

Max Gehringer