Group:  English: Entertainment ยป microsoft.public.windowsmedia.sdk
Thread: Size of media item

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Size of media item
Justin Bozalina 06.07.2007 17:00:00
Hi,

I'm new to WMP SDK. I've been working on this problem for a week or so and
haven't been able to come up with a solution. I have a WMP window in my MFC
application that I'm popping up to play an AVI selected in a file dialog.
Playing the file works fine, but I'm trying to size the window correctly
based on the size of the AVI. I'm doing this by putting the URL of my file,
then getting the current media item. However, the
get_imageSourceHeight/Width functions always return zero as their sizes.
Alternatively, is there a way to "autosize" the WMP window. I've looked for
this functionality in the documentation and haven't been able to find
anything about it.

My code:
if(m_spWMPPlayer)
hr = m_spWMPPlayer->put_URL(bstrURL);
if(m_spWMPPlayer2)
m_spWMPPlayer2->put_stretchToFit(TRUE);

IWMPMedia* pMedia = NULL;
long width, height;
m_pWMPCore3->get_currentMedia(&pMedia);
pMedia->get_imageSourceHeight(&height); //height returns = 0
pMedia->get_imageSourceWidth(&width); //width returns = 0

Thanks for any help!

Re: Size of media item
"AUGE_OHR" <AUGE_OHR_NOSPAM_[ at ]CSI.COM> 06.07.2007 17:25:11
hi,

[Quoted Text]
> My code:
> if(m_spWMPPlayer)
> hr = m_spWMPPlayer->put_URL(bstrURL);
> if(m_spWMPPlayer2)
> m_spWMPPlayer2->put_stretchToFit(TRUE);

you have to "play" it before you can get High/wide

> IWMPMedia* pMedia = NULL;
> long width, height;
> m_pWMPCore3->get_currentMedia(&pMedia);
> pMedia->get_imageSourceHeight(&height); //height returns = 0
> pMedia->get_imageSourceWidth(&width); //width returns = 0

greetings by OHR
Jimmy


Re: Size of media item
Justin Bozalina 06.07.2007 18:22:01
Hey Jimmy. I changed the code to try this:

IWMPControls* pControl = NULL;
IWMPMedia* pMedia = NULL;

if(m_spWMPPlayer)
{
m_spWMPPlayer->put_URL(bstrURL);
m_spWMPPlayer->put_stretchToFit(TRUE);
}

m_pWMPCore->get_controls(&pControl);
pControl->play();

long width, height;
m_pWMPCore->get_currentMedia(&pMedia);
pMedia->get_imageSourceHeight(&height);
pMedia->get_imageSourceWidth(&width);

But it still returns zero for the width and height. The functions aren't
failing, they're just not returning the right values.

Re: Size of media item
"AUGE_OHR" <AUGE_OHR_NOSPAM_[ at ]CSI.COM> 06.07.2007 20:19:17
hi,

[Quoted Text]
> m_pWMPCore->get_controls(&pControl);
> pControl->play();

use some "sleep(10)" after "play" but before rest

> long width, height;
> m_pWMPCore->get_currentMedia(&pMedia);
> pMedia->get_imageSourceHeight(&height);
> pMedia->get_imageSourceWidth(&width);

greetings by OHR
Jimmy


Re: Size of media item
Mark Salsbery 07.07.2007 01:04:02
Sleep isn't going to work :/ That would be bad form :)

Maybe add an event handler for PlayStateChange and when the state is 3
(playing) then you can get the video dimensions, duration, etc.

Mark

--
Mark Salsbery
Microsoft MVP - Visual C++


"Justin Bozalina" wrote:

[Quoted Text]
> Hey Jimmy. I changed the code to try this:
>
> IWMPControls* pControl = NULL;
> IWMPMedia* pMedia = NULL;
>
> if(m_spWMPPlayer)
> {
> m_spWMPPlayer->put_URL(bstrURL);
> m_spWMPPlayer->put_stretchToFit(TRUE);
> }
>
> m_pWMPCore->get_controls(&pControl);
> pControl->play();
>
> long width, height;
> m_pWMPCore->get_currentMedia(&pMedia);
> pMedia->get_imageSourceHeight(&height);
> pMedia->get_imageSourceWidth(&width);
>
> But it still returns zero for the width and height. The functions aren't
> failing, they're just not returning the right values.
>

Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net