Home | Delphi SWF SDK | SlideShow Engine | Free source samples | Code library | Forum | Contact

Code library

TFlashPlayerControl

There is a great solution for movies playing - the TFlashPlayerControl component, that is an alternative of TShockWaveFlash!

TFlashPlayerControl features:

Creates flash-enabled applications which are ready to work even without the flash player activex installing

Traditionally, there are many obstacles or annoyances that one encounters using Flash in Delphi applications.

Delphi applications need flash.ocx/swflash.ocx installed in the system before it works;
have to work flawlessly with the the already installed version of the Macromedia Flash Player;
have no easy way to prevent the Flash movie files (SWF) from being abused.

TFlashControl solves these problems and more!

By default, the component uses the flash.ocx/swflash.ocx that has already installed on the system. You can use any source as ActiveX. So your application works even if the Macromedia Flash Player is not installed yet. Just use the FlashPlayerControl.LoadFlashOCXCodeFromStream method. The example how to load the flash.ocx control from the file is below:

var
 FlashCodeStream: TFileStream;

initialization
 FlashCodeStream := TFileStream.Create(AppDir + 'flash.ocx', fmOpenRead or fmShareDenyNone);
 FlashPlayerControl.LoadFlashOCXCodeFromStream(FlashCodeStream);
 FlashCodeStream.Free;

Here is an example how to load flash.ocx control from TStream:

{$RESOURCE 'res\flash.res'}
// contents of flash.rc file:
//
FlashOCXCode BIN "flash.ocx"
var
 FlashCodeStream: TResourceStream;
initialization
 FlashCodeStream := TResourceStream.Create(0, 'FlashOCXCode', 'BIN');
 FlashPlayerControl.LoadFlashOCXCodeFromStream(FlashCodeStream);
 FlashCodeStream.Free;


Loads flash movies from any TStream (TResourceStream, TMemoryStream, etc.)

Using the component you can load a flash movie from any stream object just using LoadMovieFromStream (LoadMovie analogue) and PutMovieFromStream (Movie property analogue). Movies get loaded into the stream directly without any temporary files, so you can load any movie "on-the-fly" from any supported source. For example, put one or more flash movie(s) in the resource section of your application.

Here is an example of how to load a flash movie from the resource:

{$RESOURCE 'res\movie.res'}
// contents of movie.rc file:
//
EmbeddedMovie FLASH "demo.swf"
...

procedure TMyForm.FormCreate(Sender: TObject);
 var
  ResourceStream: TResourceStream;
begin
  ResourceStream := TResourceStream.Create(0, 'EmbeddedMovie', 'FLASH');
  FlashPlayerControl1.PutMovieFromStream(ResourceStream);
end;

Here is another example created with SWF SDK:

var
 Movie: TFlashMovie;
 MS: TMemoryStream;
begin
 Movie := TFlashMovie.Create(0, 0, 400*twips, 300*twips, 10);
...
 Movie.ShowFrame;
 Movie.MakeStream;
 MS := TMemoryStream.Create;
 Movie.SaveToStream(MS);
 Movie.Free;
 FlashPlayerControl.PutMovieFromStream(MS);
 MS.free;
end;

Discuss TFlashPlayerControl in the forum.

Download TFlashPlayerControl

to top

Copyright 2004-2008 FeatherySoft, Inc. All rights reserved
Delphi is a trademark of Borland Software Corporation
Macromedia and Shockwave Flash are trademarks of Macromedia, Inc