c++调用flash播放器

第一步:加载flash播放器

1.在窗口中创建CAxwindow

     CAxwindow  axWnd;

axWnd.Create(hParent, rect, 0, WS_CHILD|WS_CLIPCHILDREN, 0, ID_CHILD_CONTROL) != NULL )//WS_VISIBLE|默认不可见
axWnd.MoveWindow(lpRcInParent);

2.获取IAxWinHostWindow接口
CComPtr spHost;
axWnd.QueryHost(&spHost);

3.加载flash创建ShockwaveFlashObjects::IShockwaveFlash指针

hFlashDLL = CoLoadLibrary(wszModulePath, FALSE);

typedef HRESULT (__stdcall * PFNDllGetClassObject)(REFCLSID, REFIID, LPVOID*);
PFNDllGetClassObject pfnGetClassObj = (PFNDllGetClassObject)GetProcAddress(m_hFlashDLL, "DllGetClassObject");
CComPtr spClsFactory;
pfnGetClassObj(ShockwaveFlashObjects::CLSID_ShockwaveFlash, __uuidof(IClassFactory), (void**)&spClsFactory);

CComPtr spFlashPlayer
spClsFactory->CreateInstance(NULL, ShockwaveFlashObjects::IID_IShockwaveFlash, &spFlashPlayer);
4.attach flash控件到窗口

spHost->AttachControl(spFlashPlayer, axWnd.m_hWnd);

5.设置窗口背景

spFlashPlayer->put_BackgroundColor(0);
spFlashPlayer->put_BGColor(0);
6
.加载视频地址

spFlashPlayer->LoadMovie(0, m_sSWFUrl);

第二步:响应播放器消息

ShockwaveFlashObjects::_IShockwaveFlashEvents

响应invoke消息

CFlashPlayer : public ShockwaveFlashObjects::_IShockwaveFlashEvents

BEGIN_COM_MAP(CFlashPlayer)
COM_INTERFACE_ENTRY(IDispatch)

END_COM_MAP()

你可能感兴趣的:(c/c++)