Jump to content
  • Advertisement
Sign in to follow this  
Mantrid

DirectShow video playback in main window

This topic is 4785 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

ok so in my game engine i'm using directshow for mp3s and videos, and sound effects etc i'm thinking of using directsound so i can play more than one sound at any one time my videos are displaying ok in the main window, but not initially. the file will play but not actually display (ie you can hear audio but no video) until i give the window a nudge (moving it a bit so it redraws) and after that it works perfectly if you need me to post any code that's fine, but would this be more likely a win32 problem, a directshow problem etc? cheers for any help

Share this post


Link to post
Share on other sites
Advertisement
ok in a blatant act of bumping here's my play media function that sets it to the main window:

void CMedia::PlayMediaFile(WCHAR *filename)
{

HRESULT hr = m_graphBuilder->RenderFile(filename, NULL);
assert(!FAILED(hr));


// Get the video window
IVideoWindow *pVW = NULL;

hr=m_graphBuilder->QueryInterface(IID_IVideoWindow, (void **)&pVW);
assert(!FAILED(hr));

// Setup the video window to use our window handle
hr=pVW->put_Owner((OAHWND)hWnd);
assert(!FAILED(hr));

// Tell DirectShow how our window style is defined
hr=pVW->put_Windowstyle(WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
assert(!FAILED(hr));


// Get the size of the window
RECT rect;
GetClientRect(hWnd, &rect);

// Set the video size:
hr=pVW->SetWindowPosition(rect.left, rect.top, rect.right, rect.bottom);
assert(!FAILED(hr));

hr = m_mediaControl->Run();
assert(!FAILED(hr));

}



[Edited by - Coder on November 7, 2005 5:44:17 AM]

Share this post


Link to post
Share on other sites
Try calling InvalidateRect( hWnd, NULL) before m_mediaControl->Run()

That should redraw the window just before the video is played.

Share this post


Link to post
Share on other sites
I have no idea how to do it in c#.
You should probably create a new topic asking how to force a window to redraw itself in c# because not many people know directshow and so not many people will be reading this.

Godd luck

Share this post


Link to post
Share on other sites
well not necessarily redrawing the window, more playing a video in the same window as your game is.... with audiovideoplayback in managed it makes a whole new window for the video

Share this post


Link to post
Share on other sites
Quote:
Original post by anvil
well not necessarily redrawing the window, more playing a video in the same window as your game is.... with audiovideoplayback in managed it makes a whole new window for the video


yeah it does it in the same window now (how annoying is that new window thing?) it just wont actually draw the video till you give it a nudge :(

Share this post


Link to post
Share on other sites
SUCCESS!!!

just in case anyone wants to know, the correct answer was:

not to set a background colour for your main window in winmain, for some reason i got that as a bit of a footnote in an entry of the MADN entitled "Using Windowless Mode with the VMR" cos i was bored after 3 days of tireless searching and clicked on random entries :-/

so just commenting out:

wcex.hbrBackground= (HBRUSH)(COLOR_WINDOW+1);

did the trick 15 attempts out of 15 (for some reason it would work about 1 or 2 attempts out of 15)

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!