program project1;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Classes, SysUtils, CustApp
{ you can add units after this };
type
{ TMain }
TMain = class(TCustomApplication)
protected
procedure DoRun; override;
public
procedure ReadID3(SFilename:string);
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
procedure WriteHelp; virtual;
end;
ID3Struct = record
Signature: array[0..2] of Char; { Should be: "TAG" }
Title,
Artist,
Album: array[0..29] of Char;
Year: array[0..3] of Char;
Comment: array[0..29] of Char;
Genre: Byte;
end;
{ TMain }
var
ID3Genre: array[0..126] of string = (
'Blues', 'Classic Rock', 'Country', 'Dance', 'Disco', 'Funk', 'Grunge',
'Hip-Hop', 'Jazz', 'Metal', 'New Age', 'Oldies', 'Other', 'Pop', 'R&B',
'Rap', 'Reggae', 'Rock', 'Techno', 'Industrial', 'Alternative', 'Ska',
'Death Metal', 'Pranks', 'Soundtrack', 'Euro-Techno', 'Ambient',
'Trip-Hop', 'Vocal', 'Jazz+Funk', 'Fusion', 'Trance', 'Classical',
'Instrumental', 'Acid', 'House', 'Game', 'Sound Clip', 'Gospel',
'Noise', 'AlternRock', 'Bass', 'Soul', 'Punk', 'Space', 'Meditative',
'Instrumental Pop', 'Instrumental Rock', 'Ethnic', 'Gothic',
'Darkwave', 'Techno-Industrial', 'Electronic', 'Pop-Folk',
'Eurodance', 'Dream', 'Southern Rock', 'Comedy', 'Cult', 'Gangsta',
'Top 40', 'Christian Rap', 'Pop/Funk', 'Jungle', 'Native American',
'Cabaret', 'New Wave', 'Psychadelic', 'Rave', 'Showtunes', 'Trailer',
'Lo-Fi', 'Tribal', 'Acid Punk', 'Acid Jazz', 'Polka', 'Retro',
'Musical', 'Rock& Roll', 'Hard Rock', 'Folk', 'Folk-Rock',
'National Folk', 'Swing', 'Fast Fusion', 'Bebob', 'Latin', 'Revival',
'Celtic', 'Bluegrass', 'Avantgarde', 'Gothic Rock', 'Progressive Rock',
'Psychedelic Rock', 'Symphonic Rock', 'Slow Rock', 'Big Band',
'Chorus', 'Easy Listening', 'Acoustic', 'Humour', 'Speech', 'Chanson',
'Opera', 'Chamber Music', 'Sonata', 'Symphony', 'Booty Bass', 'Primus',
'Porn Groove', 'Satire', 'Slow Jam', 'Club', 'Tango', 'Samba',
'Folklore', 'Ballad', 'Power Ballad', 'Rhythmic Soul', 'Freestyle',
'Duet', 'Punk Rock', 'Drum Solo', 'Acapella', 'Euro-House', 'Dance Hall', 'Test'
);
procedure TMain.DoRun;
var
ErrorMsg: String;
begin
// quick check parameters
ErrorMsg:=CheckOptions('h', 'help');
if ErrorMsg<>'' then begin
ShowException(Exception.Create(ErrorMsg));
Terminate;
Exit;
end;
// parse parameters
if HasOption('h', 'help') then begin
WriteHelp;
Terminate;
Exit;
end;
{ add your program here }
ReadID3('/media/can/DRIVE_2/sarkilar/mp3/burcu_tatlises/gundelik/01___gundelik.mp3');
// stop program loop
Terminate;
end;
procedure TMain.ReadID3(SFilename:string);
var
FMP3: file of Byte;
MP3Tag: ID3Struct; // line 88
begin
try
(* SFileName - (string) The full file name with path. *)
AssignFile(FMP3, SFileName);
Reset(FMP3);
try
Seek(FMP3, FileSize(FMP3) - 128);
BlockRead(FMP3, MP3Tag, SizeOf(Tag));
finally
end;
finally
CloseFile(FMP3);
end;
if MP3Tag.Signature <> 'TAG' then begin
WriteLn('Doesn''t have a tag')
{ Doesn't have an ID3 tag }
end else begin
{ Do something with the tag }
WriteLn(MP3Tag.Title);
WriteLn(MP3Tag.Artist);
WriteLn(MP3Tag.Album);
WriteLn(MP3Tag.Comment);
end;
end;
constructor TMain.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
StopOnException:=True;
end;
destructor TMain.Destroy;
begin
inherited Destroy;
end;
procedure TMain.WriteHelp;
begin
{ add your help code here }
writeln('Usage: ', ExeName, ' -h');
end;
var
Application: TMain;
begin
Application:=TMain.Create(nil);
Application.Title:='Read Mp3 Tags';
Application.Run;
Application.Free;
end.