1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
void MainApp::playVideo()
{
HWND hwnd;
mWindow->getCustomAttribute("WINDOW",&hwnd);
//if (Root::getSingleton().getCurrentFrameNumber()%2==0) mWindow->update();
// Initialize COM
HRESULT hr = CoInitialize(NULL);
// Create a FilterGraph
hr = CoCreateInstance(CLSID_FilgraphManager, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&pGraphBuilder);
// Get MediaControl Interface
hr = pGraphBuilder->QueryInterface(IID_IMediaControl, (LPVOID *)&pMediaControl);
//create the videomixingrenderer
hr = CoCreateInstance(CLSID_VideoMixingRenderer9, NULL, CLSCTX_INPROC, IID_IBaseFilter, (void**)&pVmr);
hr = pGraphBuilder->AddFilter(pVmr, L"VMR9");
//get the config interface of the VMR9
hr = pVmr->QueryInterface(IID_IVMRFilterConfig9, (void**)&pConfig);
hr = pConfig->SetRenderingMode(VMRMode_Windowless);
//get the windowless controll
hr = pVmr->QueryInterface(IID_IVMRWindowlessControl9, (void**)&pWC);
//hr = pWC->SetVideoPosition(NULL, NULL);
RECT rect;
rect.top = 0;
rect.left = 0;
rect.bottom = mWindow->getHeight();
rect.right = mWindow->getWidth();
// set destination rectangle for the video
hr = pWC->SetVideoPosition(0, &rect);
// set the rendering window
hr = pWC->SetVideoClippingWindow(hwnd);
// open the file to be rendered
hr = pGraphBuilder->RenderFile(FILENAME,0);
//run the video
hr = pMediaControl->Run();
} |
Partager