How to exercise the media player through a console applicati
WMPTalk.com Forum Index WMPTalk.com
Discuss Windows Media Player
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web wmptalk.com
How to exercise the media player through a console applicati

 
Post new topic   Reply to topic    WMPTalk.com Forum Index -> SDK
Author Message
sridhar
Guest





Posted: Tue Dec 20, 2005 1:30 pm    Post subject: How to exercise the media player through a console applicati Reply with quote

Hello All,

i am a novice to windows media sdk.
A requirement that we have is to exercise the windows media player through a
console application
(where the UI of the media player is not needed).

i have written a small test program, which compiles and executes by no audio
is heard.
Could somebody help me out please ?

with regards
sridhar

i have installed microsoft media 9 sdk
The program is as follows:

i modified the code presented by Glenn Slayden

//
// Play a WMA file. The easy way. No MFC required. No UI presented.
//
// (c) 2003 by Glenn Slayden (glenn@glennslayden.com)

/*#########################################################################*
/

#include <windows.h>
#include <stdio.h>
#include "wmp.h"

int PlayWMA(WCHAR *pwch_url)
{
HRESULT hr;
int ret = 1;
CLSID clsid_wmp; // SDK headers are missing an adequate CLSID_
definition, so roll your own
CLSID refiid_wmp;
IWMPCore *p_iwmpcore = 0;
IWMPControls *puControl = 0;
IWMPSettings *puSettings = 0;
BSTR bs;

CLSIDFromString(L"{6BF52A52-394A-11d3-B153-00C04F79FAA6}",&clsid_wmp);
CLSIDFromString(L"{D84CCA99-CCE2-11d2-9ECC-0000F8085981}",&refiid_wmp);

//CoCreateInstance(clsid_wmp,NULL,CLSCTX_ALL, IID_IWMPCore,(void
**)&p_iwmpcore);
hr = CoCreateInstance(clsid_wmp,NULL,CLSCTX_ALL, refiid_wmp,(void
**)&p_iwmpcore);
if (FAILED(hr))
return 0;

hr = p_iwmpcore->get_controls(&puControl);
if (FAILED(hr))
{
ret = 0;
goto end;
}

hr = p_iwmpcore->get_settings(&puSettings);
if (FAILED(hr))
{
ret = 0;
goto end;
}

bs = SysAllocString(pwch_url);
hr = p_iwmpcore->put_URL(bs);
if (FAILED(hr))
{
ret = 0;
goto end;
}
SysFreeString(bs);

hr = puSettings->put_volume(100);
if (FAILED(hr))
{
ret = 0;
goto end;
}

hr = puControl->play();
if (FAILED(hr))
{
ret = 0;
goto end;
}

getchar(); /* just waiting for song to play, but nothing happens ! */

end:
if (puSettings)
puSettings->Release();
if (puControl)
puControl->Release();
if (p_iwmpcore)
p_iwmpcore->Release();

return ret;
}


int main (void)
{
int ret;

CoInitialize(NULL);

ret = PlayWMA(L"C:\\04 Symphony 4 - Beethoven.mp3");

CoUninitialize();

return !ret;
}

/*#########################################################################*
/

/* THE END */

Back to top
Alessandro Angeli [MVP::D
Guest





Posted: Tue Dec 20, 2005 1:30 pm    Post subject: Re: How to exercise the media player through a console appli Reply with quote

sridhar wrote:

Quote:
i am a novice to windows media sdk.
A requirement that we have is to exercise the windows
media player through a console application
(where the UI of the media player is not needed).

i have written a small test program, which compiles and
executes by no audio is heard.
[CUT]


What do you mean by "exercise"? You you mean use to play
something, then you may have problems when WMP's UI is
invisible because it uses DirectSound for audio rendering
and DirectSound has some quirks regarding what windows has
focus, and clearly an invisible or non-existent window has
no focus.

You may want to use DirectShow instead, which is just as
easy (WMP uses DirectShow inside) and gives you more control
in those conditions. Look at the "How to play a file"
tutorial at the beginning of the DirectShow docs (it's a
page long sample that plays everything WMP supports). The
DirectShow SDK is included in the latest Platform/Windows
SDK or in pre-summer 2004 DirectX SDKs.


--
// Alessandro Angeli
// MVP :: Digital Media
// a dot angeli at psynet dot net
Back to top
sridhar
Guest





Posted: Thu Dec 22, 2005 9:30 am    Post subject: Re: How to exercise the media player through a console appli Reply with quote

Many thanks for responding to the question.
Yes by exercising i meant that i wish to play, pause, stop, fast forward and
rewind.
Can DirectShow support actions such as play, pause, stop, fast forward and
rewind ?
i will try using the DirectShow SDK as suggested by you and get back for any
queries.

thanks
sridhar

"Alessandro Angeli [MVP::DigitalMedia]" <nobody@nowhere.in.the.net> wrote in
message news:uJ6yuHWBGHA.2040@TK2MSFTNGP14.phx.gbl...
Quote:
sridhar wrote:

i am a novice to windows media sdk.
A requirement that we have is to exercise the windows
media player through a console application
(where the UI of the media player is not needed).

i have written a small test program, which compiles and
executes by no audio is heard.
[CUT]

What do you mean by "exercise"? You you mean use to play
something, then you may have problems when WMP's UI is
invisible because it uses DirectSound for audio rendering
and DirectSound has some quirks regarding what windows has
focus, and clearly an invisible or non-existent window has
no focus.

You may want to use DirectShow instead, which is just as
easy (WMP uses DirectShow inside) and gives you more control
in those conditions. Look at the "How to play a file"
tutorial at the beginning of the DirectShow docs (it's a
page long sample that plays everything WMP supports). The
DirectShow SDK is included in the latest Platform/Windows
SDK or in pre-summer 2004 DirectX SDKs.


--
// Alessandro Angeli
// MVP :: Digital Media
// a dot angeli at psynet dot net



Back to top
Alessandro Angeli [MVP::D
Guest





Posted: Thu Dec 22, 2005 5:30 pm    Post subject: Re: How to exercise the media player through a console appli Reply with quote

sridhar wrote:

Quote:
Many thanks for responding to the question.
Yes by exercising i meant that i wish to play, pause,
stop, fast forward and rewind.
Can DirectShow support actions such as play, pause, stop,
fast forward and rewind ?
i will try using the DirectShow SDK as suggested by you
and get back for any queries.

Everything WMP does is done by DirectShow under the hood.
However, fastforwarding and rewinding do not work in
DirectShow with most formats, most notably WMV, just as they
do not work in WMP (but WMP cheats with WMV, something you
can not do in DirectShow without creating your own WMV
reader). Also, WMP adds several audio processing filters
which you won't have ready in DirectShow (but you can write
them or buy some commercial ones I think).


--
// Alessandro Angeli
// MVP :: Digital Media
// a dot angeli at psynet dot net
Back to top
Alessandro Angeli [MVP::D
Guest





Posted: Thu Dec 22, 2005 5:30 pm    Post subject: Re: How to exercise the media player through a console appli Reply with quote

sridhar wrote:

Quote:
Many thanks for responding to the question.
Yes by exercising i meant that i wish to play, pause,
stop, fast forward and rewind.
Can DirectShow support actions such as play, pause, stop,
fast forward and rewind ?
i will try using the DirectShow SDK as suggested by you
and get back for any queries.

Everything WMP does is done by DirectShow under the hood.
However, fastforwarding and rewinding do not work in
DirectShow with most formats, most notably WMV, just as they
do not work in WMP (but WMP cheats with WMV, something you
can not do in DirectShow without creating your own WMV
reader). Also, WMP adds several audio processing filters
which you won't have ready in DirectShow (but you can write
them or buy some commercial ones I think).


--
// Alessandro Angeli
// MVP :: Digital Media
// a dot angeli at psynet dot net
Back to top
 
Post new topic   Reply to topic    WMPTalk.com Forum Index -> SDK All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



Microsoft Office Forum New Topics
Powered by phpBB