Play Flash Video (FLV) from a Stream

F-IN-BOX allows applications to play Flash Video (FLV) files directly from memory, from external files, or from embedded resources.
No temporary files are created — all content is streamed directly from memory. This enables scenarios such as embedding and encrypting FLV files inside an application’s resources, improving portability and security.

A Flash movie should request video from a custom (private) URL, such as http://FLV/FlashVideo.flv:

var netConn:NetConnection = new NetConnection();
netConn.connect(null);
 
var netStream:NetStream = new NetStream(netConn);
my_video.attachVideo(netStream);
 
netStream.setBufferTime(0);
netStream.play("http://FLV/FlashVideo.flv");

When Flash requests the FLV, F-IN-BOX intercepts the URL and provides the video content. Use the global handler FPC_AddOnLoadExternalResourceHandler to supply the FLV stream.

HFPC hFPC = FPC_LoadRegisteredOCX();
 
FPC_AddOnLoadExternalResourceHandler(hFPC, &GlobalOnLoadExternalResourceHandler, 0);
 
HRESULT WINAPI StaticGlobalOnLoadExternalResourceHandler(
    LPCTSTR lpszURL, 
    IStream** ppStream, 
    HFPC hFPC, 
    LPARAM lParam)
{
    HRESULT hr = E_FAIL;
 
    if (0 == lstrcmpi(lpszURL, _T("http://FLV/FlashVideo.flv")))
    {
        // Provide FLV video from embedded resource
        HMODULE hModule = GetModuleHandle(NULL);
        HRSRC hResInfo = FindResource(hModule, _T("EMBEDDED_FLV"), _T("FLV"));
        HGLOBAL hResData = LoadResource(hModule, hResInfo);
        LPCVOID lpData = LockResource(hResData);
        DWORD dwSize = SizeofResource(hModule, hResInfo);
 
        ULONG nWritten;
        (*ppStream)->Write(lpData, dwSize, &nWritten);
 
        hr = S_OK;
    }
 
    return hr;
}

With this approach, FLV playback works seamlessly without relying on file system access. All video content can be delivered securely from memory or embedded resources, ensuring applications remain portable and protected.