Additional code samples & documentation needed! [#16744]

To discuss development of addons / skins / customization of MediaMonkey.

Moderators: jiri, drakinite, Addon Administrators

mrmike@mcshaffry.com
Posts: 3
Joined: Sun May 10, 2020 8:51 am

Additional code samples & documentation needed! [#16744]

Post by mrmike@mcshaffry.com »

Hello all,

I've been attempting to rewrite some MM4 scripts into MM5, and even though the "Inspect Element" is pretty useful, I'd like to suggest some needed code samples and improvements to the Scripting documentation:

1. A description of all available control types and how they are used, such as the dropdrown. I can't seem to figure out how to properly initialize a drop down because I get an error about focusedIndex not being allowed, even though I've created the dropdown exactly the way I see it in the inspected sources.
2. If there are any MM5 prebaked dialog boxes available, a list of them and how they should be called would be very nice. For example, if the dialog box in the AutoDJ options for selecting a playlist is ready to use, I'd be happy to know about it.
3. A full list of the lifetime of options windows - for example, "load" is called only once, when the dialog is first seen, but seemingly never again, and "save" is called when the "OK" button is hit. There doesn't seem to be an example of what is called when the "Cancel" button is hit, or when the options window becomes active. This is important to reload application values from their defaults if "Cancel" is hit.
4. The automatically generated class API documentation looks broken, because when you click on something the relevant material is positioned out of view, below the classes. A two-pane approach for that documentation would help immensely.
5. Code samples for accessing MediaMonkey data structures, such as Playlists, would be quite helpful. At the moment I do a lot of searching through the Scripts directory hoping to find what I'm looking for, which is time consuming and rarely yields results.
6. The API documentation specifically mentions classes like "Playlists" - and mentions that the class declared in "native/Playlists.js" - but when scripting, this file can't be included, and "app.playlists" should be used to get to the class. Mentioning that in the documentation would be quite useful, since it is time consuming to find that by reading other script code.

Also, for local script development, it would be nice to be able to disable the log/problem reporting feature for my new options window so that your crash database doesn't get filled with reports that you can't fix anyway.

I'm very happy you are using ES8/JS as the scripting language, by the way. Abandoning VBA was a wise choice.
Ludek
Posts: 4945
Joined: Fri Mar 09, 2007 9:00 am

Re: Additional code samples & documentation needed!

Post by Ludek »

Hi and thanks for your feedback!

Sorry for late reply. We've been busy by finalizing stuff for translators in order to be able to finaly release MM 5.0 + struggling with the shut down of FreeDB.

More code samples and documentation would be definetely useful (+ also the documentation needs to be updated -- it hasn't been for quite a long time).
Tracked as https://www.ventismedia.com/mantis/view ... 282#c57207

1. As for the Dropdown: I guess that you mean the "focusedIndex supported only for dropdown list (readOnly: true)" assertion?
I guess that your DropDown is missing the readOnly: true param? Or it is missing the valuelist.

2-5: Probably the best code example for now is the whole MM5 app (whole UI is written in JS/SCC/HTML5 and uses the same language as the scripts).
That said you can find any Dropdown in our UI and inspect its related code in any dialog/window.

BTW: Better than the "Inspect Element" is the "Open DevTools in Chrome" choice where you can breakpoint the code in sources like this:
https://www.dropbox.com/s/p3t13byyxi9mt ... 9.png?dl=0
+ also analyze the performance + much more (see the DevTools help)

6) As for the "native/Playlists.js" : yes, this is just a trick as in true all the native/*.* has .pas extension renamed to .js, i.e. this is the backend written in Delphi and is accessed via the app obect in JS. i.e. app.playlists in this case as you found. To be mentioned in the documentation.

7) Disabling the log/reporting feature would be definetly useful for you and us too -- so that our crash database doesn't get filled with reports that we can't fix anyway. Good point. Added as https://www.ventismedia.com/mantis/view.php?id=16744
mrmike@mcshaffry.com
Posts: 3
Joined: Sun May 10, 2020 8:51 am

Re: Additional code samples & documentation needed!

Post by mrmike@mcshaffry.com »

Thanks for the reply!

I didn't actually look hard enough to find the MM5 source code - it was right in front me all along. For example, the autoDJ.js file is on Media Monkey 5/helpers - and shows pretty clearly how to bring up a dialog box with a lists of playlists in it:

var dlg = uitools.openDialog('dlgSelectPlaylist', {
modal: true,
});

That will be a big help.
Post Reply