Wednesday, April 04, 2007

Simple program to Play the file

#include
#include

#pragma comment(lib,"strmiids")
//load the strmiids.lib

void PlayFile()
{
IGraphBuilder* pGraph = NULL;
IMediaControl* pControl = NULL;
IMediaEvent* pEvent = NULL;

HRESULT hr = S_OK;

hr = CoInitialize(NULL);

if(FAILED(hr))
{
printf("\n Could not initialize the COM runtime library");
return;
}

hr = CoCreateInstance(CLSID_FilterGraph,NULL,CLSCTX_INPROC_SERVER,IID_IFilterGraph,(void**)&pGraph);

if(FAILED(hr))
{
printf("\n Error in CoCreateInstance() fn");
return;
}


hr = pGraph->QueryInterface(IID_IMediaControl,(void**)&pControl);
hr = pGraph->QueryInterface(IID_IMediaEvent,(void**)&pEvent);


hr = pGraph->RenderFile(L"D:\\profile\\avi\\cardriving.wmv",NULL);

if(SUCCEEDED(hr))
{
//Run the Graph...
hr = pControl->Run();

if(SUCCEEDED(hr))
{
long evCode;
pEvent->WaitForCompletion(INFINITE,&evCode);


}
}


pControl->Release();
pEvent->Release();
pGraph->Release();

CoUninitialize();

}

int main(int argc, char* argv[])
{
PlayFile();
return 0;
}

Labels:

0 Comments:

Post a Comment

<< Home