INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Non Plug-in interrogation of MC?  (Read 1844 times)

dhiggins

  • Regular Member
  • World Citizen
  • ***
  • Posts: 126
Non Plug-in interrogation of MC?
« on: May 30, 2007, 11:10:46 pm »

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
Logged

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D
Re: Non Plug-in interrogation of MC?
« Reply #1 on: May 31, 2007, 03:57:08 am »

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.

It does register itself as of MC12.  It didn't used to in MC11

dhiggins

  • Regular Member
  • World Citizen
  • ***
  • Posts: 126
Re: Non Plug-in interrogation of MC?
« Reply #2 on: May 31, 2007, 10:26:04 am »

Doh, never mind, I'd never been to the WIKI, and I just found some info there that makes me believe I just don't have the code quite right.

Will try what's posted there and see if that works better.

Sorry about the post.

Thanks
Darin
Logged

dhiggins

  • Regular Member
  • World Citizen
  • ***
  • Posts: 126
Re: Non Plug-in interrogation of MC?
« Reply #3 on: June 01, 2007, 12:10:20 am »

FYI, the info in the WIKI was a HUGE help. It was a bit counter intuitive to use GetObject for the ID "MediaJukebox Application" (most com object libs that I'm familiar with use progids of "App.Class", and I did notice that some of the Documentation refers to the main object as MJAutomation, when it seems to actually be MCAutomation.

Still, My dll is working great now. No hangs, no locks and using GetObject I can easily tell when MC is loaded and when it's not.

Just FYI.

Darin
Logged

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D
Re: Non Plug-in interrogation of MC?
« Reply #4 on: June 01, 2007, 10:23:12 am »

FYI, the info in the WIKI was a HUGE help. It was a bit counter intuitive to use GetObject for the ID "MediaJukebox Application" (most com object libs that I'm familiar with use progids of "App.Class", and I did notice that some of the Documentation refers to the main object as MJAutomation, when it seems to actually be MCAutomation.

Still, My dll is working great now. No hangs, no locks and using GetObject I can easily tell when MC is loaded and when it's not.

Just FYI.

Darin

It was MJAutomation in MC11.  Alot of documentation hasn't been updated yet.
Pages: [1]   Go Up