INTERACT FORUM

Please login or register.

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

Author Topic: Tag Field Changed Event (WatchFields)  (Read 1896 times)

Tanoshimi

  • Junior Woodchuck
  • **
  • Posts: 57
Tag Field Changed Event (WatchFields)
« on: June 27, 2007, 09:26:28 am »

Since I've heard this come up alot, I wanted to again stress how important this can be, in the hopes it gets added in a (near) future build.

We all know MC will not fire an event when a Field changes.  I was working on a plugin that allowed you to select the fields to watch, then notify you when it changes.  The problem is, for just one Field, the plugin is required to loop through all Song and test the existing value against the Last value.  Now this works, but in a library of 10,000+ songs, watching 1 field takes forever.

MC knows when a Field is changed (heck it changes it).  It would be so very simple to fire an event with an EventType of MC12Field_Changed or _Deleted or _Added, with the two parameters being FieldName and NewValue.  It seems like an easy fix (one or two lines of code) that would be very powerful to other programmers.  For example, I have a plugin called ComputedFields that does what CalculatedFields does, only it does Math, but if one of the values in the Formula changes (say you change the rating of a song), I have no way of trapping this to update my ComputedField.

Does anyone else want to know when Fields have changed?  Is the MC staff ever going to look at this problem?
-Tano
Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42372
  • Shoes gone again!
Re: Tag Field Changed Event (WatchFields)
« Reply #1 on: July 01, 2007, 09:54:01 am »

This is something we've considered.

The trick is that fields change a _lot_ (plug in an iPod and you could get a million notifications), so performance is a real consideration.  Even if a plugin added 1ms to every database set, it'd kill the performance of the program.

Any ideas for a happy medium?
Logged
Matt Ashland, JRiver Media Center

Tanoshimi

  • Junior Woodchuck
  • **
  • Posts: 57
Re: Tag Field Changed Event (WatchFields)
« Reply #2 on: July 01, 2007, 04:34:18 pm »

This is just a suggestion, but on the screen where Fields are created (where you select String, Integer, etc), perhaps a checkbox for Notify.  You only fire an event if the Field that's changing has the Notify Property set to true.  90% of the time, no one will deal with it, and there's no performance hit.  But if a Plugin needs to be notified when a certain Field changes, then it can set that fields Notify value to true, sit back, and wait for the event to be fired.  Yes, if a Plugin selected a field that's often modified there would be a performance hit, just as there would be if there were a ton of items changed at once.  However, if the plugin worked on Name, Artist, Album, Filename, etc., then the hit would be miniscule. 

Ultimately, it would still boil down to the Plugin Designer taking precautions, but that shouldn't be too difficult as their plugin will bog down the system if they do not, and no one would want it.
Logged
Pages: [1]   Go Up