unit mp3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls, MPlayer, ExtCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
TrackBar1: TTrackBar;
MediaPlayer1: TMediaPlayer;
Timer1: TTimer;
ListBox1: TListBox;
Button5: TButton;
OpenDialog1: TOpenDialog;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure TrackBar1Change(Sender: TObject);
private
public
var running:boolean;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
if Button1.Caption='Play' then
if running=true then
begin
Mediaplayer1.Resume;
Button1.caption:='Pause';
end
else
begin
Mediaplayer1.Open;
Mediaplayer1.Play;
Button1.caption:='Pause';
running:=true;
end
else
begin
Mediaplayer1.Pause;
Button1.caption:='Play';
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Mediaplayer1.stop;
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
Opendialog1.execute;
Mediaplayer1.Filename:=Opendialog1.FileName;
Mediaplayer1.Open;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Trackbar1.Position:=Mediaplayer1.Position;
end;
procedure TForm1.TrackBar1Change(Sender: TObject);
begin
Trackbar1.Max:=Mediaplayer1.TrackLength[0];
end;
end.