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();
|