INTERACT FORUM

Windows => Plug-in Development => Topic started by: LehighBri on May 24, 2004, 01:33:08 pm

Title: Event handling using the MC COM object
Post by: LehighBri on May 24, 2004, 01:33:08 pm
Is there any event handling built into the Media Jukebox COM object?  I would like to call a method each time a new file is played.  This would be similar to iTunes' OnPlayerPlayEvent.

Any ideas on if this is possible or what classes to look at?  Thanks!
Title: Re:Event handling using the MC COM object
Post by: Matt on May 24, 2004, 01:35:16 pm
There aren't currently notifications in the automation SDK.  Perhaps in the next version.

For now, you'll need to run a timer or something similar and poll MC.
Title: Re:Event handling using the MC COM object
Post by: LehighBri on May 24, 2004, 01:50:14 pm
Thanks for the perfectly good workaround, and I look forward to hearing how this will be implemented in future versions!
Title: Re:Event handling using the MC COM object
Post by: Zoner on June 17, 2004, 04:47:30 pm
Another alternative is to use the Windows messaging interface: that's event-based.
Title: Re:Event handling using the MC COM object
Post by: Zoner on July 05, 2004, 04:35:39 am
Sorry, what I wrote is incorrect.  The message-based interface is only good for sending commands to MC, not for receiving notifications from it.
Title: Re:Event handling using the MC COM object
Post by: Zoner on July 12, 2004, 03:22:59 am
J River - any chance we could get some development in this area?  I would settle for anything at all, no matter how simple.  If you could just broadcast a windows message every time you started or stopped playing a new track, that would be fantastic.

Polling really is a bad solution - it means we have to choose between latency and CPU usage.  An event-based solution means no compromises.
Title: Re:Event handling using the MC COM object
Post by: RhinoBanga on July 12, 2004, 09:05:11 am
Quote
Polling really is a bad solution

I agree and you're not the only one after it.   I made a request over two years ago:

http://yabb.jriver.com/interact/index.php?board=6;action=display;threadid=15822;start=msg107191#msg107191



Although to be fair in PlayingNow I poll every 750ms to check what is currently playing and no-one has complained that it's a performance killer; but a proper event mechanism would be nice.
Title: Re:Event handling using the MC COM object
Post by: Zoner on July 13, 2004, 01:55:43 am
...and soooo easy to do, surely?  COM already supports an event mechanim, but failing that just blasting out a windows message to all windows to say "something happened" is a 1-liner.
Title: Re:Event handling using the MC COM object
Post by: RhinoBanga on July 13, 2004, 02:38:26 am
The problem with a windows message is that it's a PITA for VB users, which unfortunately most plugin users are, so it would only benefit a few of us or those who can handle subclassing in VB.
Title: Re:Event handling using the MC COM object
Post by: Zoner on July 17, 2004, 03:52:02 am
I agree that something more sophisticated would be better, but after waiting for over a year for that with no end in sight, I'm more than ready to accept *anything* J River can provide.

This problem is getting more acute for me now, since I've expanded my CAV6.6 software to handle up to 6 zones.  Polling 6 zones in MC is really a drag!
Title: Re:Event handling using the MC COM object
Post by: NaTeDoGG on September 25, 2004, 01:19:12 am
Bumpity! Can we have events pleeeeaaaaase?
Title: Re:Event handling using the MC COM object
Post by: Zoner on November 07, 2004, 03:41:05 am
Double-bump
Title: Re: Event handling using the MC COM object
Post by: Mr ChriZ on March 05, 2006, 07:39:18 am
Triple Bump ;-)
Doesn't bother me that much but as I'm here!
Title: Re: Event handling using the MC COM object
Post by: Matt on March 06, 2006, 08:46:29 am
There is a solution that exists that we use internally.  It's not well documented and the messages it uses may change between versions (and possibly even builds).

With that disclaimer said, the solution that exists is:

OnCreate(...) of a window:
pMJ->RegisterWindowWithRouter(hwndMyWindow, TRUE);

Handle this message:
WM_MC_COMMAND

Return TRUE if you handle a message or MCC_UNHANDLED if you don't.

For example, the on track change notification looks like this:
MCC_NOTIFY_PLAYER_INFO_CHANGED (test (Param & PLAYER_INFO_CHANGE_PLAYING_FILE))

OnDestroy(...) of a window:
pMJ->RegisterWindowWithRouter(hwndMyWindow, FALSE);

More information on the messages here: (focus on the MCC_NOTIFICATIONS_SECTION)
http://www.jrmediacenter.com/DevZone/MCCommands.h
Title: Re: Event handling using the MC COM object
Post by: Mr ChriZ on March 06, 2006, 08:54:13 am
Interesting to know  :),
Cheers Matt!
Title: Re: Event handling using the MC COM object
Post by: RhinoBanga on March 06, 2006, 09:00:21 am
Hi Matt,

While I appreciate you telling us this I don't think it's really usable since you are saying it may change even down at the build level.

Something more robust is unfortunately needed.
Title: Re: Event handling using the MC COM object
Post by: scthom on March 06, 2006, 05:23:48 pm
While I appreciate you telling us this I don't think it's really usable since you are saying it may change even down at the build level.

Something more robust is unfortunately needed.

I agree.  Would be a fantastic feature for plugins, and needs to be fairly robust (and constant!!) to be useful in any meaningful way.  And, really, it needs to be events.  Some plugins (Encoder) use events already.