【delphi开源代码栏目提醒】:网学会员为广大网友收集整理了,FLargeAVIMain.pas,希望对大家有所帮助!
unit FLargeAVIMain;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, Grids, DBGrids, ExtCtrls, DBCtrls, StdCtrls, Buttons,
ComCtrls, MPlayer;
type
TForm1 = class(TForm)
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
bbtnGenerate: TBitBtn;
DBNavigator1: TDBNavigator;
DBGrid1: TDBGrid;
DataSource1: TDataSource;
DBNavigator2: TDBNavigator;
DBGrid2: TDBGrid;
MediaPlayer1: TMediaPlayer;
Panel1: TPanel;
bbtnPlay: TBitBtn;
pbCount: TProgressBar;
procedure bbtnGenerateClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure bbtnPlayClick(Sender: TObject);
procedure MediaPlayer1Notify(Sender: TObject);
private
{ Private declarations }
lStart : Longint;
lEnd : Longint;
iIID : Integer;
iTarget : Integer;
aviFiles : array[0..3] of String;
iAVI : Integer;
function GetID : Integer;
function GetName : String;
procedure GetAVI;
public
{ Public declarations }
Procedure GetStartTime;
Procedure GetEndTime;
function GetRunTime : Double;
Procedure ShowRunTimeMsg;
end;
var
Form1: TForm1;
implementation
uses udmLargeAVI;
{$R *.dfm}
const
LOOP = 50;
procedure TForm1.bbtnGenerateClick(Sender: TObject);
var
iCount : Integer;
begin
pbCount.Max := LOOP;
pbCount.Position := 0;
lStart := GetTickCount;
for iCount := 1 to LOOP do
begin
iAVI := Random(4);
if (iAVI = 3) then
iAVI := Random(4);
dmAVI.cdsAVI.Insert;
dmAVI.cdsAVI.FieldByName('ID').Value := GetID;
dmAVI.cdsAVI.FieldByName('NAME').Value := GetName;
dmAVI.cdsAVI.FieldByName('INDATE').Value := Now;
GetAVI;
dmAVI.cdsAVI.Post;
pbCount.Position := pbCount.Position + 1;
Application.ProcessMessages;
end;
dmAVI.cdsAVI.ApplyUpdates(0);
lEnd := GetTickCount;
Self.Caption := FloatToStr( ((lEnd - lStart) / 1000.0) );
end;
procedure TForm1.GetAVI;
begin
dmAVI.cdsAVIAVI.LoadFromFile(dmAVI.cdsAVI.FieldByName('NAME').AsString);
end;
function TForm1.GetID: Integer;
begin
Result := iIID;
Inc(iIID);
end;
function TForm1.GetName: String;
begin
Result := '';
Result := aviFiles[iAVI];
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Randomize;
iIID := 1;
aviFiles[0] := 'COOL.AVI';
aviFiles[1] := 'Count24.AVI';
aviFiles[2] := 'dx.AVI';
aviFiles[3] := 'Speedis.AVI';
end;
procedure TForm1.bbtnPlayClick(Sender: TObject);
begin
GetStartTime;
dmAVI.cdsAVIAVI.SaveToFile('TEMPAVI.AVI');
MediaPlayer1.FileName := 'TEMPAVI.AVI';
MediaPlayer1.Open;
MediaPlayer1.Play;
GetEndTime;
ShowRunTimeMsg;
end;
procedure TForm1.MediaPlayer1Notify(Sender: TObject);
begin
if (MediaPlayer1.Mode = mpStopped) then
begin
MediaPlayer1.Close;
end;
end;
procedure TForm1.GetEndTime;
begin
lEnd := GetTickCount;
end;
function TForm1.GetRunTime: Double;
begin
Result := (lEnd - lStart) / 1000.0;
end;
procedure TForm1.GetStartTime;
begin
lStart := GetTickCount;
end;
procedure TForm1.ShowRunTimeMsg;
begin
Self.Caption := Self.Caption + '-' + FloatToStr(GetRunTime);
end;
end.