OnLoadExternalResourceAsync
Syntax
Delphi
TFlashPlayerControlOnLoadExternalResourceAsync = procedure(
ASender: TObject;
const Path: WideString;
out Stream: TStream) of object;
OnLoadExternalResourceAsync: TFlashPlayerControlOnLoadExternalResourceAsync;
C++Builder
typedef Classes::TStream* *PTStream;
typedef void __fastcall (__closure *TFlashPlayerControlOnLoadExternalResourceAsync)(
System::TObject* ASender,
const WideString Path,
PTStream pStream);
Description
The OnLoadExternalResourceAsync event is raised when a Flash movie loaded from a TStream tries to load an FLV file using a relative path (for example: "/all_videos/somevideo.flv").
The handler should check the requested Path
and return a TStream that provides the FLV content.
Compared to other approaches:
- OnLoadExternalResource requires providing the entire resource immediately, which can freeze the application if the file is large.
- OnLoadExternalResourceEx allows asynchronous writing from a background thread, but Flash reserves memory equal to the file size, which is inefficient for large files.
- OnLoadExternalResourceAsync avoids both drawbacks. Flash uses the provided TStream directly and calls its .Seek and .Read methods as needed, without preloading or reserving large amounts of memory.
This makes OnLoadExternalResourceAsync the most efficient way to play large FLV files from a stream.
Note: For movies not loaded from a TStream, use SetGlobalOnLoadExternalResourceHandlerAsync.