unit tagmp3files;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  StdCtrls;

type
  Ttagmp3s = class(TForm)
    cancel: TButton;
    albumtitle: TLabel;
    tracktitle: TLabel;
    albumprogress: TLabel;
    trackprogress: TLabel;
    procedure cancelClick(Sender: TObject);
    procedure FormActivate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  tagmp3s: Ttagmp3s;
  cancelop : boolean;
implementation

uses Main,id3
{$IFNDEF kiosk}
,burn
{$ENDIF}
;

{$R *.DFM}


procedure Ttagmp3s.cancelClick(Sender: TObject);
begin
cancelop:=true;
end;



procedure Ttagmp3s.FormActivate(Sender: TObject);
var
x,y : integer;
t : tid3tag;
begin
cancelop:=false;
for x:=0 to mainform.albumlist.items.count-1 do begin
    mainform.albumlist.itemindex:=x;
    mainform.albumlistChange(nil);
    if cancelop=true then break;
    albumprogress.caption:=mainform.albumlist.items[mainform.albumlist.itemindex];

     extractalbumandaristfrompath(currentalbumpath,t.artist,t.album);
     t.genre:=#0#0;
     t.field:='TAG';
     t.year:='';
     t.comments:='';

    for y:=0 to mainform.tracklist.items.count -1 do begin
     //trackprogress.caption:='track'+format('%.2d',[y])+'.mp3';
     t.track:=mainform.tracklist.items[y];

     trackprogress.caption:=t.track;

     if fileexists(currentalbumpath+'\track'+format('%.2d',[y+1])+'.mp3') then  writetag(currentalbumpath+'\track'+format('%.2d',[y+1])+'.mp3',t);
     application.processmessages;

      if cancelop=true then break;
    end;
end;
    cancel.caption:='Close';
end;


end.