Click here to Skip to main content
12,551,157 members (51,658 online)
Rate this:
Please Sign up or sign in to vote.
See more: C++ C C# MFC
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))
      // Run the graph.
      hr = pControl->Run();
      if (SUCCEEDED(hr))
          // Wait for completion.
          long evCode;
          pEvent->WaitForCompletion(INFINITE, &evCode);
          // Note: Do not use INFINITE in a real application, because it
          // can block indefinitely.
It waits for the video to complete so i cant pause the playing video.
so i used (responding to event)

IMediaEventEx *g_pEvent = NULL;
g_pGraph->QueryInterface(IID_IMediaEventEx, (void **)&g_pEvent);
g_pEvent->SetNotifyWindow((OAHWND)g_hwnd, WM_GRAPHNOTIFY, 0);


void HandleGraphEvent()
    // Disregard if we don't have an IMediaEventEx pointer.
    if (g_pEvent == NULL)
    // Get all the events
    long evCode;
    LONG_PTR param1, param2;
    HRESULT hr;
    while (SUCCEEDED(g_pEvent->GetEvent(&evCode, &param1, &param2, 0)))
        g_pEvent->FreeEventParams(evCode, param1, param2);
        switch (evCode)
        case EC_COMPLETE:  // Fall through.
        case EC_USERABORT: // Fall through.
        case EC_ERRORABORT:

// Disable event notification before releasing the graph.
g_pEvent->SetNotifyWindow(NULL, 0, 0);
g_pEvent = NULL;

I commented the waitforcompletion method, it executed sucessfully but the video was not played.

Your suggestions are welcome.
Posted 30-Dec-12 21:48pm
J.Surjith Kumar 2-Jan-13 6:02am
The code which is above is the right code. I found out small mistake in my code and now it works as i expected.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

The code which i given above (Responding to event) is works well now.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.161021.1 | Last Updated 2 Jan 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100