ramya Guest
|
Posted: Thu Feb 08, 2007 5:05 pm Post subject: play mp3 using DirectShow |
|
|
Hi All,
I'v jus started out using directshow and tried running a code to play
an mp3 file from the disk
directly.But it doesnt play mp3 files, it plays only wav files..can
anybody help plz.
heres the code fragment :
CoInitialize(NULL);
IGraphBuilder *pGraph = NULL;
IMediaControl *pControl = NULL;
IVideoWindow *pVW = NULL;
IMediaEvent *pEvent = NULL;
int err = 0;
CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,
IID_IGraphBuilder, (void **)&pGraph);
pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl);
pGraph->QueryInterface(IID_IMediaEvent, (void **)&pEvent);
pGraph->QueryInterface(IID_IVideoWindow, (void **)&pVW);
pGraph->RenderFile(L"\\Cuppy_Cake_Song.mp3", NULL);
// the below wav file is playing
//pGraph->RenderFile(L"\\jana_gana_mana.wav", NULL);
err = GetLastError();
pVW->put_Owner((OAHWND)handle);
pVW->put_Visible(OATRUE);
pVW->put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
RECT vwrect;
GetClientRect(handle,&vwrect);
//Set the Child to this position
pVW-
| Quote: | SetWindowPosition(0,0,vwrect.right,vwrect.bottom);
|
pControl->Run();
err = GetLastError();
long evCode;
pEvent->WaitForCompletion(INFINITE, &evCode);
pVW->put_Owner(NULL);
pControl->Release();
pEvent->Release();
pGraph->Release();
pVW->Release();
CoUninitialize(); |
|