Page 1 of 1

HowTo get selected songs

Posted: Tue Feb 07, 2017 8:53 pm
by crap_inhuman
How can i get the selected songs through api ?

Using the well-known SDB.SelectedSongList return no result

Re: HowTo get selected songs

Posted: Wed Feb 08, 2017 6:09 am
by PetrCBR

Code: Select all

var tracklist = uitools.getSelectedTracklist();

Re: HowTo get selected songs

Posted: Wed Feb 08, 2017 3:43 pm
by djdd
An example can be found in the SampleScript "fixTrailingThe", local.js, line 234, that also Show how to handle the Situation, if nothing was selected

Code: Select all

trackList = uitools.getSelectedTracklist()
if (!trackList || trackList.count == 0) {

    trackList = uitools.getTracklist()
}

if (!trackList || trackList.count == 0) {
    res = messageDlg("Select tracks to be updated", 'Error', ["btnOK"], {}, function(){})
    return
}
Regards,
Dieter

Re: HowTo get selected songs

Posted: Thu Feb 09, 2017 3:06 am
by crap_inhuman
Thank you for your answers.

Is it possible with the COM interface, too?

Re: HowTo get selected songs

Posted: Thu Feb 09, 2017 7:51 am
by PetrCBR
From COM interface you can get the tracks as JSON string using asJSON property (will be introduced in next build):

Code: Select all

tracks = SDB.runJSCode('function(){ var list = uitools.getSelectedTracklist(); if(!list || !list.count) list = uitools.getTracklist(); if(list) return list.asJSON; return ''; }();')

Re: HowTo get selected songs

Posted: Thu Feb 09, 2017 2:42 pm
by crap_inhuman
I try to convert the Discogs Tagger using Autoit3 scripting language - the script interact with MM using the COM interface. Works perfect with MM4. To get the script working with MM5 i need a COM interface as in MM4. This script is already finished.

Using the following code didn't return a object, so i would have to change the whole script.

Code: Select all

tracks = SDB.runJSCode('function(){ var list = uitools.getSelectedTracklist(); if(!list || !list.count) list = uitools.getTracklist(); if(list) return list.asJSON; return ''; }();')


I try to convert the script using the VBS2JS converter, too... But i don't know, if i can get it work sometime.

Re: HowTo get selected songs

Posted: Thu Feb 09, 2017 3:27 pm
by Ludek
Re: Discogs Tagger

You might want to look at [MM5 install folder]/SampleScripts/customWebTagger.mmip (after install the sources will be in [MM5 install folder]/Scripts/customWebTagger/)

Re: HowTo get selected songs

Posted: Thu Feb 09, 2017 3:48 pm
by PetrCBR
As i wrote, asJSON property will be introduced in next release.