Author Topic: Additional Tagging & Reporting Tools  (Read 942593 times)

boroda

  • Sr. Member
  • ****
  • Posts: 4669
You could simply do a test when the user clicks Proceed and show a message if another of your commands is still running, or alternatively iterate though the query resultset quickly and build up your own internal resultset which you then use to run your file operations from.
Very very good idea espesially about quickly querying files and stroring them in own list.

MB internally has a class that can run tasks in the background and have them display the status on the taskbar with the termination button, so i will look to expose that via the API.
Thanks.

By the way what MB displays in statusbar when 2 or more background tasks are performed? And how 'X' button in statusbar does work in this situation? Never ran 2 long background tasks simultaneously.

Elberet

  • Full Member
  • ***
  • Posts: 167
The common way to do this is to have a central work queue. Whenever the user confirms an operation, an object representing that operation is pushed into the work queue and a thread backing the queue is pinged. The worker thread associated with the queue simply runs the operations in the queue in order and sleeps when the queue is empty. This provides serialization (i.e. operations which iterate through a library query do not overlap and close each others' queries) and you can add any kind of UI to this, such as a little window that pops up while the queue is non empty, showing a label for the operation in progress, a progress bar and an abort button. If you're careful not to do any actual work in that window's UI code (shouldn't be a problem, after all it merely controls the worker thread and doesn't do the actual work), you can even put this into the MB GUI thread without causing problems.

Steven, couldn't you return a query "handle"? The initual query returns a handle, GetNext requires this handle and once done, the handle is disposed with an EndQuery call. That'd allow for simulatenous queries in a C++-like fashion and C# devs could roll the handle into a custom enumerator which calls EndQuery upon disposal / finalization.

boroda

  • Sr. Member
  • ****
  • Posts: 4669
This provides serialization (i.e. operations which iterate through a library query do not overlap and close each others' queries)
This is not very covinient for interactive operations (with UI). For example user opens 'Change case' command, clicks 'proceed', gets immediate responce 'operation is queued' then opens 'Copy tag' command. He will see old tag value in preview if tags are not changed by background task yet (but will be changed later).

Not sure how this should be properly organized.

Steven, couldn't you return a query "handle"? The initual query returns a handle, GetNext requires this handle and once done, the handle is disposed with an EndQuery call. That'd allow for simulatenous queries in a C++-like fashion and C# devs could roll the handle into a custom enumerator which calls EndQuery upon disposal / finalization.
This would be great.
Last Edit: August 14, 2011, 03:00:25 PM by boroda74

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34394
i'll add a way to get all query results in one go

and as mentioned i will expose the threadmanager class which also allows the taskbar to be updated with a status and ability to terminate the task. This class queues work items so they are executed in sequence

and lastly i'll look to invoke the menu callbacks on the plugin thread (rather than the GUI thread as now) - thats subject to input forms working normally when created and operated on in their own thread - not sure if that would cause any issues

edit:
i dont think its a good idea to create input forms in a thread as you cant set the owner to the musicbee application form. So i will leave the menu item callback as now (ie. in the GUI thread) on the basis that menu items are likley to be requireing some form of user interaction.
Last Edit: August 14, 2011, 06:08:33 PM by Steven

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34394
API has been updated - see the MusicBee API topic for info on the new API and the updated interface definition file included with the examples: MusicBeeInterface.cs
http://getmusicbee.com/forum/index.php?topic=1972.msg22996#new

updated .exe required to support the new API methods:
http://www.mediafire.com/?xy72lud3hr129np
Last Edit: August 14, 2011, 09:38:11 PM by Steven

BeeBeeKing

  • Full Member
  • ***
  • Posts: 236
Does this mean I should remove the current plugin before updating MB? (in light of the new API)

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34394
no, its backwards compatible - i expect boroda74 will make use of the new methods and provide an updated plugin at some point

boroda

  • Sr. Member
  • ****
  • Posts: 4669
New beta version is released. See 1st post on this topic for details.


P.S. Steven, I'll look later at new API. I've found that I don't need MB background task pool - I can manage it myself (all the same - I'm using some kind of serialization, more exactly commands cannot be overlapped). Also leaving menu items commands in GUI thread makes sense. But providing a way for working with statusbar text/buttons may be extremely useful.

percy74

  • Guest
Thanks very much for the update boroda, especially the auto-tagging feature.  It's working great.

boroda

  • Sr. Member
  • ****
  • Posts: 4669
Thanks very much for the update boroda, especially the auto-tagging feature.  It's working great.
What do you mean by auto-tagging feature?

Maleko12

  • Member
  • Sr. Member
  • *****
  • Posts: 658
Slight typo in "Advanced Search and Replace": Change multiple artit list from 'Artist1; Artist2' to 'Artist1 feat. Artist2'. Granted, it can be edited in the "Rename/Edit" section.

percy74

  • Guest
Thanks very much for the update boroda, especially the auto-tagging feature.  It's working great.
What do you mean by auto-tagging feature?

Oh sorry.  I meant auto-rating feature. The "plays per days in library" option makes it work just the way I like.  Thanks for that.

BeeBeeKing

  • Full Member
  • ***
  • Posts: 236
Where do we get 1.3.4249 , 4243 seems to be the latest?

BeeBeeKing

  • Full Member
  • ***
  • Posts: 236
ok, found it in the API forum. Must not be posted in the beta release forum yet.

BeeBeeKing

  • Full Member
  • ***
  • Posts: 236
I can only see the multiple artists plugin in Advanced search and replace box. I did delete most of the versions of the leadind zero's plugin except the version i may still use at some time. They appear to still be in the folder, just not visible in your plugin.

I am also getting this error when I close out of the plugin, and have to ctrl alt del to get out. I am on win 7 64bit
------------------------------------------------
MusicBee v1.3.4249.15886 (Win6.1), 21 Aug 2011 14:32:

System.ArgumentOutOfRangeException: Not a valid Win32 FileTime.
   at System.DateTime.ToFileTimeUtc()
   at System.IO.File.SetLastWriteTimeUtc(String path, DateTime lastWriteTimeUtc)
   at System.IO.FileSystemInfo.set_LastWriteTimeUtc(DateTime value)
   at MusicBeePlugin.AdvancedSearchAndReplacePlugin.saveSettings()
   at MusicBeePlugin.AdvancedSearchAndReplacePlugin.buttonCancel_Click(Object sender, EventArgs e)
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)