wxMSW: wxMediaCtrl best size broken
Ryan Norton
wxprojects at comcast.net
Mon Oct 2 00:32:41 PDT 2006
> The wxAMMediaBackend is never getting a valid size for the video, and so
> GetBestSize is always returning (0,0). Anybody know why?
Not 100% sure of this, but I left a comment in the file about this
// Originally this was >= 3 here but on 3 we can't get the
// size of the video (will error) - however on 4
// it won't play on downloaded things until it is
// completely downloaded so we use the lesser of two evils...
Now that it is over a year later before I've even looked at the thing,
I think what I would have done is instead of
// Get the original video size
GetAM()->get_ImageSourceWidth((long*)&m_bestSize.x);
GetAM()->get_ImageSourceHeight((long*)&m_bestSize.y);
in wxAMMediaBackend::FinishLoad would be to make m_bestSize
initially wxDefaultSize as a sort of "bad" value.
This way, I could check it in wxAMMediaBackend::GetVideoSize
to see if it is still wxDefaultSize, and if it is still that then try to
get the original video size again, otherwise returning (0,0).
So, something like (not tested, in theory might work, and I
haven't really done much wx work in a long time, so perhaps
take it with a grain of salt :))
----
wxAMMediaBackend::wxAMMediaBackend()
:m_pAX(NULL),
#ifdef __WXWINCE__
m_pWMP(NULL),
#else
m_pAM(NULL),
m_pMP(NULL),
#endif
m_bestSize(wxDefaultSize)
----
wxSize wxAMMediaBackend::GetVideoSize() const
{
if(m_bestSize == wxDefaultSize)
{
// Get the original video size
GetAM()->get_ImageSourceWidth((long*)&m_bestSize.x);
GetAM()->get_ImageSourceHeight((long*)&m_bestSize.y);
if(m_bestSize == wxDefaultSize)
{
return wxSize(0,0);
}
}
return m_bestSize;
}
---------
Ideally, one would want to throw in an optimization or two
for the case where there is no actual video :), but hopefully
the general idea is there.
Also, this doesn't fix the fundamental problem of the video size
simply not being available on some files until they are fully loaded
(this isn't very desirable or, IIRC in some cases even possible,
when streaming from the internet for example). In the comment
above, "3" refers to a "ready to play" state and "4" refers to
"fully loaded"-style state.
The other windows version (Windows Media Player 10
interface) runs into basically the same problem, although it
uses a rather disjointed workaround of actually playing
the media before the load event is called (it then checks
to see if the end user/developer actually called Play() etc.,
and if not stops the media as to appear as if it never
played in the first place :DDD).
P.S. Now that I look at it a year later the code looks
nice and clean, although now I would have used
autopointers and RAII for exception safety...
More information about the wx-dev
mailing list