Using DirectShow to Control Flow of a Program

I am having trouble understanding what I need to do to halt the flow of a program until a video file finishes playing. So far I have accomplished getting the video to play, but the program continues while the video is playing rendering the content of the program on top of the video making it not seen.

My goal is to make the video play, then once it has finished the rest of the program should run.

So far I have this in the start up area of my code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//Initialize components for DirectShow to stream a video at start-up
CoInitialize(NULL);

//creates filter graph manager
CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC, IID_IGraphBuilder, (void**)&p_Graph); //CLSCTX_INPROC_SERVER works as well

//???
p_mEventEx = NULL;

//query COM interface
p_Graph->QueryInterface(IID_IMediaControl, (void**)&p_mControl);
p_Graph->QueryInterface(IID_IMediaEvent, (void**)&p_mEvent);
p_Graph->QueryInterface(IID_IMediaEventEx, (void**)&p_mEventEx);
p_mEventEx->SetNotifyWindow((OAHWND)hWnd, WM_GRAPHNOTIFY, 0); //designates hWnd as the recipient of message
p_Graph->QueryInterface(IID_IVideoWindow, (void**)&p_Window);

//RenderFile() builds the filter graph which lets us stream video files
p_Graph->RenderFile(L"Intro.wmv", NULL);

//set the parent window
p_Window->put_Owner((OAHWND)hWnd);

//set the child window
p_Window->put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS);

//set the child to this position
p_Window->SetWindowPosition(0, 0, rect.right, rect.bottom);

//run video file
p_mControl->Run();


After this code runs once, the program proceeds immediately into the loop where my update and render functions for the program runs. Preferably, I want to stop just the render function while allowing the update to continue to check if the user presses a key to skip the video. What do I need to add to the code to do this?
Last edited on
Solved this through adding a boolean var to check if the video has finished playing from my HandleGraphEvent() function. I threw my Render() and Update() functions inside an if() statement to not play unless the boolean var is true.

I read that this can also be solved through using a FSM, anyone care to shed some light on that approach?
Topic archived. No new replies allowed.