Board index » delphi » Windows Media Player Status??

Windows Media Player Status??

I want to get the status of Windows Media Player (i.e. if it is
currently playing anything stopped or paused and if possible the name
(or filename) of the played content.

I went through various newsgroups etc., but could not find any way of
getting this information or information on controlling Windows Media
Player from Delphi.  I also used Winsight32 to try and determine what
messages are sent when you start, stop etc. WMP, If I could trace the
messages I can hook into WMP's message stream.  Unfortunately I could
not find any messages when WMP was started, stopped or paused.

Any help, especially some sample code, would be greatly appreciated.

Thanks
ABE

 

Re:Windows Media Player Status??


Quote
abeu...@boebank.co.za (ABE) wrote in message <news:1ef3cb57.0301270110.5ba64fc5@posting.google.com>...
> I want to get the status of Windows Media Player (i.e. if it is
> currently playing anything stopped or paused and if possible the name
> (or filename) of the played content.

> I went through various newsgroups etc., but could not find any way of
> getting this information or information on controlling Windows Media
> Player from Delphi.  I also used Winsight32 to try and determine what
> messages are sent when you start, stop etc. WMP, If I could trace the
> messages I can hook into WMP's message stream.  Unfortunately I could
> not find any messages when WMP was started, stopped or paused.

> Any help, especially some sample code, would be greatly appreciated.

> Thanks
> ABE

I also tried the following:

var
  ret          : longint;
  S            : array[0..255] of char;
  SizeofS      : Cardinal;
  MciOpenParms : TMCI_OPEN_PARMS;
  aDeviceID    : MCIDEVICEID;
begin
  MciOpenParms.lpstrDeviceType := 'waveaudio';
  ret := mciSendCommand(0,
                        MCI_OPEN,
                        MCI_OPEN_TYPE+MCI_OPEN_SHAREABLE,
                        LongInt(@MciOpenParms));
  if ret <> 0 then
  begin
    mciGetErrorString(ret,S,SizeofS);
    ShowMessage(StrPas(S));
  end
  else
    Result := MciOpenParms.wDeviceID;
end;

If the lpstrDeviceType = 'waveaudio' then a DeviceID is returned, but
if I use
lpstrDeviceType = 'digitalvideo' then I get an error message "263 -
The specified device is not open or is not recognized by MCI." I get
this message when WMP is open, closed and even while playing a
video.(AVI, MPEG etc.)

Am I going in the right way?  Any help will be appreciated.

ABE

Re:Windows Media Player Status??


The message <1ef3cb57.0301292233.5600f...@posting.google.com>
from abeu...@boebank.co.za (ABE) contains these words:

Quote
>  MciOpenParms.lpstrDeviceType := 'waveaudio';
>   ret := mciSendCommand(0,
>                         MCI_OPEN,
>                         MCI_OPEN_TYPE+MCI_OPEN_SHAREABLE,
>                         LongInt(@MciOpenParms));

Try it like this

 MciOpenparm.lpstrDeviceType:='';
 MciOpenparm.lpstrElementName:='c:\AtestVideo.avi';

 ret := mciSendCommand(0,
           MCI_OPEN,
           MCI_OPEN_TYPE or MCI_OPEN_SHAREABLE or MCI_OPEN_ELEMENT,
           LongInt(@MciOpenParms));

I think you can't open it for video because it needs to know the
exact format you intend to use. Wav can be software generated so
a default driver is provided. Anyway that's just a guess.

--
Sincerely,

Andreas Kyriacou
----------------
http://www.andrikkos.co.uk (Imagine! Image Viewer)

Re:Windows Media Player Status??


Quote
Andreas Kyriacou <andrik...@zetnet.co.uk> wrote in message <news:2003013008315580675@zetnet.co.uk>...
> The message <1ef3cb57.0301292233.5600f...@posting.google.com>
> from abeu...@boebank.co.za (ABE) contains these words:

> >  MciOpenParms.lpstrDeviceType := 'waveaudio';
> >   ret := mciSendCommand(0,
> >                         MCI_OPEN,
> >                         MCI_OPEN_TYPE+MCI_OPEN_SHAREABLE,
> >                         LongInt(@MciOpenParms));

> Try it like this

>  MciOpenparm.lpstrDeviceType:='';
>  MciOpenparm.lpstrElementName:='c:\AtestVideo.avi';

>  ret := mciSendCommand(0,
>            MCI_OPEN,
>            MCI_OPEN_TYPE or MCI_OPEN_SHAREABLE or MCI_OPEN_ELEMENT,
>            LongInt(@MciOpenParms));

> I think you can't open it for video because it needs to know the
> exact format you intend to use. Wav can be software generated so
> a default driver is provided. Anyway that's just a guess.

I have an application which runs in the background on a number of
computers and that application must determine the filename of the file
playing and the current status of WMP (paused, playing etc.)  The
problem is that I won't be able to know what is playing beforehand
(avi,mpeg etc.) on those computers.

ABE

Other Threads