rendered paste bodyunit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, MPlayer, ExtCtrls, StdCtrls,Shellapi;
type
TTrackInfo = class
public
id : integer;
path : string;
name : string;
artist : string;
title : string;
video : string;
mp3 : string;
cover : string;
bg : string;
cat : string;
end;
type
TForm2 = class(TForm)
LabeledEdit1: TLabeledEdit;
LabeledEdit2: TLabeledEdit;
LabeledEdit3: TLabeledEdit;
LabeledEdit4: TLabeledEdit;
LabeledEdit5: TLabeledEdit;
LabeledEdit6: TLabeledEdit;
LabeledEdit7: TLabeledEdit;
Image1: TImage;
Image2: TImage;
Bevel1: TBevel;
Bevel2: TBevel;
Label1: TLabel;
Label2: TLabel;
Panel1: TPanel;
MediaPlayer1: TMediaPlayer;
Label3: TLabel;
MediaPlayer2: TMediaPlayer;
OpenDialog1: TOpenDialog;
Button1: TButton;
Button2: TButton;
memo1: TMemo;
Button3: TButton;
Button4: TButton;
Button5: TButton;
ComboBox1: TComboBox;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormShow(Sender: TObject);
procedure MediaPlayer1Click(Sender: TObject; Button: TMPBtnType;
var DoDefault: Boolean);
procedure MediaPlayer2Click(Sender: TObject; Button: TMPBtnType;
var DoDefault: Boolean);
procedure LabeledEdit5DblClick(Sender: TObject);
procedure LabeledEdit6DblClick(Sender: TObject);
procedure LabeledEdit4DblClick(Sender: TObject);
procedure LabeledEdit3DblClick(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
private
public
Trackinfo : TTrackInfo;
constructor Create(ATrackinfo: TTrackInfo); reintroduce;
end;
var
pathdummy :array [0..3]of string;
a : Tstringlist;
f : textfile;
dummy : string;
implementation
uses Unit1;
{$R *.dfm}
function DoFileWork(aOperation: FILEOP_FLAGS; aFrom, aTo: AnsiString;
Flags: FILEOP_FLAGS): Integer;
var
FromPath, ToPath: AnsiString;
SHFileOpStruct: TSHFileOpStruct;
begin
FromPath := aFrom + #0#0;
ToPath := aTo + #0#0;
with SHFileOpStruct do
begin
Wnd := 0;
wFunc := aOperation;
pFrom := PAnsiChar(FromPath);
if ToPath <> '' then
begin
pTo := PAnsiChar(ToPath)
end else begin // target available
pTo := nil;
end; // target not available
fFlags := Flags;
end; // structure
Result := SHFileOperationA(SHFileOpStruct);
end;
function MoveDir(const fromDir, toDir: string): Boolean;
var
fos: TSHFileOpStruct;
begin
ZeroMemory(@fos, SizeOf(fos));
with fos do
begin
wFunc := FO_MOVE;
fFlags := FOF_FILESONLY;
pFrom := PChar(fromDir + #0);
pTo := PChar(toDir)
end;
Result := (0 = ShFileOperation(fos));
end;
function CopyDir(const fromDir, toDir: string): Boolean;
var
fos: TSHFileOpStruct;
begin
ZeroMemory(@fos, SizeOf(fos));
with fos do
begin
wFunc := FO_COPY;
fFlags := FOF_FILESONLY;
pFrom := PChar(fromDir + #0);
pTo := PChar(toDir)
end;
Result := (0 = ShFileOperation(fos));
end;
function geccomod(art, filename:string):string;
var
dummy:string;
begin
dummy := copy(filename,length(filename)-2,3);
insert(' '+ art,filename,pos('.'+dummy,filename));
result := filename;
end;
procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
mediaplayer1.close;
mediaplayer2.Close;
end;
procedure TForm2.FormShow(Sender: TObject);
begin
combobox1.Items.LoadFromFile(form1.edit1.text+'\catconfig.txt');
combobox1.ItemIndex := combobox1.Items.IndexOf(trackinfo.cat);
trackinfo.cat := combobox1.Items.Strings[combobox1.itemindex];
image1.Picture.LoadFromFile(ExtractFilePath(Application.ExeName)+'nopic.jpg');
image2.Picture.LoadFromFile(ExtractFilePath(Application.ExeName)+'nopic.jpg');
labelededit1.Text := Trackinfo.artist;
labelededit2.Text := Trackinfo.title;
labelededit3.Text := Trackinfo.mp3;
labelededit4.Text := Trackinfo.video;
labelededit5.Text := Trackinfo.cover;
labelededit6.Text := Trackinfo.bg;
labelededit7.Text := Trackinfo.path + Trackinfo.name;
opendialog1.InitialDir := Trackinfo.path;
try
if fileexists(lowercase(Trackinfo.path+Trackinfo.cover)) then image1.Picture.LoadFromFile(lowercase(Trackinfo.path+Trackinfo.cover));
except
showmessage('Error loading Cover');
end;
try
if fileexists(lowercase(Trackinfo.path+Trackinfo.bg)) then image2.Picture.LoadFromFile(lowercase(Trackinfo.path+Trackinfo.bg));
except
showmessage('Error loading Background');
end;
try
if fileexists(lowercase(Trackinfo.path+Trackinfo.video)) then
begin
if mediaplayer1.Mode = mpopen then mediaplayer1.Close;
mediaplayer1.FileName := Trackinfo.path+Trackinfo.video;
mediaplayer1.Open;
mediaplayer1.DisplayRect := panel1.ClientRect;
end;
except
showmessage('Error loading Video');
end;
try
if fileexists(lowercase(Trackinfo.path+Trackinfo.mp3)) then
begin
if mediaplayer2.Mode = mpopen then mediaplayer2.Close;
mediaplayer2.FileName := Trackinfo.path+Trackinfo.mp3;
mediaplayer2.Open;
end;
except
showmessage('Error loading MP3!');
end;
end;
procedure TForm2.MediaPlayer1Click(Sender: TObject; Button: TMPBtnType;
var DoDefault: Boolean);
begin
if button = btplay then
mediaplayer1.Play;
if button = btstop then
begin
MediaPlayer1.Frames := 1;
mediaplayer1.Stop;
mediaplayer1.StartPos := 1;
end;
end;
procedure TForm2.MediaPlayer2Click(Sender: TObject; Button: TMPBtnType;
var DoDefault: Boolean);
begin
if button = btplay then
mediaplayer2.Play;
if button = btstop then
begin
MediaPlayer2.Frames := 0;
mediaplayer2.Stop;
mediaplayer2.StartPos := 0;
end;
end;
procedure TForm2.LabeledEdit5DblClick(Sender: TObject);
begin
opendialog1.FilterIndex := 1;
if opendialog1.Execute then
begin
image1.Picture.LoadFromFile(opendialog1.Filename);
labelededit5.Text := extractfilename(opendialog1.Filename);
pathdummy[0] := extractfilepath(opendialog1.filename);
end;
end;
procedure TForm2.LabeledEdit6DblClick(Sender: TObject);
begin
opendialog1.FilterIndex := 1;
if opendialog1.Execute then
begin
image2.Picture.LoadFromFile(opendialog1.Filename);
labelededit6.Text := extractfilename(opendialog1.Filename);
pathdummy[1] := extractfilepath(opendialog1.filename);
end;
end;
procedure TForm2.LabeledEdit4DblClick(Sender: TObject);
begin
opendialog1.FilterIndex := 2;
if opendialog1.Execute then
begin
if mediaplayer1.Mode = mpopen then mediaplayer1.Close;
mediaplayer1.FileName := opendialog1.FileName;
mediaplayer1.Open;
mediaplayer1.DisplayRect := Panel1.ClientRect;
labelededit4.Text := extractfilename(opendialog1.Filename);
pathdummy[2] := extractfilepath(opendialog1.filename);
end;
end;
procedure TForm2.LabeledEdit3DblClick(Sender: TObject);
begin
opendialog1.FilterIndex := 3;
if opendialog1.Execute then
begin
if mediaplayer2.Mode = mpopen then mediaplayer2.Close;
mediaplayer2.FileName := opendialog1.FileName;
mediaplayer2.Open;
labelededit3.Text := extractfilename(opendialog1.Filename);
pathdummy[3] := extractfilepath(opendialog1.filename);
end;
end;
procedure TForm2.Button1Click(Sender: TObject);
var
i,j,k,l : integer;
dum : array[0..3] of string;
du : string;
begin
if application.messagebox('Realy Change Details ?','UltraSongTool', MB_YESNO) = IDYES then
begin
a := Tstringlist.create;
assignfile(f,Trackinfo.path+Trackinfo.name);
reset(f);
repeat
readln(f,dummy);
a.Add(dummy);
until EOF(f);
closefile(f);
if Trackinfo.artist <> Labelededit1.Text then
begin
if a.IndexOf('#ARTIST:'+Trackinfo.artist) > -1 then
begin
//showmessage (inttostr( a.IndexOf('#ARTIST:'+artist)));
j := a.IndexOf('#ARTIST:'+Trackinfo.artist);
a.Delete(j);
a.Insert(j,'#ARTIST:'+labelededit1.text);
Trackinfo.artist := LabeledEdit1.Text;
end
else
begin
end;
end;
if Trackinfo.title <> labelededit2.Text then
begin
if a.IndexOf('#TITLE:'+Trackinfo.title) > -1 then
begin
//showmessage ( inttostr( a.IndexOf('#TITLE:'+title)));
j := a.IndexOf('#TITLE:'+Trackinfo.title);
a.Delete(j);
a.Insert(j,'#TITLE:'+labelededit2.Text);
Trackinfo.title := LabeledEdit2.Text;
end
else
begin
end;
end;
if Trackinfo.mp3 <> labelededit3.Text then
begin
if a.IndexOf('#MP3:'+Trackinfo.mp3) > -1 then
begin
j := a.IndexOf('#MP3:'+Trackinfo.mp3);
a.Delete(j);
a.Insert(j,'#MP3:'+ labelededit3.Text);
Trackinfo.mp3 := LabeledEdit3.Text;
{ mediaplayer1.Close;
mediaplayer1.FileName := Trackinfo.path + labelededit3.Text;
mediaplayer1.Open;}
end
else
begin
for k := 0 to a.Count -1 do
begin
if pos('#',a.strings[k]) = 1 then
begin
l:= pos('#',a.strings[k]) + 1;
a.Insert(l,'#MP3:'+labelededit3.Text);
Trackinfo.mp3 := LabeledEdit3.Text;
if pathdummy[3] <> Trackinfo.path then
begin
copyfile(pchar(pathdummy[3]+labelededit3.Text),pchar(Trackinfo.path+labelededit3.Text),false);
showmessage('Copying MP3 File into Songdirectory.');
end;
{mediaplayer1.Close;
mediaplayer1.FileName := Trackinfo.path + labelededit3.Text;
mediaplayer1.Open;}
break;
end;
end;
end;
end;
if Trackinfo.video <> labelededit4.Text then
begin
if a.IndexOf('#VIDEO:'+Trackinfo.video) > -1 then
begin
j := a.IndexOf('#VIDEO:'+Trackinfo.video);
a.Delete(j);
a.Insert(j,'#VIDEO:'+ labelededit4.Text);
Trackinfo.video := LabeledEdit4.Text;
{mediaplayer2.Close;
mediaplayer2.FileName := Trackinfo.path + labelededit4.Text;
mediaplayer2.DisplayRect := panel1.ClientRect;
mediaplayer2.Open;}
end
else
begin
for k := 0 to a.Count - 1 do
begin
if pos('#',a.strings[k]) = 1 then
begin
l:= pos('#',a.strings[k]) + 1;
a.Insert(l,'#VIDEO:'+labelededit4.Text);
Trackinfo.video := LabeledEdit4.Text;
if pathdummy[2] <> Trackinfo.path then
begin
copyfile(pchar(pathdummy[2]+labelededit4.Text),pchar(Trackinfo.path+labelededit4.Text),false);
showmessage('Copying Video File into Songdirectory.');
end;
{mediaplayer2.Close;
mediaplayer2.FileName := Trackinfo.path + labelededit4.Text;
mediaplayer2.DisplayRect := panel1.ClientRect;
mediaplayer2.Open;}
break;
end;
end;
end;
end;
if (Trackinfo.cover <> labelededit5.Text) then
begin
if a.IndexOf('#COVER:'+ Trackinfo.cover) > -1 then
begin
j := a.IndexOf('#COVER:'+Trackinfo.cover);
a.Delete(j);
a.Insert(j,'#COVER:'+ labelededit5.Text);
Trackinfo.cover := LabeledEdit5.Text;
if pathdummy[0] <> Trackinfo.path then
begin
copyfile(pchar(pathdummy[0]+labelededit5.text),pchar(Trackinfo.path+labelededit5.Text),false);
showmessage('Copying Cover into Songdirectory.');
end;
image1.Picture.LoadFromFile(Trackinfo.path+trackinfo.cover);
end
else
begin
for k := 0 to a.Count - 1 do
begin
if pos('#',a.strings[k]) = 1 then
begin
l:= pos('#',a.strings[k]) + 1;
a.Insert(l,'#COVER:'+labelededit5.Text);
Trackinfo.cover := LabeledEdit5.Text;
if pathdummy[0] <> Trackinfo.path then
begin
copyfile(pchar(pathdummy[0]+labelededit5.Text),pchar(Trackinfo.path+labelededit5.Text),false);
showmessage('Copying Cover into Songdirectory.');
end;
image1.Picture.LoadFromFile(Trackinfo.path+labelededit5.Text);
break;
end;
end;
end;
end;
if Trackinfo.bg <> labelededit6.Text then
begin
if a.IndexOf('#BACKGROUND:'+Trackinfo.bg) > -1 then
begin
j := a.IndexOf('#BACKGROUND:'+Trackinfo.bg);
a.Delete(j);
a.Insert(j,'#BACKGROUND:'+ labelededit6.Text);
Trackinfo.bg := LabeledEdit6.Text;
if pathdummy[1] <> Trackinfo.path then
begin
copyfile(pchar(pathdummy[0]+labelededit6.Text),pchar(Trackinfo.path+labelededit6.Text),false);
showmessage('Copying Background into Songdirectory.');
end;
image2.Picture.LoadFromFile(Trackinfo.path+labelededit6.Text);
end
else
begin
for k := 0 to a.Count - 1 do
begin
if pos('#',a.strings[k]) = 1 then
begin
l:= pos('#',a.strings[k]) + 1;
a.Insert(l,'#BACKGROUND:'+labelededit6.Text);
Trackinfo.bg := LabeledEdit6.Text;
if pathdummy[1] <> Trackinfo.path then
begin
copyfile(pchar(pathdummy[1]+labelededit6.Text),pchar(Trackinfo.path+labelededit6.Text),false);
showmessage('Copying Background into Songdirectory.');
end;
image2.Picture.loadfromfile(Trackinfo.path+labelededit6.Text);
break;
end;
end;
end;
end;
if trackinfo.name <> ( trackinfo.artist + ' - ' + trackinfo.title) then
begin
deletefile(trackinfo.path+trackinfo.name);
trackinfo.name := trackinfo.artist + ' - ' + trackinfo.title + '.txt';
assignfile(f,trackinfo.path+trackinfo.Name);
rewrite(f);
closefile(f);
end;
if ((pos('[CO]',trackinfo.cover) < 1) or (trackinfo.cover <> (trackinfo.artist+ ' - '+ trackinfo.title + '.jpg'))) and (trackinfo.cover <> '') then
begin
showmessage('Cover rename');
du := geccomod('[CO]',trackinfo.artist+ ' - '+ trackinfo.title + '.jpg');
renamefile(trackinfo.path+trackinfo.cover,trackinfo.path+du);
j := a.IndexOf('#COVER:'+trackinfo.cover);
a.Delete(j);
a.Insert(j,'#COVER:'+ du);
Trackinfo.cover := du
end;
if ((pos('[BG]',trackinfo.bg) < 1) or (trackinfo.bg <> (trackinfo.artist+ ' - '+ trackinfo.title + '.jpg'))) and (trackinfo.bg <> '') then
begin
showmessage('Background rename');
dummy := geccomod('[BG]',trackinfo.artist+ ' - '+ trackinfo.title + '.jpg');
renamefile(trackinfo.path+trackinfo.bg,trackinfo.path+dummy);
j := a.IndexOf('#BACKGROUND:'+trackinfo.bg);
a.Delete(j);
a.Insert(j,'#BACKGROUND:'+ dummy);
Trackinfo.bg := dummy
end;
if ((pos('[VD#0]',trackinfo.video) < 1) or (trackinfo.video <> (trackinfo.artist+ ' - '+ trackinfo.title + '.mpg'))) and (trackinfo.video <> '') then
begin
showmessage('Video rename');
dummy := geccomod('[VD#0]',trackinfo.artist+ ' - '+ trackinfo.title + '.mpg');
renamefile(trackinfo.path+trackinfo.video,trackinfo.path+dummy);
j := a.IndexOf('#VIDEO:'+trackinfo.video);
a.Delete(j);
a.Insert(j,'#VIDEO:'+ dummy);
Trackinfo.video := dummy
end;
assignfile(f,Trackinfo.path+Trackinfo.name);
rewrite(f);
for i := 0 to a.Count - 1 do
begin
writeln(f, a.Strings[i]);
end;
closefile(f);
end;
a.Free;
form1.Show;
Close;
end;
procedure TForm2.Button2Click(Sender: TObject);
begin
form1.show;
Close;
end;
constructor TForm2.Create(ATrackinfo: TTrackInfo);
begin
inherited Create(Application);
Trackinfo := ATrackinfo;
Caption := 'Change Details : ' + Trackinfo.artist + ' - ' + Trackinfo.title;
end;
procedure TForm2.ComboBox1Change(Sender: TObject);
var
dum : string;
begin
button1.Enabled := false;
//showmessage(trackinfo.path + ' - ' + form1.Edit1.Text+combobox1.Items.Strings[combobox1.itemindex]);
mediaplayer1.Close;
mediaplayer2.Close;
image1.Picture.LoadFromFile(ExtractFilePath(Application.ExeName)+'nopic.jpg');
image2.Picture.LoadFromFile(ExtractFilePath(Application.ExeName)+'nopic.jpg');
chdir(form1.Edit1.Text);
dum := form1.Edit1.Text+combobox1.Items.Strings[combobox1.itemindex];
//if movedir(dum, form1.Edit1.Text+combobox1.Items.Strings[combobox1.itemindex]) = true then
// showmessage('changed cat');
delete(trackinfo.path,length(trackinfo.path),1);
if dofilework(FO_move,trackinfo.path,dum,FOF_NOCONFIRMATION) = 0 then
showmessage('changed cat');
trackinfo.path := form1.Edit1.Text+combobox1.Items.Strings[combobox1.itemindex] + '\';
trackinfo.cat := combobox1.Items.Strings[combobox1.itemindex];
chdir(trackinfo.path);
button1.Enabled := true;
close;
form1.Show;
end;
end.