November 08, 2024, 04:37:05 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


ShockWave Flash Demo

Started by JR, April 18, 2006, 07:10:39 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

JR

Uses ATL to embed an instance of ShockWave Flash in a window and plays a movie.

An small video is provided in the attached zipped file for testing purposes.


#use "atl.lib"
#use "uuid.lib"

struct GUID,1
{
  unsigned int data1;
  unsigned word data2;
  unsigned word data3;
  unsigned byte data4[8];
}

extern _IID_IDispatch as GUID;

interface IUnknown
{
    declare virtual QueryInterface(GUID *riid, void *ppvObject), int;
    declare virtual AddRef(), unsigned int;
    declare virtual Release(), unsigned int;
}

interface IDispatch : IUnknown
{
    declare virtual GetTypeInfoCount(unsigned int *pctinfo),int;
    declare virtual GetTypeInfo(unsigned int iTInfo, int lcid, pointer *ppTInfo),int;
    declare virtual GetIDsOfNames(GUID *riid, unsigned word *rgszNames, unsigned int cNames, int lcid, int *rgDispID),int;
    declare virtual Invoke(int dispIdMember, GUID *riid, int lcid, unsigned word wFlags, pointer *pDispParams, pointer *pVarResult, pointer *pExcepInfo, unsigned int *puArgErr),int;
}

interface IShockwaveFlash : IDispatch
{
    declare virtual get_ReadyState(int *pVal), int;
    declare virtual get_TotalFrames(int *pVal), int;
    declare virtual get_Playing(word *pVal), int;
    declare virtual put_Playing(word pVal), int;
    declare virtual get_Quality(int *pVal), int;
    declare virtual put_Quality(int pVal), int;
    declare virtual get_ScaleMode(int *pVal), int;
    declare virtual put_ScaleMode(int pVal), int;
    declare virtual get_AlignMode(int *pVal), int;
    declare virtual put_AlignMode(int pVal), int;
    declare virtual get_BackgroundColor(int *pVal), int;
    declare virtual put_BackgroundColor(int pVal), int;
    declare virtual get_Loop(word *pVal), int;
    declare virtual put_Loop(word pVal), int;
    declare virtual get_Movie(/*BSTR*/ pointer *pVal), int;
    declare virtual put_Movie(/*BSTR*/ pointer *pVal), int;
    declare virtual get_FrameNum(int *pVal), int;
    declare virtual put_FrameNum(int pVal), int;
    declare virtual SetZoomRect(int left, int top, int right, int bottom), int;
    declare virtual Zoom(int factor), int;
    declare virtual Pan(int x, int y, int mode), int;
    declare virtual Play(), int;
    declare virtual Stop(), int;
    declare virtual Back(), int;
    declare virtual Forward(), int;
    declare virtual Rewind(), int;
    declare virtual StopPlay(), int;
    declare virtual GotoFrame(int FrameNum), int;
    declare virtual CurrentFrame(int *FrameNum), int;
    declare virtual IsPlaying(word *Playing), int;
    declare virtual PercentLoaded(int *percent), int;
    declare virtual FrameLoaded(int FrameNum, word *loaded), int;
    declare virtual FlashVersion(int *version), int;
    declare virtual get_WMode(/*BSTR*/ pointer *pVal), int;
    declare virtual put_WMode(/*BSTR*/ pointer *pVal), int;
    declare virtual get_SAlign(/*BSTR*/ pointer *pVal), int;
    declare virtual put_SAlign(/*BSTR*/ pointer *pVal), int;
    declare virtual get_Menu(word *pVal), int;
    declare virtual put_Menu(word pVal), int;
    declare virtual get_Base(/*BSTR*/ pointer *pVal), int;
    declare virtual put_Base(/*BSTR*/ pointer *pVal), int;
    declare virtual get_Scale(/*BSTR*/ pointer *pVal), int;
    declare virtual put_Scale(/*BSTR*/ pointer *pVal), int;
    declare virtual get_DeviceFont(word *pVal), int;
    declare virtual put_DeviceFont(word pVal), int;
    declare virtual get_EmbedMovie(word *pVal), int;
    declare virtual put_EmbedMovie(word pVal), int;
    declare virtual get_BGColor(/*BSTR*/ pointer *pVal), int;
    declare virtual put_BGColor(/*BSTR*/ pointer *pVal), int;
    declare virtual get_Quality2(/*BSTR*/ pointer *pVal), int;
    declare virtual put_Quality2(/*BSTR*/ pointer *pVal), int;
    declare virtual LoadMovie(int layer, /*BSTR*/ pointer *url), int;
    declare virtual TGotoFrame(/*BSTR*/ pointer *target, int FrameNum), int;
    declare virtual TGotoLabel(/*BSTR*/ pointer *target, /*BSTR*/ pointer *plabel), int;
    declare virtual TCurrentFrame(/*BSTR*/ pointer *target, int *FrameNum), int;
    declare virtual TCurrentLabel(/*BSTR*/ pointer *target, /*BSTR*/ pointer *pVal), int;
    declare virtual TPlay(/*BSTR*/ pointer *target), int;
    declare virtual TStopPlay(/*BSTR*/ pointer *target), int;
    declare virtual SetVariable(/*BSTR*/ pointer *name, /*BSTR*/ pointer *value), int;
    declare virtual GetVariable(/*BSTR*/ pointer *name, /*BSTR*/ pointer *pVal), int;
    declare virtual TSetProperty(/*BSTR*/ pointer *target, int property, /*BSTR*/ pointer *value), int;
    declare virtual TGetProperty(/*BSTR*/ pointer *target, int property, /*BSTR*/ pointer *pVal), int;
    declare virtual TCallFrame(/*BSTR*/ pointer *target, int FrameNum), int;
    declare virtual TCallLabel(/*BSTR*/ pointer *target, /*BSTR*/ pointer *plabel), int;
    declare virtual TSetPropertyNum(/*BSTR*/ pointer *target, int property, double value), int;
    declare virtual TGetPropertyNum(/*BSTR*/ pointer *target, int property, double *pVal), int;
    declare virtual TGetPropertyAsNumber(/*BSTR*/ pointer *target, int property, double *pVal), int;
    declare virtual get_SWRemote(/*BSTR*/ pointer *pVal), int;
    declare virtual put_SWRemote(/*BSTR*/ pointer *pVal), int;
    declare virtual get_FlashVars(/*BSTR*/ pointer *pVal), int;
    declare virtual put_FlashVars(/*BSTR*/ pointer *pVal), int;
    declare virtual get_AllowScriptAccess(/*BSTR*/ pointer *pVal), int;
    declare virtual put_AllowScriptAccess(/*BSTR*/ pointer *pVal), int;
    declare virtual get_MovieData(/*BSTR*/ pointer *pVal), int;
    declare virtual put_MovieData(/*BSTR*/ pointer *pVal), int;
    declare virtual get_InlineData(IUnknown *ppIUnknown), int;
    declare virtual put_InlineData(IUnknown pIUnknown), int;
    declare virtual get_SeamlessTabbing(word *pVal), int;
    declare virtual put_SeamlessTabbing(word pVal), int;
}

import unsigned int CreateWindowEx alias CreateWindowExA(
  unsigned int dwExStyle,
  unsigned byte *lpClassName,
  unsigned byte *lpWindowName,
  unsigned int dwStyle,
  int x,
  int y,
  int nWidth,
  int nHeight,
  unsigned int hWndParent,
  unsigned int hMenu,
  unsigned int hInstance,
  void *lpParam
);

import unsigned int GetModuleHandle alias GetModuleHandleA(unsigned byte *lpModuleName);
import int MoveWindow(unsigned int hWnd, int X, int Y, int nWidth, int nHeight, int bRepaint);
import void RtlZeroMemory(void *Destination, unsigned int Length);

import int MultiByteToWideChar(
  unsigned int CodePage,          // code page
  unsigned int dwFlags,           // character-type options
  unsigned byte *lpMultiByteStr,  // string to map
  int cbMultiByte,                // number of bytes in string
  unsigned word *lpWideCharStr,   // wide-character buffer
  int cchWideChar                 // size of buffer
);

import int WideCharToMultiByte(
  unsigned int CodePage,            // code page
  unsigned int dwFlags,             // performance and mapping flags
  unsigned word *lpWideCharStr,     // wide-character string
  int cchWideChar,                  // number of chars in string.
  unsigned byte *lpMultiByteStr,    // buffer for new string
  int cbMultiByte,                  // size of buffer
  unsigned byte *lpDefaultChar,     // default for unmappable chars
  unsigned int *lpUsedDefaultChar   // set when default char used
);

import pointer SysAllocString(pointer *sz);
import void SysFreeString(pointer *bstr);
import unsigned int SysStringLen(pointer *bstr);
import int lstrlenW(unsigned word *lpwcs);

sub AnsiToUnicode(string psz), heap
{
    int hr;
    int nLen;
    pointer pwcs;

    nLen = (len(psz) + 1) * 2;
    pwcs = AllocHeap(nLen);
    RtlZeroMemory(pwcs, nLen);
    hr = MultibyteToWideChar(0, 0, psz, len(psz), pwcs, nLen);
    return pwcs;
}

sub UnicodeToAnsi(pointer *pwcs), string
{
    int nLen;
    pointer psz;

    nLen = lstrlenW(pwcs);
    psz = AllocHeap(nLen);
    RtlZeroMemory(psz, nLen);
    nLen = WideCharToMultibyte(0, 0, pwcs, -1, psz, nLen, 0, 0);
    return psz;
}

import int AtlAxWinInit();
import int AtlAxGetControl(unsigned int hWnd, IUnknown *pUnk);

// TestFlash definition
class TestFlash : CWindow
{
    declare virtual OnClose(),int;
    declare virtual OnCreate(),int;
    declare virtual OnSize(int nType,int cx,int cy),int;
    unsigned int m_ctl;
}

global sub main()
{
    TestFlash win;
    win.Create(0, 0, 600, 400,
               AWS_VISIBLE|AWS_SYSMENU|AWS_SIZE|AWS_MINIMIZEBOX| \
               AWS_MAXIMIZEBOX|AWS_AUTODRAW|AWS_CLIPCHILDREN,
               0, "Test Shockwave Flash", null);

    unsigned int hInst;
    hInst = GetModuleHandle(null);

    AtlAxWinInit();  // Initialize ATL
    rc = win.GetClientRect();
    win.m_ctl = CreateWindowEx (0, "AtlAxWin", "ShockwaveFlash.ShockwaveFlash",
                                AWS_VISIBLE|AWS_CHILD|AWS_BORDER,
                                rc.left + 5, rc.top + 5,
                                rc.right - rc.left - 10, rc.bottom - rc.top - 10,
                                win.m_hwnd,
                                1, // control id
                                hInst,
                                null);

    int hr = 0;
    IUnknown *pUnk = null;
    IShockwaveFlash *pFlash = null;

    // Obtains a direct interface pointer to the control contained
    // inside a specified window given its handle.
    hr = AtlAxGetControl(win.m_ctl, &pUnk);
    if (hr = 0)
    {
        // Obtains the dispatch interface pointer of the control
        hr = pUnk->QueryInterface(_IID_IDispatch, &pFlash);
        // Release the IUnknown pointer (no longer needed)
        pUnk->Release();
        if (hr = 0)
        {
            // Set the path of the movie (must be a fully qualified path)
            pbstrPath = SysAllocString(AnsiToUnicode(GetStartPath() + "choudanse7.swf"));
            pFlash->put_Movie(pbstrPath);
            SysFreeString(pbstrPath);
            // Rotate the video
//            pbstrName = SysAllocString(AnsiToUnicode("_rotation"));
//            pbstrValue = SysAllocString(AnsiToUnicode("10"));
//            pFlash->SetVariable(pbstrName, pbstrValue);
//            SysFreeString(pbstrName);
//            SysFreeString(pbstrValue);
            // Modify the video transparency
//            pbstrName = SysAllocString(AnsiToUnicode("_alpha"));
//            pbstrValue = SysAllocString(AnsiToUnicode("50"));
//            pFlash->SetVariable(pbstrName, pbstrValue);
//            SysFreeString(pbstrName);
//            SysFreeString(pbstrValue);
            // Modify the scale and position
//            pbstrName = SysAllocString(AnsiToUnicode("_xscale"));
//            pbstrValue = SysAllocString(AnsiToUnicode("50"));
//            pFlash->SetVariable(pbstrName, pbstrValue);
//            SysFreeString(pbstrName);
//            SysFreeString(pbstrValue);
//            pbstrName = SysAllocString(AnsiToUnicode("_yscale"));
//            pbstrValue = SysAllocString(AnsiToUnicode("50"));
//            pFlash->SetVariable(pbstrName, pbstrValue);
//            SysFreeString(pbstrName);
//            SysFreeString(pbstrValue);
//            pbstrName = SysAllocString(AnsiToUnicode("_x"));
//            pbstrValue = SysAllocString(AnsiToUnicode("80"));
//            pFlash->SetVariable(pbstrName, pbstrValue);
//            SysFreeString(pbstrName);
//            SysFreeString(pbstrValue);
//            pbstrName = SysAllocString(AnsiToUnicode("_y"));
//            pbstrValue = SysAllocString(AnsiToUnicode("40"));
//            pFlash->SetVariable(pbstrName, pbstrValue);
//            SysFreeString(pbstrName);
//            SysFreeString(pbstrValue);
            // Play the movie
            pFlash->Play();
            // Release the interface
            pFlash->Release();
        }
    }

    do{ wait();} until !win.IsValid();
}

TestFlash::OnCreate()
{
    CenterWindow();
    return 0;
}

TestFlash::OnClose()
{
    Destroy();
    return 0;
}

TestFlash::OnSize(int nType,int cx,int cy),int
{
    if (m_ctl != 0)
    {
        rc = GetClientRect();
        MoveWindow(m_ctl, rc.left + 5, rc.top + 5, rc.right - rc.left - 10, rc.bottom - rc.top - 10, true);
    }
    return true;
}

Ionic Wind Support Team

You can also use AddControlEx and create a bound control that is directly compatible with Aurora's windows too.


win.AddControlEx("AtlAxWin", "ShockwaveFlash.ShockwaveFlash", rc.left + 5, rc.top + 5,
                                rc.right - rc.left - 10, rc.bottom - rc.top - 10,AWS_VISIBLE|AWS_CHILD|AWS_BORDER,0,1);

Ionic Wind Support Team

Mkey

Hello,

Really interresting.

Did you try to set the Wmode to transaparent????

I would like to have a transparent movie.

Thanks.

JR

The put_WMode property is not available at run-time. You will need to create an stream, fill it with the name and value of the property and create the controll with AtlAxCreateControl, one of whose parameters is a pointer to an stream that is used to initialize the properties of the control. To create an stream is easy, but currently I don't have precise information of how exactly the information has to be written in it to work.

Mkey

Quote from: JosÃÆ'Ã,© Roca on May 21, 2006, 09:10:43 AM
The put_WMode property is not available at run-time. You will need to create an stream, fill it with the name and value of the property and create the controll with AtlAxCreateControl, one of whose parameters is a pointer to an stream that is used to initialize the properties of the control. To create an stream is easy, but currently I don't have precise information of how exactly the information has to be written in it to work.


It s something I search for since a long time ago. I search too how to read with flash control a movie only from stream without have it on the disk for example to read it from a database blobstream ...
I wasn't able to do it with Delphi. I'm new with Aurora, (or C++).

If you have any information or links (all you have C++, ..., too) please post it.

Thanks a lot.

Pip1957

Would it be possible for someone to convert this program to Ebasic

Pip1957


sapero

November 30, 2008, 08:47:42 AM #7 Last Edit: November 30, 2008, 08:49:14 AM by sapero
Hey Pip, here is your code for Emergence 8)

Pip1957

As always Sapero you the best ;D

Pip1957

Sapero thank you for the code at the moment it is way over my head, would it be possible to rewrite it without using classes what I need is to be able to open a flash control or window in a dialog that would close by button and leave the dialog open, again thank you for the code will keep studying it.

sapero

Sure, but you can convert it too, just move code from method into window handler case.

Pip1957

Thank you sapero this I can understand :D

pistol350

LOL.
I can confirm that it's easier to understand now  ;D
Regards,

Peter B.