Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using OLE to play tracks in WMP

155 views
Skip to first unread message

Swifty

unread,
Jan 31, 2013, 2:31:58 AM1/31/13
to
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?

If you're wondering what I'm up to, it's because of a new PC. The "star"
ratings of my tracks survived, because the rating can be (and is, in my
case) encoded in the IDv3 tags. But the playcounts were all lost.

My catalog, which I publish on a webpage, looks odd having star ratings
but zero playcounts, and the only way of bumping the playcount is to let
WMP play the last few seconds of each track. I can set the playcount via
OLE, but not the last-played time, and that looks even more odd.

So, I'm doing this manually, but I still have 12,722 unplayed tracks,
and it's getting very tedious doing it manually...

--
Steve Swift
http://www.swiftys.org.uk/

Mark Miesfeld

unread,
Feb 1, 2013, 12:25:11 PM2/1/13
to
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

Swifty

unread,
Feb 1, 2013, 1:04:22 PM2/1/13
to
On 01/02/2013 17:25, Mark Miesfeld wrote:
> samples\ole\apps\oleUtils.frm

Thanks for that sample, Mark. I was ctually hoping that someone might
offer me an example program that they'd written that does something
simple with Windows Media Player using OLE. I always did struggle with
OLE, and things are getting harder recently. The fact that I forgot to
look in the Microsoft documentation is symptomatic of how much worser
I've become. In my own defence, I've only ever used WMPlayer.OCX.7 as an
interface to the player's library, so at first it didn't even occur to
me that WMPlayer.OCX.7 could be used to control the player as well.

Let me see how I get on. The Microsoft documentation on the Methods and
Properties in WMPlayer.OCX.7 is actually rather good.
0 new messages