unit FlashPlayerUnit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, FileCtrl, ComCtrls, ShellCtrls, OleCtrls,
ShockwaveFlashObjects_TLB, ExtCtrls, ToolWin, ImgList, Menus;
type
TFlashPlayerForm = class(TForm)
GroupBox1: TGroupBox;
FileListBox1: TFileListBox;
StatusBar1: TStatusBar;
GroupBox2: TGroupBox;
ShockwaveFlash1: TShockwaveFlash;
ImageList1: TImageList;
OpenDlgFlashFile: TOpenDialog;
MainMenu1: TMainMenu;
F1: TMenuItem;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
N5: TMenuItem;
N6: TMenuItem;
N9: TMenuItem;
CoolBar1: TCoolBar;
ToolBar1: TToolBar;
SelectFileDirectoryBtn: TToolButton;
PlayBtn: TToolButton;
StopBtn: TToolButton;
FrontBtn: TToolButton;
NextBtn: TToolButton;
CloseBtn: TToolButton;
OpenFlashFileBtn: TToolButton;
N7: TMenuItem;
N8: TMenuItem;
procedure FormCreate(Sender: TObject);
procedure PlayBtnClick(Sender: TObject);
procedure StopBtnClick(Sender: TObject);
procedure SelectFileDirectoryBtnClick(Sender: TObject);
procedure CloseBtnClick(Sender: TObject);
procedure N1Click(Sender: TObject);
procedure FrontBtnClick(Sender: TObject);
procedure NextBtnClick(Sender: TObject);
procedure N9Click(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure N3Click(Sender: TObject);
procedure N4Click(Sender: TObject);
procedure N5Click(Sender: TObject);
procedure N6Click(Sender: TObject);
procedure Tbtn_FullClick(Sender: TObject);
procedure OpenFlashFileBtnClick(Sender: TObject);
procedure N8Click(Sender: TObject);
procedure FormClose(Sender: TObject
var Action: TCloseAction);
procedure ShockwaveFlash1ReadyStateChange(Sender: TObject;
newState: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;
var
FlashPlayerForm: TFlashPlayerForm;
implementation
uses AboutUnit;
{$R *.dfm}
procedure TFlashPlayerForm.FormCreate(Sender: TObject);
var
DefaultOpenFileDir,BackPictureDir: string;
begin
DefaultOpenFileDir :=Extractfilepath(Application.ExeName)+'banner.bmp';
BackPictureDir :=Extractfilepath(Application.ExeName)+'Flash'+'/';
if FileExists(DefaultOpenFileDir) then
begin
Coolbar1.Bitmap.LoadFromFile(DefaultOpenFileDir);
end;
if DirectoryExists(BackPictureDir) then
Filelistbox1.Directory :=BackPictureDir;
StopBtn.Enabled :=False;
FrontBtn.Enabled :=False;
NextBtn.Enabled :=False;
end;
procedure TFlashPlayerForm.PlayBtnClick(Sender: TObject);
begin
if ShockwaveFlash1.Movie<>'' then
begin
ShockwaveFlash1.Movie :=Filelistbox1.FileName;
ShockwaveFlash1.Play;
StopBtn.Enabled :=True;
FrontBtn.Enabled :=True;
NextBtn.Enabled :=True;
end
else
ShowMessage('请确认当前已打开Flash播放文件');
end;
procedure TFlashPlayerForm.StopBtnClick(Sender: TObject);
begin
ShockwaveFlash1.Movie :=Filelistbox1.FileName;
ShockwaveFlash1.Stop;
end;
procedure TFlashPlayerForm.SelectFileDirectoryBtnClick(Sender: TObject);
var sDir :string;
begin
if SelectDirectory('请选择Flash播放文件目录','',sDir) then
begin
Filelistbox1.Directory :=sDir;
end;
end;
procedure TFlashPlayerForm.CloseBtnClick(Sender: TObject);
begin
FlashPlayerForm.Close;
end;
procedure TFlashPlayerForm.N1Click(Sender: TObject);
begin
OpenFlashFileBtn.Click;
end;
procedure TFlashPlayerForm.FrontBtnClick(Sender: TObject);
begin
ShockwaveFlash1.Back;
end;
procedure TFlashPlayerForm.NextBtnClick(Sender: TObject);
begin
ShockwaveFlash1.Forward;
end;
procedure TFlashPlayerForm.N9Click(Sender: TObject);
begin
FlashPlayerForm.Close;
end;
procedure TFlashPlayerForm.N2Click(Sender: TObject);
begin
SelectFileDirectoryBtn.Click;
end;
procedure TFlashPlayerForm.N3Click(Sender: TObject);
begin
PlayBtn.Click;
end;
procedure TFlashPlayerForm.N4Click(Sender: TObject);
begin
StopBtn.Click;
end;
procedure TFlashPlayerForm.N5Click(Sender: TObject);
begin
FrontBtn.Click;
end;
procedure TFlashPlayerForm.N6Click(Sender: TObject);
begin
NextBtn.Click;
end;
procedure TFlashPlayerForm.Tbtn_FullClick(Sender: TObject);
begin
ShockwaveFlash1.SetZoomRect(Screen.DesktopLeft,Screen.DesktopHeight,Screen.DesktopTop,0);
end;
procedure TFlashPlayerForm.OpenFlashFileBtnClick(Sender: TObject);
begin
OpenDlgFlashFile.Title := '请选择要打开的Flash播放文件';
OpenDlgFlashFile.Filter := 'Flash播放文件(*.swf)|*.swf';
if OpenDlgFlashFile.Execute then
begin
ShockwaveFlash1.Movie :=OpenDlgFlashFile.FileName;
ShockwaveFlash1.Play;
end
end;
procedure TFlashPlayerForm.N8Click(Sender: TObject);
begin
Application.Createform(TAboutForm,AboutForm);
AboutForm.ShowModal;
end;
procedure TFlashPlayerForm.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
ShockwaveFlash1.Free;
Action := caFree;
FlashPlayerForm := nil;
end;
procedure TFlashPlayerForm.ShockwaveFlash1ReadyStateChange(Sender: TObject;
newState: Integer);
begin
if ShockwaveFlash1.ReadyState =4 then
StatusBar1.SimpleText :='播放至'+inttostr(ShockwaveFlash1.FrameNum)+'帧/共'+inttostr(ShockwaveFlash1.TotalFrames)+'帧';
end;
end.