羽
羽.泉
Unregistered / Unconfirmed
GUEST, unregistred user!
我用delphi5编了一个很小很小的播放器,但trackbar不随着播放的进度而改变,不知为什么?请指教!!!下面是源代码:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Menus, MPlayer, ExtCtrls, ComCtrls,unit2;
type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
Panel1: TPanel;
TrackBar1: TTrackBar;
OpenDialog1: TOpenDialog;
Timer1: TTimer;
MediaPlayer1: TMediaPlayer;
Open1: TMenuItem;
Close1: TMenuItem;
Exit1: TMenuItem;
PopupMenu1: TPopupMenu;
Open2: TMenuItem;
Close2: TMenuItem;
Exit2: TMenuItem;
H1: TMenuItem;
procedure Open1Click(Sender: TObject);
procedure Close1Click(Sender: TObject);
procedure Exit1Click(Sender: TObject);
procedure TrackBar1Change(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Open2Click(Sender: TObject);
procedure Close2Click(Sender: TObject);
procedure Exit2Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure H1Click(Sender: TObject);
private
{ Private declarations}
runed:boolean;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Open1Click(Sender: TObject);
begin
if opendialog1.Execute then
begin
mediaplayer1.FileName:=opendialog1.FileName;
mediaplayer1.Open;
runed:=true;
trackbar1.Max:=mediaplayer1.Length;
end;
end;
procedure TForm1.Close1Click(Sender: TObject);
begin
mediaplayer1.Close;
runed:=false;
end;
procedure TForm1.Exit1Click(Sender: TObject);
begin
mediaplayer1.Close;
close;
end;
procedure TForm1.TrackBar1Change(Sender: TObject);
begin
if runed then
mediaplayer1.Position:=trackbar1.Position;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
runed:=false;
end;
procedure TForm1.Open2Click(Sender: TObject);
begin
if opendialog1.Execute then
begin
mediaplayer1.FileName:=opendialog1.FileName;
mediaplayer1.Open;
runed:=true;
trackbar1.Max:=mediaplayer1.Length;
end;
end;
procedure TForm1.Close2Click(Sender: TObject);
begin
mediaplayer1.Close;
runed:=false;
end;
procedure TForm1.Exit2Click(Sender: TObject);
begin
mediaplayer1.Close;
close;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if runed then
trackbar1.Position:=mediaplayer1.Position;
end;
procedure TForm1.H1Click(Sender: TObject);
begin
form2.showmodal;
end;
end.
如果谁会请和我联系:mydream@371.net.谢谢啦!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Menus, MPlayer, ExtCtrls, ComCtrls,unit2;
type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
Panel1: TPanel;
TrackBar1: TTrackBar;
OpenDialog1: TOpenDialog;
Timer1: TTimer;
MediaPlayer1: TMediaPlayer;
Open1: TMenuItem;
Close1: TMenuItem;
Exit1: TMenuItem;
PopupMenu1: TPopupMenu;
Open2: TMenuItem;
Close2: TMenuItem;
Exit2: TMenuItem;
H1: TMenuItem;
procedure Open1Click(Sender: TObject);
procedure Close1Click(Sender: TObject);
procedure Exit1Click(Sender: TObject);
procedure TrackBar1Change(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Open2Click(Sender: TObject);
procedure Close2Click(Sender: TObject);
procedure Exit2Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure H1Click(Sender: TObject);
private
{ Private declarations}
runed:boolean;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Open1Click(Sender: TObject);
begin
if opendialog1.Execute then
begin
mediaplayer1.FileName:=opendialog1.FileName;
mediaplayer1.Open;
runed:=true;
trackbar1.Max:=mediaplayer1.Length;
end;
end;
procedure TForm1.Close1Click(Sender: TObject);
begin
mediaplayer1.Close;
runed:=false;
end;
procedure TForm1.Exit1Click(Sender: TObject);
begin
mediaplayer1.Close;
close;
end;
procedure TForm1.TrackBar1Change(Sender: TObject);
begin
if runed then
mediaplayer1.Position:=trackbar1.Position;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
runed:=false;
end;
procedure TForm1.Open2Click(Sender: TObject);
begin
if opendialog1.Execute then
begin
mediaplayer1.FileName:=opendialog1.FileName;
mediaplayer1.Open;
runed:=true;
trackbar1.Max:=mediaplayer1.Length;
end;
end;
procedure TForm1.Close2Click(Sender: TObject);
begin
mediaplayer1.Close;
runed:=false;
end;
procedure TForm1.Exit2Click(Sender: TObject);
begin
mediaplayer1.Close;
close;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if runed then
trackbar1.Position:=mediaplayer1.Position;
end;
procedure TForm1.H1Click(Sender: TObject);
begin
form2.showmodal;
end;
end.
如果谁会请和我联系:mydream@371.net.谢谢啦!