用MEDIAPLAEYRR 做播放器,PANEL面板做显示窗口.TRACKBAR做进度显示.

type
  TForm1 = class(TForm)
    MediaPlayer1: TMediaPlayer;
    Panel1: TPanel;
    MainMenu1: TMainMenu;
    N1: TMenuItem;
    N2: TMenuItem;
    N3: TMenuItem;
    OpenDialog1: TOpenDialog;
    TrackBar1: TTrackBar;
    Timer1: TTimer;
    procedure N2Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure TrackBar1Change(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.N2Click(Sender: TObject);
begin
if opendialog1.execute then
   mediaplayer1.filename:=opendialog1.filename;
   mediaplayer1.Open;
   mediaplayer1.DisplayRect:=panel1.ClientRect;
   mediaplayer1.Play;
   mediaplayer1.Notify:=true;
   end;

procedure TForm1.FormCreate(Sender: TObject);
begin
 mediaplayer1.DisplayRect:=panel1.ClientRect;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
trackbar1.Position:=mediaplayer1.position;
trackbar1.Max:=mediaplayer1.Length;
end;

procedure TForm1.TrackBar1Change(Sender: TObject);
begin
     //if mediaplayer1.Mode in [mpplaying ] then

//if timer1.enabled=true then
  // timer1.Enabled:=false;


  // mediaplayer1.Position:=trackbar1.Position;
  // trackbar1.Max:=mediaplayer1.Position;
  // mediaplayer1.resume;
  // timer1.Enabled:=true;
  // if mediaplayer1.Mode in [mppaused] then
  // mediaplayer1.Position:=trackbar1.Position;
  // timer1.enabled:=true;
end;

end.
怎么用TRACKBAR来实现影片的拖动呢