Jump to content
  • Advertisement
Sign in to follow this  

Hang when looping video in DShow

This topic is 5042 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey guys. I am becoming extremely frustrated as to why I have a full 2 second hang when looping video with DirectShow. The video loops, it just hangs like crazy when resetting the position of the video. As of now, my test program is just checking to see; if HandleEvents() returns true, RestartVideo(). Any tips or problems you point out in my code would be greatly appreciated. Thanks in advance! p.s. The Invalidate() calls in both the PlayVideo() and RestartVideo() functions arent necessary, nor are the Stop() and Run() calls in the RestartVideo() function. Just there for piece of mind, and dont affect the hang. Current applicable functions:
void CDShowWrapper::PlayVideo()

	//	Video to be played.
	m_pGraphBuilder->RenderFile(L"Menu.m2v", NULL);

	//	Query for the Interfaces.
	m_pGraphBuilder->QueryInterface(IID_IVideoWindow, (void**)&m_pVideoWindow);
	m_pGraphBuilder->QueryInterface(IID_IMediaEventEx, (void**)&m_pMediaEventEx);
	m_pGraphBuilder->QueryInterface(IID_IMediaControl, (void**)&m_pMediaControl);
	m_pGraphBuilder->QueryInterface(IID_IMediaSeeking, (void**)&m_pMediaSeeking);

	//	Setup the Queried Interfaces.

	//	Give the Video Window some style.
	m_pVideoWindow->put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS);
	m_pVideoWindow->SetWindowPosition(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT);

	//	Setup the Event Handler.
	m_pMediaEventEx->SetNotifyWindow((OAHWND)m_main_hwnd, WM_GRAPHNOTIFY, 0);

	InvalidateRect(m_main_hwnd, NULL, false);

void CDShowWrapper::RestartVideo()
	LONGLONG pos = 0;

		m_pMediaSeeking->SetPositions(&pos, AM_SEEKING_AbsolutePositioning, &pos, AM_SEEKING_NoPositioning);
		InvalidateRect(m_main_hwnd, 0, 0);

bool CDShowWrapper::HandleEvents()
	HRESULT hr = 0;
	long lEvCode, lParam1, lParam2 = 0;

		return false;

	//	Peek from the Event Queue.
	hr = m_pMediaEventEx->GetEvent(&lEvCode, &lParam1, &lParam2, 0);

		//	Pop the event from the queue.
		m_pMediaEventEx->FreeEventParams(lEvCode, lParam1, lParam2);

		//	Check the Event Code.
			case EC_COMPLETE:
				return true;
		//	Peek for another event.
		hr = m_pMediaEventEx->GetEvent(&lEvCode, &lParam1, &lParam2, 0);
	return false;

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!