Page 13 of 13

Re: Scripting Functionality Thread (NO Script Requests Here!)

Posted: Thu Nov 20, 2008 5:21 am
by twinbee
To return to this point...
No, SDB.MainTracksWindow.AddTracksFromQuery() is the fastest way to add tracks to the main window, as long as you don't have slow SQL's.
I have about 5000 songs in my database so far. As before, I need to add tracks by ID to the TracksWindow. Using AddTracksFromQuery() is around 10 times slower than a way I have found which is rather kludgy (so I would prefer replaced) but is lightning quick - this is basically what happens:

When Mediamonkey boots up, I copy each SongData object for all tracks to an Objects array thusly:

Code: Select all

Set it = SDB.Database.QuerySongs("id > 0")
Do While Not it.EOF
	SDB.Objects(it.Item.ID) = it.Item    ' Copy the SongData object to each Object in the array
	it.Next
Loop
I then use later: mytrackswindow.AddTrack( SDB.Objects( id(n)) ) - where "id" is an array containing thousands of ID numbers. Doing it this way is much faster than AddTracksFromQuery() alone. Even if I use ID IN(" & MyString & ")" (which I think you mentioned a while back), my above kludgy method is almost twice as fast (and also, using ID IN.... won't keep the order of the thousands of ID numbers (separated by commas) in MyString - though perhaps there's a way around that?).

This is why my reasoning for allowing the AddTrackById method for SDBTracksWindow would be a great boon. Thousands of ID numbers could be added directly without having to scan the database for each and every ID as with AddTracksFromQuery(). Am I overlooking something?

Re: Scripting Functionality Thread (NO Script Requests Here!)

Posted: Thu Dec 18, 2008 1:53 am
by ZvezdanD
Bex wrote:I agree that we should have a proper Clear method
I tried to replace SDB.MainTracksWindow.RemoveSelectedTracks in my scripts with:

Code: Select all

        SDB.MainTree.CurrentNode.NodeType = 12
        SDB.MainTracksWindow.Refresh
because it is much faster, but unfortunately after adding new tracks with SDB.MainTracksWindow.AddTrack I could not get tracks sorted as before. I tried to restore NodeType, SortCriteria and SortGroup of that node but neither of that helped. Do you have some suggestion for this or should I stay with my solution?

By the way, have you tried your suggestion with a new possibility of MM 3.1 to display all tracks in the tracklist even when you select Library node?

Re: Scripting Functionality Thread (NO Script Requests Here!)

Posted: Thu Dec 18, 2008 3:52 am
by Bex
No I haven't tested it yet. Perhaps SDB.MainTree.CurrentNode.NodeType = 11, which is the location, works better in MM3.1?

Re: Scripting Functionality Thread (NO Script Requests Here!)

Posted: Mon Dec 29, 2008 3:49 pm
by trixmoto
Anybody else with there was an OnDelete event? For the script I'm currently working on I am creating a table to extend the Songs table and when a song is deleted I'd really like to be able to delete my own record as well. I can of course tidy these up later on, but I'd like to add some other functionality as well that would need to happen as the track is being deleted.

Re: Scripting Functionality Thread (NO Script Requests Here!)

Posted: Mon Dec 29, 2008 3:51 pm
by MoDementia
I use a trigger for this type of thing, I think sync the sync has one

Re: Scripting Functionality Thread (NO Script Requests Here!)

Posted: Mon Dec 29, 2008 4:21 pm
by trixmoto
Thanks, I'll take a look. :)

EDIT: Whilst this does seem to allow me to clean up my own database table, it does not allow me to add the other functionality I require (like showing a popup window to the user). Looks like I'm still gonna need an event unless I'm mistaken?

Re: Scripting Functionality Thread (NO Script Requests Here!)

Posted: Tue Dec 30, 2008 1:29 am
by MoDementia
You're right, but a popup to do what? there is no undelete :(

Re: Scripting Functionality Thread (NO Script Requests Here!)

Posted: Tue Dec 30, 2008 7:36 am
by trixmoto
Well if the event had a parameter to cancel the delete that would be cool, but not actually something that I need. The script I'm working on communicates with an online repository so when you delete a track in the repository from MM I want to give the user the option to also delete it from the repository automatically.

Re: Scripting Functionality Thread (NO Script Requests Here!)

Posted: Tue Dec 30, 2008 3:32 pm
by MoDementia
Yep an event wold be needed in this case.
As a work around you could add to the trigger to up date another table with the deletions, but it would be another click to read that table and confirm deletions.
Might not be too bad, ie instead of a popup every deletion just review the list after a deleting session.

Re: Scripting Functionality Thread (NO Script Requests Here!)

Posted: Tue May 12, 2009 5:43 pm
by ZvezdanD
I really need OnAfterTracksMove event.

Re: Scripting Functionality Thread (NO Script Requests Here!)

Posted: Mon Sep 14, 2009 2:52 pm
by flashk
I would really like a OnTrackListModified event that behaves similarly to the OnNowPlayingModified event, except for the main tracks window. The problem with OnTrackListFilled is that it doesn't handle tracks being removed, reordered, or resorted.

Re: Scripting Functionality Thread (NO Script Requests Here!)

Posted: Mon Sep 14, 2009 3:10 pm
by ZvezdanD
I agree with the previous. Also, I need OnPlaylistModified (static as well as auto-playlists).

Re: Scripting Functionality Thread (NO Script Requests Here!

Posted: Tue Oct 23, 2012 5:34 pm
by Nanya
T'would be nice to have the ability to click on a spot on an SDBUITrackBar to change its value, (perhaps there already is, but it's just undocumented).

Having the ability to return to a previous view after a refresh would also be nice, i.e., selected tracks, visible tracks, etc..

And what about controls to modify TrackBrowser selections?

(Amateur here, perhaps I've just missed all these features. :D )