Microsoft DirectX 8.1 (C++) |
To preview a project, first call CoCreateInstance to create an instance of the Basic Render Engine. The class identifier is CLSID_RenderEngine. Then call the IRenderEngine::SetTimelineObject method to specify the timeline that you are rendering.
The first time that you preview the timeline, perform the following calls in the order listed:
The following code example shows these steps:
IRenderEngine *pRender = NULL;
hr = CoCreateInstance(CLSID_RenderEngine, NULL,
CLSCTX_INPROC_SERVER, IID_IRenderEngine, (void**)&pRender);
hr = pRender->SetTimelineObject(pTL);
hr = pRender->ConnectFrontEnd();
hr = pRender->RenderOutputPins();
Now run the filter graph. First, call the IRenderEngine::GetFilterGraph method to retrieve a pointer to the Filter Graph Manager's IGraphBuilder interface. Then query the Filter Graph Manager for the IMediaControl interface and call IMediaControl::Run, as shown in the following code:
IGraphBuilder *pGraph = NULL;
IMediaControl *pControl = NULL;
hr = pRender->GetFilterGraph(&pGraph);
hr = pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl);
hr = pControl->Run();
Use the Filter Graph Manager's IMediaEventEx interface to wait for the preview to complete. You can also seek the graph using the Filter Graph Manager's IMediaSeeking interface, just as you would with a file playback graph.
To preview the project again, seek the graph back to time zero and call Run again. If you change the contents of the timeline, do the following:
The following example shows these steps:
hr = pRender->ConnectFrontEnd();
if (hr == S_WARN_OUTPUTRESET)
{
hr = pRender->RenderOutputPins();
}
LONGLONG llStart = 0;
hr = pSeek->SetPositions(&llStart, AM_SEEKING_AbsolutePositioning, 0, 0);
hr = pControl->Run();
For a complete example that loads and previews a project file, see Loading and Previewing a Project.
See Also