unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls, MPlayer, jpeg;
type
TForm1 = class(TForm)
MediaPlayer1: TMediaPlayer;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
OpenDialog1: TOpenDialog;
Timer1: TTimer;
Label1: TLabel;
Image1: TImage;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
endposition:integer;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
opendialog1.FileName:='*.avi';
if opendialog1.Execute then
begin
mediaplayer1.Close;
mediaplayer1.filename:=opendialog1.filename;
label1.caption:='当前播放文件:'+Extractfilename(opendialog1.filename);
mediaplayer1.open;
mediaplayer1.next;
endposition:=mediaplayer1.position;
mediaplayer1.rewind;
button2.enabled:=true;
button3.enabled:=false;
button4.enabled:=false;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if mediaplayer1.mode=mppaused then
begin
mediaplayer1.Resume;
end
else
begin
mediaplayer1.play;
end;
button4.Enabled:=true;
button3.enabled:=true;
timer1.Enabled:=true;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
mediaplayer1.Pause;
button3.Enabled:=false;
button4.enabled:=false;
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
mediaplayer1.Rewind;
mediaplayer1.Play;
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
mediaplayer1.close;
close;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if mediaplayer1.position=endposition then
begin
mediaplayer1.rewind;
mediaplayer1.play;
end;
end;
end.
你运行一下试试吧