Am trying to play the video with some of the basic controls included like play, pause and stop. If i use this code
if (SUCCEEDED(hr))
{
hr = pControl->Run();
if (SUCCEEDED(hr))
{
long evCode;
pEvent->WaitForCompletion(INFINITE, &evCode);
}
}
It waits for the video to complete so i cant pause the playing video.
so i used (responding to event)
#define WM_GRAPHNOTIFY WM_APP + 1
IMediaEventEx *g_pEvent = NULL;
g_pGraph->QueryInterface(IID_IMediaEventEx, (void **)&g_pEvent);
g_pEvent->SetNotifyWindow((OAHWND)g_hwnd, WM_GRAPHNOTIFY, 0);
case WM_GRAPHNOTIFY:
HandleGraphEvent();
break;
void HandleGraphEvent()
{
if (g_pEvent == NULL)
{
return;
}
long evCode;
LONG_PTR param1, param2;
HRESULT hr;
while (SUCCEEDED(g_pEvent->GetEvent(&evCode, ¶m1, ¶m2, 0)))
{
g_pEvent->FreeEventParams(evCode, param1, param2);
switch (evCode)
{
case EC_COMPLETE:
case EC_USERABORT:
case EC_ERRORABORT:
CleanUp();
PostQuitMessage(0);
return;
}
}
}
g_pEvent->SetNotifyWindow(NULL, 0, 0);
g_pEvent->Release();
g_pEvent = NULL;
I commented the waitforcompletion method, it executed sucessfully but the video was not played.
Your suggestions are welcome.