unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, MPlayer, StdCtrls, ComCtrls;
type
TForm1 = class(TForm)
od: TOpenDialog;
mp: TMediaPlayer;
Button1: TButton;
tb: TTrackBar;
procedure Button1Click(Sender: TObject);
procedure tbChange(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
if od.Execute then
begin
mp.FileName:=od.FileName;
try
mp.open;
mp.play;
tb.Max:=mp.Length;
except
showmessage('播放不成功');
end;
end;
end;
procedure TForm1.tbChange(Sender: TObject);
begin
mp.Position:=tb.Position;
mp.play;
end;
end.