Sign in to follow this  
Mantrid

DirectShow video playback in main window

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
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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this