对放avi的补充,是编的原代码.(0分)

  • 主题发起人 主题发起人 eden
  • 开始时间 开始时间
E

eden

Unregistered / Unconfirmed
GUEST, unregistred user!
unit media1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ComCtrls, ExtCtrls, MPlayer;

type
TForm1 = class(TForm)
MediaPlayer1: TMediaPlayer;
Timer1: TTimer;
TrackBar1: TTrackBar;
Button1: TButton;
Button2: TButton;
Button3: TButton;
OpenDialog1: TOpenDialog;
procedure Button3Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;


var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button3Click(Sender: TObject);
begin

if mediaplayer1.filename<>'' then

begin

mediaplayer1.Stop;
timer1.enabled:=false;
end;


end;


procedure TForm1.Button1Click(Sender: TObject);
begin

if opendialog1.execute then

begin

mediaplayer1.filename:=opendialog1.filename;
timer1.enabled:=false;
mediaplayer1.close;
mediaplayer1.Open;
mediaplayer1.timeformat:=tfhms;
caption:=opendialog1.filename;
trackbar1.min:=0;
trackbar1.max:=mediaplayer1.length;
trackbar1.position:=0;
end;


end;


procedure TForm1.Button2Click(Sender: TObject);
begin

if mediaplayer1.filename<>'' then

begin

mediaplayer1.wait:=false;
mediaplayer1.play;
timer1.enabled:=true;
end;



end;


procedure TForm1.Timer1Timer(Sender: TObject);
begin

mediaplayer1.timeformat:=tfhms;
trackbar1.min:=0;
trackbar1.max:=mediaplayer1.length;
trackbar1.position:=mediaplayer1.position;

end;


end.
 
看过了,建议改两处:
Button3Click(Sender: TObject);
begin

MediaPlayer1.Close;
...
end;

...
Timer1OnTimer(Sender: TObject);
begin

TrackBar1.Position:=MediaPlayer1.Position;
//去掉本过程中的其他语句
end;
 
1为什么是close,我用的stop有问题吗?
2mediaplayer1.timeformat:=tfhms里的tfhms是什么意思呀?
 
附加功能 将问题提前
 
timeformat只要设一次,不用放在OnTimer里
 
接受答案了.
 

Similar threads

后退
顶部