算了我就贴出来好了 给你个烂点的unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, FileCtrl, ExtCtrls, MPlayer, ComCtrls;
type
TForm1 = class(TForm)
MediaPlayer1: TMediaPlayer;
Panel1: TPanel;
Button1: TButton;
Button2: TButton;
OpenDialog1: TOpenDialog;
Timer1: TTimer;
TrackBar1: TTrackBar;
FileListBox1: TFileListBox;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure FileListBox1Change(Sender: TObject);
procedure TrackBar1DragDrop(Sender, Source: TObject;
X, Y: Integer);
procedure TrackBar1EndDrag(Sender, Target: TObject;
X, Y: Integer);
private
{ Private declarations }
procedure PlayAvi();
public
{ Public declarations }
end;
var
Form1: TForm1;
g_index :Integer;
implementation
{$R *.dfm}
procedure TForm1.PlayAvi();
begin
if g_index = FileListBox1.Count then
g_index := 0;
MediaPlayer1.FileName:=FileListBox1.Items[g_index];
MediaPlayer1.Open;
MediaPlayer1.Display := Panel1;
MediaPlayer1.DisplayRect := Rect(0,0,Panel1.Width,Panel1.Height);
MediaPlayer1.Play;
TrackBar1.Min := 0;
TrackBar1.Max := MediaPlayer1.Length;
TrackBar1.Position := 0;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
FileListBox1.Clear;
if OpenDialog1.Execute then
begin
FileListBox1.Items := OpenDialog1.Files;
end;
MediaPlayer1.Close;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
PlayAvi();
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if MediaPlayer1.Mode = mpPlaying then
TrackBar1.Position := MediaPlayer1.Position;
if (MediaPlayer1.Mode = mpStopped)and(MediaPlayer1.Position = MediaPlayer1.Length) then
begin
g_index := g_index+1;
PlayAvi();
end;
end;
procedure TForm1.FileListBox1Change(Sender: TObject);
begin
g_index := FileListBox1.ItemIndex ;
// PlayAvi();
end;
procedure TForm1.TrackBar1DragDrop(Sender, Source: TObject;
X, Y: Integer);
begin
Timer1.Enabled := False;
MediaPlayer1.Position := TrackBar1.Position;
end;
procedure TForm1.TrackBar1EndDrag(Sender, Target: TObject;
X, Y: Integer);
begin
Timer1.Enabled := True;
end;
end.