Tuesday, 7 April 2015

DELPHI7 :: Program Sederhana Playlist

http://form-info.blogspot.com/
Assalamualikum kawan.....
Kali ini kita akan membuat program sederhana Playlist ,di mana
playlist ini kita bisa memutar music.
Nah ini cara-caranya utk membuat program tersebut,moga bisa berguna utk sobat semua.
Moga bermanfaat utk kawan2 smuax..


1. Sekedar Info, Aplikasi Ini Membutuhkan 2 Buah Form.
2. Buka Delphi Anda Desain Tampilan-nya Kayak Gini (Lebih Bagus Lebih Baik) :

Komponen-komponen-nya adalah :
1 Buah Media Player
1 Buah Progresbar
3 buah button
1 Buah Panel
1 Buah Label
1 Buah Timer
1 Buah Open Dialog
1 Buah Speed Button

2. Untuk Form Dua (Playlist-nya)
Komponen Yang dibutuhkan :
1 Buah Popup Menu
1 Buah List
http://form-info.blogspot.com/

Code Untuk Form 2 :
procedure Tplaylist.Hapus1Click(Sender: TObject);
begin
list.Items.Delete(list.ItemIndex);
end;

procedure Tplaylist.listDblClick(Sender: TObject);
begin
form1.btstart.Caption:='Start';
form1.btstart.OnClick(self);
end;
end.

Code Untuk Form 1
var
Form1: TForm1;
index : integer;

implementation

uses Unit2;

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
judul.Caption:='';
timer1.Enabled:=false;
btstart.Enabled:=false;
btstop.Enabled:=false;
progress.Enabled:=false;
end;

procedure TForm1.showplsClick(Sender: TObject);
begin
playlist.show;
end;

procedure TForm1.btopenClick(Sender: TObject);
var
i : integer;
begin
if opendialog1.Execute then
begin
for i:=0 to opendialog1.Files.Count-1 do
playlist.list.Items.Add(opendialog1.Files.Strings[i]);
btstart.Enabled:=true;
playlist.Show;
playlist.list.ItemIndex:=0;
end;
end;

procedure TForm1.btstartClick(Sender: TObject);
begin
if btstart.Caption = 'Start' then
begin
index:=playlist.list.itemindex;
mp.FileName:=playlist.list.Items.Strings[index];
mp.Open;
judul.Caption:=extractfilename(mp.FileName);
judul.Left:=200;
progress.Max:=mp.Length;
mp.Play;
timer1.Enabled:=true;
progress.Enabled:=true;
btstop.Enabled:=true;
btstart.Caption:='Pause';
end else
if btstart.Caption = 'Pause' then
begin
mp.Pause;
btstart.Caption:='Play';
end else
if btstart.Caption = 'Play' then
begin
mp.Pause;
btstart.Caption:='Pause';
end else
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
mp.Close;
end;

procedure TForm1.btstopClick(Sender: TObject);
begin
mp.Stop;
timer1.Enabled:=false;
judul.Left:=8;
btstart.Caption:='Start';
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
judul.Left:=judul.Left-1;
if judul.Left = 0-judul.Width then
judul.Left:=panel1.Width+1;
progress.Position:=mp.Position;
if mp.position=mp.Length then
begin
if index + 1 = playlist.list.Items.Count then
begin
form1.btstop.OnClick(self);
playlist.list.ItemIndex:=0;
end else
begin
playlist.list.ItemIndex:=index+1;
btstart.Caption:='Start';
btstart.OnClick(self);
end;
end;
end;

procedure TForm1.progressScroll(Sender: TObject; ScrollCode: TScrollCode;
var ScrollPos: Integer);
begin
mp.Position:=progress.Position;
mp.Play;
end;

end.

No comments:

Post a Comment