我想在 ActiveX 控件中渲染视频(不在弹出的 DirectShow 窗口中)。我有:
IID_IVMRWindowlessControl
IID_IVMRFilterConfig9
CLSID_VideoMixingRenderer9
我想设置 WindowLess 模式,但我不知道如何获得...的 HWND,究竟是什么?IEFrame,HTML元素?
hr = pWc->SetVideoClippingWindow(???);
有人有一些提示吗?
问候。
我想在 ActiveX 控件中渲染视频(不在弹出的 DirectShow 窗口中)。我有:
IID_IVMRWindowlessControl
IID_IVMRFilterConfig9
CLSID_VideoMixingRenderer9
我想设置 WindowLess 模式,但我不知道如何获得...的 HWND,究竟是什么?IEFrame,HTML元素?
hr = pWc->SetVideoClippingWindow(???);
有人有一些提示吗?
问候。
首先,将其添加到 ActiveX 控件的构造函数中:
// this seemingly innocent line is _extremely_ important.
// This causes the window for the control to be created
// otherwise, you won't get an hWnd to render to!
m_bWindowOnly = true;
您的 ActiveX 控件将有一个名为 m_hWnd 的成员变量,您可以将其用作呈现目标。如果没有将 m_bWindowOnly 变量设置为 true,ActiveX 控件将不会创建自己的窗口。
最后,选择您的渲染器(例如 VMR9)
CRect rcClient;
CComPtr<IBaseFilter> spRenderer;
CComPtr<IVMRWindowlessControl9> spWindowless;
// Get the client window size
::GetClientRect(m_hWnd, rcClient);
// Get the renderer filter
spRenderer.Attach( m_pGraph->GetVideoRenderer() );
if( ! spRenderer )
return E_POINTER;
spWindowless = spRenderer;
if( spWindowless )
{
spWindowless->SetVideoClippingWindow( m_hWnd );
spWindowless->SetVideoPosition(NULL, rcClient);
spWindowless.Release();
}
spRenderer.Detach();
请注意,我的图形对象是一个自定义对象,GetVideoRenderer() 是我自己的函数之一 - 它返回一个 IBaseFilter*。
我花了很长时间才找到这个。ATL 的文档记录很差,这很遗憾,因为它是一项出色的技术。无论如何,希望这会有所帮助!
freefallr 的信息非常有帮助,但我认为它不能完全回答您的问题。无窗口activex控件的诀窍是您没有窗口。当你绘制时,你基本上会得到一个设备上下文,你必须响应来自浏览器的调用,并且只有在它告诉你时才绘制。
所需的接口在这里:http: //msdn.microsoft.com/en-us/library/ms682300%28v=VS.85%29.aspx
更多信息在这里:http: //msdn.microsoft.com/en-us/library/aa751970%28VS.85%29.aspx#OC96_and_Windowless_
一段时间以来,我们一直打算在 FireBreath (http://firebreath.org) 中添加对此的支持;我们在所有 npapi 浏览器中都支持它,但看起来我们(还)不支持 IE。如果您发现更多详细信息,请在此处发布摘要 =]