MP3 Player

mp31unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, FileCtrl, StdCtrls,Comctrls,extctrls,mplayer,gauges,buttons,appevnts,
mmsystem, jpeg;

type
TForm1 = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
lwaktu: TLabel;
ldurasi: TLabel;
Llagu: TLabel;
Button1: TButton;
chkHening: TCheckBox;
TrackBar1: TTrackBar;
GDurasi: TGauge;
MDPlayer: TMediaPlayer;
Panel3: TPanel;
otomatis: TCheckBox;
Panel4: TPanel;
Label4: TLabel;
Lstatus: TLabel;
LstDaftar: TListBox;
Panel5: TPanel;
Timer1: TTimer;
Timer2: TTimer;
Timer3: TTimer;
ODBukadaftar: TOpenDialog;
savelist: TSaveDialog;
odDaftar: TOpenDialog;
LstDaftar2: TListBox;
Lbukafile: TLabel;
Lsimpandaftar: TLabel;
Lbukadaftar: TLabel;
Lhapusdaftar: TLabel;
Lsemualagu: TLabel;
Lsatulagu: TLabel;
Lkeluar: TLabel;
PnLayar: TPanel;
BtPenuh: TButton;
ChkAsli: TCheckBox;
procedure besarkanfont(Tulisan:Tlabel);
procedure kecilkanfont(Tulisan:Tlabel);
procedure mainkan;
procedure LbukafileMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure LsimpandaftarMouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
procedure LbukadaftarMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure LsemualaguMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure LsatulaguMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure LkeluarMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure LbukafileMouseLeave(Sender: TObject);
procedure LsimpandaftarMouseLeave(Sender: TObject);
procedure LbukadaftarMouseLeave(Sender: TObject);
procedure LsemualaguMouseLeave(Sender: TObject);
procedure LsatulaguMouseLeave(Sender: TObject);
procedure LkeluarMouseLeave(Sender: TObject);
procedure LbukafileClick(Sender: TObject);
procedure LsimpandaftarClick(Sender: TObject);
procedure LbukadaftarClick(Sender: TObject);
procedure LsemualaguClick(Sender: TObject);
procedure LsatulaguClick(Sender: TObject);
procedure LkeluarClick(Sender: TObject);
procedure MDPlayerClick(Sender: TObject; Button: TMPBtnType;
var DoDefault: Boolean);
procedure LstDaftarClick(Sender: TObject);
procedure LstDaftarDblClick(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Timer2Timer(Sender: TObject);
procedure Timer3Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure TrackBar1Change(Sender: TObject);
procedure chkHeningClick(Sender: TObject);
procedure ChkAsliClick(Sender: TObject);
procedure BtPenuhClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
konfirmasi : integer;
k,d : integer;
device,p : integer;
filename : string;

menit,detik : integer;
Tmenit,Tdetik,hasilwaktu : string;
wklagu : integer;

implementation

uses Unit2;

{$R *.dfm}

procedure TForm1.besarkanfont(Tulisan:TLabel);
begin
Tulisan.Font.Size:=9;
Tulisan.Font.Style:=[fsBold,fsUnderline];
Tulisan.Font.Color:=clRed;
end;
procedure TForm1.kecilkanfont(Tulisan:Tlabel);
begin
tulisan.Font.Size:=8;
Tulisan.Font.Style:=[];
Tulisan.Font.Color:=clBlack;
end;
procedure TForm1.mainkan;
var
m,d : real;
begin
if LstDaftar.Items.Count=0 then
exit
else
begin
if k=LstDaftar2.Items.Count then k:=0;
filename:=LstDaftar2.Items.Strings[k];
MDPlayer.FileName:=filename;
MDPlayer.Open;
if FormLayarPenuh.Visible= true then
MDPlayer.Display:=FormLayarPenuh else
MDPlayer.Display :=PnLayar;
if ChkAsli.Checked=true then
MDPlayer.DisplayRect:=rect(0,0,0,0) else
begin
if FormLayarPenuh.Visible= true then
MDPlayer.DisplayRect:=rect(0,0,FormLayarPenuh.Width,FormLayarPenuh.Height) else
MDPlayer.DisplayRect:=Rect(0,0,PnLayar.Width,PnLayar.Height);
end;
MDPlayer.Play;

GDurasi.MaxValue:=MDPlayer.Length;
timer3.Enabled:=true;
MDPlayer.TimeFormat:=tfMilliseconds;
m:=(MDPlayer.Length / 1000 / 60);
d:=60/100*((StrToFloat(copy(FloatToStr(m),3,4))));
//  ldurasi.Caption:='[‘+(copy(FloatToStr(m),1,1+’:’+(copy(FloatToStr(d),1,2)+’]’);
Llagu.Caption:=ExtractFileName(filename);
Lstatus.Caption:=’Mainkan’;
end;
end;
procedure TForm1.LbukafileMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
besarkanfont(Lbukafile);
end;

procedure TForm1.LsimpandaftarMouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
begin
besarkanfont(Lsimpandaftar);
end;

procedure TForm1.LbukadaftarMouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
begin
besarkanfont(Lbukadaftar);
end;

procedure TForm1.LsemualaguMouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
begin
besarkanfont(Lsemualagu);
end;

procedure TForm1.LsatulaguMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
besarkanfont(Lsatulagu);
end;

procedure TForm1.LkeluarMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
besarkanfont(Lkeluar);
end;

procedure TForm1.LbukafileMouseLeave(Sender: TObject);
begin
kecilkanfont(Lbukafile);
end;

procedure TForm1.LsimpandaftarMouseLeave(Sender: TObject);
begin
kecilkanfont(Lsimpandaftar);
end;

procedure TForm1.LbukadaftarMouseLeave(Sender: TObject);
begin
kecilkanfont(Lbukadaftar);
end;

procedure TForm1.LsemualaguMouseLeave(Sender: TObject);
begin
kecilkanfont(Lsemualagu);
end;

procedure TForm1.LsatulaguMouseLeave(Sender: TObject);
begin
kecilkanfont(Lsatulagu);
end;

procedure TForm1.LkeluarMouseLeave(Sender: TObject);
begin
kecilkanfont(Lkeluar);
end;

procedure TForm1.LbukafileClick(Sender: TObject);
var
x,z : integer;
begin
GDurasi.Progress:=0;
LstDaftar.Clear;
if odDaftar.Execute then
LstDaftar2.Items.AddStrings(odDaftar.Files);
z:=LstDaftar2.Items.Count;
if z >0 then
begin
for x :=0 to (z-1) do
LstDaftar.Items.Add(ExtractFileName(LstDaftar2.Items.Strings[x]));
k:=0;
MDPlayer.Enabled:=true;
mainkan;
end;
end;

procedure TForm1.LsimpandaftarClick(Sender: TObject);
begin
if savelist.Execute then
LstDaftar2.Items.SaveToFile(savelist.FileName);
end;

procedure TForm1.LbukadaftarClick(Sender: TObject);
var
x,z : integer;
begin
GDurasi.Progress:=0;
if ODBukadaftar.Execute then
begin
LstDaftar2.Clear;
LstDaftar.Clear;
LstDaftar2.Items.LoadFromFile(ODBukadaftar.FileName);
z:=LstDaftar2.Items.Count;
if z <> 0 then
begin
for x :=0 to (z-1) do
LstDaftar.items.Add(ExtractFileName(LstDaftar2.Items.Strings[x]));
k:=0;
MDPlayer.Enabled:=true;
mainkan;
end;
end;
end;
procedure TForm1.LsemualaguClick(Sender: TObject);
begin
if LstDaftar.Items.Count=0 then
Application.MessageBox(‘Daftar lagu kosong’,’informasi’,MB_ICONINFORMATION)
else
begin
konfirmasi:=Application.MessageBox(‘Anda Yakin ?’,’Konfirmasi’,MB_ICONQUESTION
or MB_YESNO);
if konfirmasi=idyes then
begin
LstDaftar.Clear;
LstDaftar2.Clear;
end
else
exit;
end;
end;

procedure TForm1.LsatulaguClick(Sender: TObject);
begin
if LstDaftar.Items.Count=0 then
Application.MessageBox(‘Daftar lagu kosong..’,’Konfirmasi’,MB_ICONEXCLAMATION)
else
begin
LstDaftar.SetFocus;
k:=LstDaftar.ItemIndex;
konfirmasi:=Application.MessageBox(‘Anda Yakin?’,’Konfirmasi’,MB_ICONQUESTION
or MB_YESNO);
if konfirmasi=idyes then
begin
LstDaftar.DeleteSelected;
LstDaftar2.DeleteSelected;
end
else
exit;
end;
end;

procedure TForm1.LkeluarClick(Sender: TObject);
begin
halt;

end;

procedure TForm1.MDPlayerClick(Sender: TObject; Button: TMPBtnType;
var DoDefault: Boolean);
begin
case button of
btPlay:
begin
if LstDaftar.Items.Count=0 then
begin
MDPlayer.Close;
exit;
end
else
begin
timer3.Enabled:=true;
Lstatus.Caption:=’Mainkan’;
mainkan;
end;
end;
btPause:
begin
timer3.Enabled:=false;
Lstatus.Caption:=’Tahan’;
end;
btStop:
begin
timer3.Enabled:=false;
Lstatus.Caption:=’Berhenti’;
MDPlayer.Position:=0;
end;
btstep:
begin
Lstatus.Caption:=’Lewati’;
end;
btBack:
begin
Lstatus.Caption:=’Kembali’;
end;
btNext:
begin
Lstatus.Caption:=’Berikutnya’;
end;
btPrev:
begin
Lstatus.Caption:=’Ulangi’;
end;
end;
GDurasi.MaxValue:=MDPlayer.Length;

end;

procedure TForm1.LstDaftarClick(Sender: TObject);
begin
k:=LstDaftar.ItemIndex;
LstDaftar2.ItemIndex:=k;
end;

procedure TForm1.LstDaftarDblClick(Sender: TObject);
begin
LstDaftar2.ItemIndex:=LstDaftar.ItemIndex;
mainkan;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
var
Nfile : integer;
begin
GDurasi.Progress:=MDPlayer.Position;
Nfile:=LstDaftar2.Items.Count;
if Nfile=0 then
begin
MDPlayer.Enabled:=false;
GDurasi.Progress:=0;
exit;
end
else
begin
MDPlayer.Enabled:=true;
if (GDurasi.PercentDone=100) and (GDurasi.MaxValue=MDPlayer.Length) then
begin
GDurasi.Progress:=0;
if chkHening.Checked=true then
begin
if k = Nfile then
begin
k:=0;
LstDaftar2.ItemIndex:=0;
LstDaftar.ItemIndex:=0;
end
else
begin
k:=k+1;
LstDaftar.ItemIndex:=k;
LstDaftar2.ItemIndex:=k;
end;
end
else
begin
k:=random(nfile);
end;
mainkan;
end;
end;
end;
procedure TForm1.Timer2Timer(Sender: TObject);
begin
Llagu.left:=Llagu.Left-1;
if llagu.Left+Llagu.Width <=0 then
Llagu.Left:=panel1.Width;
if LstDaftar.items.Count=0 then
begin
Llagu.Caption:=’Player Musik’;
Lwaktu.Caption:=’Player’;
Ldurasi.Caption:=’Den@ryo’;
end;
end;

procedure TForm1.Timer3Timer(Sender: TObject);
begin
wklagu:=MDPlayer.Position;
detik:=wklagu div 1000;
menit:=detik div 60;
detik:=(detik-menit*60);
if menit  >9 then
tmenit:=IntToStr(menit)
else
tmenit:=’0′ + IntToStr(menit);
if detik > 9 then
tdetik:=IntToStr(detik)
else
tdetik:=’0’+IntToStr(detik);
hasilwaktu:=Tmenit+’:’+tdetik;
Lwaktu.Caption:=(hasilwaktu);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
timer3.Enabled:=false;
TrackBar1.Position:=TrackBar1.Max;
GDurasi.Enabled:=false;
end;

procedure TForm1.TrackBar1Change(Sender: TObject);
begin
if chkHening.Checked = true then
chkHening.Checked:=false;
case TrackBar1.Position of
1 : waveOutSetVolume(0,$00000000);
2 : waveOutSetVolume(0,$10001000);
3 : waveOutSetVolume(0,$20002000);
4 : waveOutSetVolume(0,$30003000);
5 : waveOutSetVolume(0,$40004000);
6 : waveOutSetVolume(0,$50005000);
7 : waveOutSetVolume(0,$60006000);
8 : waveOutSetVolume(0,$70007000);
9 : waveOutSetVolume(0,$80008000);
10: waveOutSetVolume(0,$90009000);
11: waveOutSetVolume(0,$A000A000);
12 : waveOutSetVolume(0,$B000B000);
13 : waveOutSetVolume(0,$C000C000);
14 : waveOutSetVolume(0,$D000D000);
15 : waveOutSetVolume(0,$E000E000);
16 : waveOutSetVolume(0,$F000F000);
17:  waveOutSetVolume(0,$FF00FF00);
18 : waveOutSetVolume(0,$FFF0FFF0);
19 : waveOutSetVolume(0,$FFFFFFFF);
20 : waveOutSetVolume(0,$FFFFFFFF);
END;
end;

procedure TForm1.chkHeningClick(Sender: TObject);
begin
if chkHening.Checked= true then
waveOutSetVolume(0,$00000000)
else
begin
TrackBar1.Position:= TrackBar1.Max-1;
end;
end;

procedure TForm1.ChkAsliClick(Sender: TObject);
begin
if chkHening.Checked= true then
MDPlayer.DisplayRect:=Rect(0,0,0,0) else
MDPlayer.DisplayRect:=Rect(0,0,PnLayar.Width,PnLayar.Height);
end;

procedure TForm1.BtPenuhClick(Sender: TObject);
begin
Application.MessageBox(‘Untuk menutup full screen,Double click aja…’,
‘Layar Penuh’,MB_ICONINFORMATION);
FormLayarPenuh.Show;
MDPlayer.Display:=FormLayarPenuh;
if ChkAsli.Checked= true then
MDPlayer.DisplayRect:=Rect(0,0,0,0) else
MDPlayer.DisplayRect:=Rect(0,0,FormLayarPenuh.Width,FormLayarPenuh.Height);

end;

end.

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: