Load Flash Movies from Memory Without Temporary Files
By default, the Flash Player ActiveX control can only load movies from files or URLs. A common workaround is to save a movie from an application's resources to a temporary file, pass its path to the ActiveX control, and then delete it. This approach is inconvenient, requires file system permissions, and may expose movies to unauthorized access.
TFlashPlayerControl provides a different mechanism. It allows Flash movies to be loaded directly from memory streams (such as TResourceStream
, TMemoryStream
, etc.) without creating temporary files. This simplifies deployment and improves security, as movies never need to be written to disk.
To load a Flash movie from a stream, use the LoadMovieFromStream or PutMovieFromStream methods. For example, Flash movies can be embedded into an application's resources and loaded at runtime.
Delphi Example
{$RESOURCE 'res\movie.res'}
// ...
type
TMainForm = class(TForm)
FlashPlayerControl1: TFlashPlayerControl;
// ...
end;
// ...
procedure TMainForm.FormCreate(Sender: TObject);
var
ResourceStream: TResourceStream;
begin
ResourceStream := TResourceStream.Create(0, 'EmbeddedMovie', 'FLASH');
FlashPlayerControl1.PutMovieFromStream(ResourceStream);
ResourceStream.Free;
end;
C++Builder Example
#pragma resource "res\\movie.res"
...
class TMainForm : public TForm
{
__published:
void __fastcall FormCreate(TObject *Sender);
// ...
};
// ...
void __fastcall TMainForm::FormCreate(TObject *Sender)
{
TResourceStream* ResourceStream = new TResourceStream(0, "EmbeddedMovie", "FLASH");
FlashPlayerControl1->PutMovieFromStream(ResourceStream);
delete ResourceStream;
}