Full screen playback using IVideoWindow

This page shows you how to do a fullscreen playback using directshow. Please note that error handling codes are omitted to keep the sample code simple.

Sample code

The following sample code shows how to do full screen playback.


#include <stdio.h>

#include <dshow.h>

// change here
#define	FILENAME L"c:\\DXSDK\\Samples\\Media\\butterfly.mpg"

int
main()
{
 IGraphBuilder *pGraphBuilder;
 IMediaControl *pMediaControl;
 IMediaEvent *pMediaEvent;
 long eventCode;
 IVideoWindow *pVideoWindow;

 CoInitialize(NULL);

 CoCreateInstance(CLSID_FilterGraph,
	NULL,
	CLSCTX_INPROC,
	IID_IGraphBuilder,
	(LPVOID *)&pGraphBuilder);

 pGraphBuilder->QueryInterface(IID_IMediaControl,
	(LPVOID *)&pMediaControl);

 pGraphBuilder->QueryInterface(IID_IMediaEvent,
	(LPVOID *)&pMediaEvent);

 pMediaControl->RenderFile(FILENAME);

 pGraphBuilder->QueryInterface(IID_IVideoWindow,
	(LPVOID *)&pVideoWindow);

 // Start Full Screen
 pVideoWindow->put_FullScreenMode(OATRUE);

 pMediaControl->Run();

 pMediaEvent->WaitForCompletion(-1, &eventCode);

 // End Full Screen
 pVideoWindow->put_FullScreenMode(OAFALSE);

 pVideoWindow->Release();
 pMediaEvent->Release();
 pMediaControl->Release();
 pGraphBuilder->Release();
 CoUninitialize();

 return 0;
}


You can trigger full screen mode by using IVideoWindow::put_FullScreenMode(OATRUE). To finish full screen mode, use IVideoWindow::put_FullScreeenMode(OAFALSE).

  

Copyright (C) GeekPage.JP. All rights reserved.