I was wondering if anyone has ever tried this.
I have an app that I would like to be able to interrogate MediaCenter to retrieve the currently playing track info.
Note that this is NOT a plugin (actually, it's a COM addin for Outlook) so its architecture is such that it tried to request the info from MC, but doesn't actually "live" in MC as a plugin.
Anyway, I found the TLB and played around with the object model.
I ended up with code essentially like this.
Set oMediaCenter = New MediaCenter.MCAutomation
If not oMediaCenter is Nothing Then
With oMediaCenter
Select Case .GetPlayback.State
Case PLAYSTATE_PAUSED, PLAYSTATE_PLAYING
'---- Media center info is available
ps = .GetCurPlaylist.Position
CurTrackTitle$ = .GetCurPlaylist.GetFile(ps).Name
CurTrackAlbum$ = .GetCurPlaylist.GetFile(ps).Album
CurTrackArtist$ = .GetCurPlaylist.GetFile(ps).Artist
CurTrackPlayCounter$ = CVStr(.GetCurPlaylist.GetFile(ps).PlayCounter)
CurTrackDuration$ = .GetCurPlaylist.GetFile(ps).GetFormattedDuration
case else
End Select
End with
End If
I would have preferred to use the GETOBJECT() method of retrieving the running instance, but it appears the MC doesn't register with the ROT. Not a huge deal, except for a couple things.
1) If I instantiate the MediaCenter.MCAutomation object more than once (even from different app instances), MC wants to POP UP and become visible, even if it was minimized or not loaded before.
2) On the second instantiation, the Set oMediaCenter = New MediaCenter.MCAutomation" statement hangs for about 30 seconds, before failing to retrieve the object.
I can easily wrap the instantiation in a singleton to prevent the double up within my DLL, but if my DLL is instantiated twice, that solution won't work (and this can happen because my Addin is also an Addin for Word).
Anyway, is this just not a supported way to call the object model in MC12, or am I missing something?
Any thoughts?
Thanks
Darin