Click here to Skip to main content
11,495,493 members (63,126 online)
Rate this: bad
good
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)
#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()
{
    // Disregard if we don't have an IMediaEventEx pointer.
    if (g_pEvent == NULL)
    {
        return;
    }
    // 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:
            CleanUp();
            PostQuitMessage(0);
            return;
        }
    } 
}

// Disable event notification before releasing the graph.
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.
Posted 30-Dec-12 22:48pm
Comments
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
good
Please Sign up or sign in to vote.

Solution 1

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

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

  Print Answers RSS
0 Dnyaneshwar@Pune 692
1 CHill60 318
2 Sascha Lefèvre 265
3 Nakul Chaudhari 236
4 OriginalGriff 191
0 Sergey Alexandrovich Kryukov 10,322
1 OriginalGriff 8,821
2 Sascha Lefèvre 3,889
3 Maciej Los 3,422
4 Richard Deeming 2,560


Advertise | Privacy | Mobile
Web03 | 2.8.150520.1 | Last Updated 2 Jan 2013
Copyright © CodeProject, 1999-2015
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