Delphi中播放Flash

在delphi中可以直接打开flash动画,并控制它播放和停止,还可以得到它的总帧数。

具体操作步骤:①Component -> Import ActiveX Contrals -> Shockwave Flash -> into new package下一步下一步完成。

       ②在控件条的ActiveX下发现一个新的控件,名字为ShokewaveFlash。

示例如图所示:

Delphi中播放Flash

代码如下:

 unit Unit1;

 interface

 uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.OleCtrls,
ShockwaveFlashObjects_TLB; type
TForm1 = class(TForm)
ShockwaveFlash1: TShockwaveFlash;
OpenDialog1: TOpenDialog;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Button6: TButton;
Label1: TLabel;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end; var
Form1: TForm1; implementation {$R *.dfm} PRocedure TForm1.Button1Click(Sender: TObject); //打开Flash
begin
if OpenDialog1.Execute then
ShockwaveFlash1.Movie:= OpenDialog1.FileName;
ShockwaveFlash1.StopPlay;
end; procedure TForm1.Button2Click(Sender: TObject); //播放Flash
begin
ShockwaveFlash1.Play;
end; procedure TForm1.Button3Click(Sender: TObject); //暂停Flash
begin
ShockwaveFlash1.StopPlay;
end; procedure TForm1.Button4Click(Sender: TObject); //关闭Flash
begin
ShockwaveFlash1.FreeOnRelease;
close;
end; procedure TForm1.Button5Click(Sender: TObject); //获取Flash总帧数
begin
label1.caption:= IntToStr(shockwaveflash1.totalframes );
end; procedure TForm1.Button6Click(Sender: TObject); //从Flash某一帧开始播放
begin
if ShockwaveFlash1.playing then
ShockwaveFlash1.GotoFrame(StrToInt(Edit1.Text));
ShockwaveFlash1.Play;
end; end.
上一篇:jQuery之ajax错误调试分析


下一篇:第三天