INTERACT FORUM

Please login or register.

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

Author Topic: How to use the MC COM Object  (Read 2832 times)

Zoner

  • Regular Member
  • World Citizen
  • ***
  • Posts: 198
  • nothing more to say...
How to use the MC COM Object
« on: July 06, 2004, 04:10:59 am »

Again, after spending a day messing around with the MC COM object, I thought I'd make a post explaining the things I wish someone had explained to me before I started.

The only way to make MC play/Stop/pause etc is via the MJPlaybackAutomation object.  Changing the cursor position within the MJCurPlaylistAutomation object, for example, will *not* affect what is playing now until you call MJPlaybackAutomation.Play(), at which point the cursor position becomes important.

Here is some sample C++ code to move to the next track in the current playlist and play it if MC is already playing (otherwise it just moves the cursor but does not start playing).  I've removed most of the error checking code to make it easier to read.

HRESULT hr = CoInitialize(NULL);

hr = MC.GetActiveObject(L"MediaJukebox Application");

if (hr != S_OK)
{
   hr = MC.CreateInstance(L"MediaJukebox Application");

   if (hr == S_OK)
   {
      MC->ShowProgram(1);
   }
}

if (hr == S_OK)
{
   IMJPlaybackAutomationPtr Playback = MC->GetPlayback();
   IMJCurPlaylistAutomationPtr Playlist = MC->GetCurPlaylist();

   const long Pos = Playlist->GetNextFile();
   Playlist->PutPosition(Pos);
   if (Playback->GetState() == PLAYSTATE_PLAYING)
   {
      Playback->Play();
   }
}
Logged

Zoner

  • Regular Member
  • World Citizen
  • ***
  • Posts: 198
  • nothing more to say...
Re:How to use the MC COM Object
« Reply #1 on: July 06, 2004, 06:27:53 am »

One more thing to add: I don't recommend mixing message-based MC control with COM-based MC control.  I was doing this (I used to use message-based control, and now am converting my app to COM-based control), and it caused problems.  For example, if MC is stopped, you move the playlist cursor using the COM object, and then send a play command via a windows message, COM-based the playlist cursor is ignored.
Logged
Pages: [1]   Go Up