georgiek50
asked on
Directshow does not repaint while a movie clip is paused.
I have made a little movie player box in a dialog I have, outputing the video to a static control. Everything works great except for when I pause the player and open a window over the application, when I make the app visible again, the video is gone and directshow does not repaint the paused frame. During playback everything works great. Here is the code that responds to events:
void cTrailerList::HandleGraphE vent(void)
{
// Function to take care of graph notication codes
long lCode, lParam1, lParam2;
LONGLONG pos = 0;
// If the IMediaEventEx pointer is NULL return
// to avoid an error
if ( cTrailer.pEvent == NULL )
return;
while ( SUCCEEDED(cTrailer.pEvent- >GetEvent( &lCode, &lParam1, &lParam2, 0)) )
{
cTrailer.pEvent->FreeEvent Params(lCo de, lParam1, lParam2);
switch(lCode)
{
case EC_COMPLETE:
// Reset to first frame of movie
cTrailer.pSeek->SetPositio ns(&pos, AM_SEEKING_AbsolutePositio ning ,
NULL, AM_SEEKING_NoPositioning);
return;
case EC_USERABORT:
case EC_ERRORABORT:
cTrailer.CleanUp();
return;
}
}
}
I have tried handling EC_REPAINT but with no success. I am somehow conviced it has to do with the static control but I can't find a workaround.
void cTrailerList::HandleGraphE
{
// Function to take care of graph notication codes
long lCode, lParam1, lParam2;
LONGLONG pos = 0;
// If the IMediaEventEx pointer is NULL return
// to avoid an error
if ( cTrailer.pEvent == NULL )
return;
while ( SUCCEEDED(cTrailer.pEvent-
{
cTrailer.pEvent->FreeEvent
switch(lCode)
{
case EC_COMPLETE:
// Reset to first frame of movie
cTrailer.pSeek->SetPositio
NULL, AM_SEEKING_NoPositioning);
return;
case EC_USERABORT:
case EC_ERRORABORT:
cTrailer.CleanUp();
return;
}
}
}
I have tried handling EC_REPAINT but with no success. I am somehow conviced it has to do with the static control but I can't find a workaround.
You will probably need to subclass CStatic and implement the OnDraw method so that it updates the CStatic window with the current buffer when WM_PAINT is called.
http://www.codeproject.com/wtl/mix_wtl_mfc.asp
This is a slightly akward example, but if you can get around the odd coding since it is a WTL to MFC conversion example, check out the project files, and then open the scrollwindow.cpp and .h for example in implementing the OnDraw method. ScrollWindow subclasses CStatic (and does a lot of other stuff).
I was actually looking at that for something else so it's the reason I'm giving it as the example. Hope it helps more than confuses.
This is a slightly akward example, but if you can get around the odd coding since it is a WTL to MFC conversion example, check out the project files, and then open the scrollwindow.cpp and .h for example in implementing the OnDraw method. ScrollWindow subclasses CStatic (and does a lot of other stuff).
I was actually looking at that for something else so it's the reason I'm giving it as the example. Hope it helps more than confuses.
ASKER
I have already subclassed the window to process the WM_PAINT message. I thought of doing something along the lines like you suggested, keep a track of the current frame and just paint it in when needed. I just wanted to see if this was the "proper" way to handle this situation because reading through MSDN it states that Directshow will handle the painting.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:
Accept: _corey_ {http:#9803126}
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
Tinchos
EE Cleanup Volunteer
I will leave the following recommendation for this question in the Cleanup topic area:
Accept: _corey_ {http:#9803126}
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
Tinchos
EE Cleanup Volunteer
All you have to do is check for a DEVICELOST return value, and then re-create the device the video is being displayed on. Or something like that.