On Jan 30, 11:31 pm, Swifty <
steve.j.sw...@gmail.com> wrote:
> I've used OLE to interrogate, and even alter the Windows Media Player
> library, starting with:
>
> Player=.OLEObject~New("WMPlayer.OCX.7")
> Collection = Player~MediaCollection
> Playlist = Collection~getAll
>
> ... but does anyone have an example of code that plays a specific track?
>
> Going for broke, can I tab to a given offset within the track?
The OleObject in ooRexx uses the functionality provided by OLE to
invoke methods on a COM object, that it knows nothing about.
So ooRexx and OleObject have absolutely no idea about which methods
the COM WMPlayer.OCX.7 object supplies to do what. For that you need
the documentation of the WMPlayer.OCX.7 object.
Although, it is possible to iterate through the names of the methods
that a COM object has, *if* the object supplies a type library. In
the examples shipped with ooRexx is a convenience routine that does
that iteration. It is in:
samples\ole\apps\oleUtils.frm
oleUtils.frm is meant to be ::requires in your program. It has
several convenience routines in it. The routines are documented in
the comments for each routine. One of the routines is:
displayKnownMethods() which will print out all the method names that
the OleObject can discover. Using your snippet of code from above,
the following program will show you what methods are available:
/* List media player methods */
Player=.OLEObject~New("WMPlayer.OCX.7")
r = displayKnownMethods(Player, .true)
say; say
Collection = Player~MediaCollection
r = displayKnownMethods(Collection, .true)
say; say
Playlist = Collection~getAll
r = displayKnownMethods(PlayList, .true)
::requires 'oleUtils.frm'
The above program will print out a large number of methods. The
output will start like this:
ProgID: WMPlayer.OCX.7
ClsID: {6BF52A52-394A-11D3-B153-00C04F79FAA6}
Dispatch Pointer: 0x000000000050CD18
TypeInfo Pointer: 0x00000000002FD198
Containing Type Library: WMPLib
Library Description: Windows Media Player
COM Class: IWMPPlayer4
Class Description: IWMPPlayer4: Public interface.
Known methods: 39
close
Decscription: Closes the media
<Function> returns VT_VOID
obj~close()
URL
Decscription: Returns or sets the URL
<Property get> returns VT_BSTR
bstrobj= obj~URL
URL
Decscription: Returns or sets the URL
<Property put> returns VT_VOID
obj~URL( VT_BSTR [in] <unnamed> )
openState
Decscription: Returns the open state of the player
<Property get> returns VT_USERDEFINED
userdefinedobj= obj~openState
playState
Decscription: Returns the play state of the player
<Property get> returns VT_USERDEFINED
userdefinedobj= obj~playState
controls
Decscription: Returns the control handler
<Property get> returns VT_PTR
ptrobj= obj~controls
settings
Decscription: Returns the settings handler
<Property get> returns VT_PTR
ptrobj= obj~settings
currentMedia
Decscription: Returns or sets the current media object
<Property get> returns VT_PTR
ptrobj= obj~currentMedia
which is actually much better than many COM objects because the
description is supplied. This might be helpful for you.
Unfortunately, many of the COM objects do not supply good
documentation, or it is hard to track down. In general, one of the
best approaches is to find an example in a Visual Basic script that
does what you want and then translate that to ooRexx using OleObject.
--
Mark Miesfeld