c++flashactivexocxshockwave

Flash ActiveX: How to Load Movie from memory or resource or stream?


I'm embedding a Flash ActiveX control in my C++ app (Flash.ocx, Flash10a.ocx, etc depending on your Flash version).

I can load an SWF file by calling LoadMovie(0, filename), but the file needs to physically reside in the disk. How to load the SWF from memory (or resource, or stream)? I'm sure there must be a way, because commercial solutions like f-in-box's feature Load flash movies from memory directly also uses Flash ActiveX control.


Solution

  • Appearantly I a going to need to supply details for a vote 'up'.. OK.

    The internal flash buffer when first initiailized indicates if a movie is loaded or if the buffer hold properties in the buffer fisrt four bytes.

    gUfU -- no movie loaded. properties to follow ....

    fUfU -- .. [4bytes] size as integer.

    then the UNCOMPRESSED movie or SWF as it were. Write a IStream class. fill with above. save as szFile

    TFlashStream *fStream = new TFlashStream(szFile);
    // QI flash player

    IPersistStreamInit * psStreamInit = 0;
    shock->QueryInterface(::IID_IPersistStreamInit,  
                         (LPVOID*)&psStreamInit);
    if(psStreamInit)
    {
        psStreamInit->InitNew();
        psStreamInit->Load(fStream);
        psStreamInit->Release();
    }
    delete fStream;
    

    Things to note : When psStreamInit->Load(fStream); will call IStream::Read looking for the header 'fUfU'.

    if the return is correct psStreamInit then calls IStream::Read for the buffer size.

    If everthing looks good so far, psStreamInit then reads in 1024 byte chunks until the read is exhausted. However. for the header and file size.

    STDMETHOD(Read)(void *pv, ULONG cb, ULONG *pcbRead)
    

    pcbRead is invalid. you may want to use something like IsBadReadPtr

    --

    Michael