Click here to Skip to main content
Rate this: bad
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 22:48pm
J.Surjith Kumar at 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
0 George Jonsson 215
1 Kornfeld Eliyahu Peter 169
2 OriginalGriff 120
3 PIEBALDconsult 110
4 Zoltán Zörgő 99
0 OriginalGriff 6,165
1 DamithSL 4,658
2 Maciej Los 4,107
3 Kornfeld Eliyahu Peter 3,649
4 Sergey Alexandrovich Kryukov 3,342

Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 2 Jan 2013
Copyright © CodeProject, 1999-2014
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