Accessing Addon version

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

Moderators: jiri, drakinite, Addon Administrators

gexptwo
Posts: 7
Joined: Sun Sep 11, 2022 1:00 pm

Accessing Addon version

Post by gexptwo »

I'm writing a display Addon. Following the Getting Started page, I see 'version' specified in info.json. I would like my display addon to show the version, I'm trying not to define the version in multiple places.
My actions_add.js has

Code: Select all

var dlg = uitools.openDialog('display', {
Is there a way for my display.js to access the 'version'? I've tried

Code: Select all

function init(params) {
    var try1 = this.version;
    var try2 = params.addon.version;
    var try3 = this.addon.version;
}
but not found. I saw the config.js addon parameter should have access but I think that would require opening the addon config first.
drakinite
Posts: 965
Joined: Tue May 12, 2020 10:06 am
Contact:

Re: Accessing Addon version

Post by drakinite »

Unfortunately (as far as I can see) there's no simple way to retrieve the addon info from outside the config window (you'd have to do app.getAddonList() and do something like list.filterByPrefix() to get the right addon). But if you like, you could try loading the info.json file with the loadFile command.

Example with the Refresh Skin shortcut:

Code: Select all

let myInfoJson;
try {
  myInfoJson = JSON.parse(loadFile('file:///refreshSkinShortcut/info.json'));
}
catch (err) { }
Image
Student electrical-computer engineer, web programmer, part-time MediaMonkey developer, full-time MediaMonkey enthusiast
I uploaded many addons to MM's addon page, but not all of those were created by me. "By drakinite, Submitted by drakinite" means I made it on my own time. "By Ventis Media, Inc., Submitted by drakinite" means it may have been made by me or another MediaMonkey developer, so instead of crediting/thanking me, please thank the team. You can still ask me for support on any of our addons.
gexptwo
Posts: 7
Joined: Sun Sep 11, 2022 1:00 pm

Re: Accessing Addon version

Post by gexptwo »

json approach works, thanks!
Post Reply