External Tools for MM5

Get help for different MediaMonkey 5 Addons.

Moderators: jiri, drakinite, Addon Administrators

Andre_H
Posts: 418
Joined: Thu Jan 21, 2021 2:04 pm
Location: Germany

External Tools for MM5

Post by Andre_H »

As an example how to open external tools (MP3Tag here):

Code: Select all

//* open file or folder of selected track in MP3Tag.*//
// variables ...
var AppPath = "\\\\YourServer\\YourShare\\Mp3Tag\\MP3Tag.exe" 
//var AppPath == "X:\\YourFolder\\Mp3Tag\\MP3Tag.exe"

actions.openFileMP3Tag = {
    title: _('Open track in MP3Tag ...'),
    icon: 'openMP3Tag',
    disabled: uitools.notMediaListSelected,
    visible: window.uitools.getCanEdit,
    execute: async function () {	
	var list = await uitools.getSelectedTracklist().whenLoaded();
        
	if (list.count === 0) {
            return;
        }

        list.forEach(function(itm) {
		var AppParameters = '/fn:"' + itm.path + '"'
		app.utils.shellExecute(AppPath, AppParameters)	
        });       
    }
}

actions.openFolderMP3Tag = {
    title: _('Open track folder in MP3Tag ...'),
    icon: 'openMP3Tag',
    disabled: uitools.notMediaListSelected,
    visible: window.uitools.getCanEdit,
    execute: async function () {	
	var list = await uitools.getSelectedTracklist().whenLoaded();
        
	if (list.count === 0) {
            return;
        }

        list.forEach(function(itm) {
		var AppParameters = '/fp:"' + itm.path + '"'
		app.utils.shellExecute(AppPath, AppParameters)	
        });       
    }
}

window._menuItems.editTags.action.submenu.push({
        action: actions.openFileMP3Tag,
        order: 1,
        grouporder: 2
});

window._menuItems.editTags.action.submenu.push({
        action: actions.openFolderMP3Tag,
        order: 2,
        grouporder: 2
});
Credits to all the guys in the addon subforum, I just jingled it together following the instructions from there.
It's nowhere near the same as the addon linked above, but possibly an approach.
- MMW 5.0.4.2690 (non-portable, shared DB & files) on Windows 2016 # only essential addons # my 24/7 media server
- MMW MMW 5.0.4.2690 (non-portable, shared DB & files) on Windows 10 # playing, testing skins & addons # my desktop app
- MMA Pro (2.0.0.1063) on Android 10, 11, 12 Phones & Tabs # WiFi Sync # playing

- MP3Tag, MP3Diags, MP3DirectCut, IrfanView
tbm72
Posts: 363
Joined: Tue Dec 09, 2008 3:04 pm
Location: UK

Re: MMW5 Addon & Skin Requests

Post by tbm72 »

Andre_H wrote: Wed Apr 06, 2022 11:37 am As an example how to open external tools (MP3Tag here):
This looks very promising thanks! Sorry for the stupid question but how do I go about getting this code into MM? Do I need to look at the scripts folder or does it involve coding as an addon?

Happy to experiment if someone can point me in the right direction!
drakinite
Posts: 965
Joined: Tue May 12, 2020 10:06 am
Contact:

Re: External Tools for MM5

Post by drakinite »

Hey guys, FYI I split these two posts off the Addon & Skin Requests thread to keep it on topic.
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.
Andre_H
Posts: 418
Joined: Thu Jan 21, 2021 2:04 pm
Location: Germany

Re: MMW5 Addon & Skin Requests

Post by Andre_H »

tbm72 wrote: Wed Apr 06, 2022 4:03 pm Sorry for the stupid question but how do I go about getting this code into MM? Do I need to look at the scripts folder or does it involve coding as an addon?
it's a subfolder under "scripts". if you PM me a mail adress, i can zip and send you the files, it's just 6files and 24kB at all.
- MMW 5.0.4.2690 (non-portable, shared DB & files) on Windows 2016 # only essential addons # my 24/7 media server
- MMW MMW 5.0.4.2690 (non-portable, shared DB & files) on Windows 10 # playing, testing skins & addons # my desktop app
- MMA Pro (2.0.0.1063) on Android 10, 11, 12 Phones & Tabs # WiFi Sync # playing

- MP3Tag, MP3Diags, MP3DirectCut, IrfanView
tbm72
Posts: 363
Joined: Tue Dec 09, 2008 3:04 pm
Location: UK

Re: External Tools for MM5

Post by tbm72 »

Thanks Andre, I seem to have a problem sending PMs for some reason - they just get put in my Outbox but not sent. I'll try again tomorrow.
Andre_H
Posts: 418
Joined: Thu Jan 21, 2021 2:04 pm
Location: Germany

Re: External Tools for MM5

Post by Andre_H »

Mail is on the way.

(I guess PM stay in outbox until the Receiver gets them)
- MMW 5.0.4.2690 (non-portable, shared DB & files) on Windows 2016 # only essential addons # my 24/7 media server
- MMW MMW 5.0.4.2690 (non-portable, shared DB & files) on Windows 10 # playing, testing skins & addons # my desktop app
- MMA Pro (2.0.0.1063) on Android 10, 11, 12 Phones & Tabs # WiFi Sync # playing

- MP3Tag, MP3Diags, MP3DirectCut, IrfanView
tbm72
Posts: 363
Joined: Tue Dec 09, 2008 3:04 pm
Location: UK

Re: External Tools for MM5

Post by tbm72 »

This is great Andre! I've managed to use your code to get an option which opens a selected track in XYplorer which is just what I'm after. The last step I'm stuck on is getting the option to appear under the 'Find more from same>' submenu when I right-click a track.

My slightly edited version of your code at the moment contains this:

Code: Select all

window._menuItems.editTags.action.submenu.push({
        action: actions.openFolderXYplorer,
        order: 1,
        grouporder: 2
});
Which works great but it puts the option as the first entry under the 'Edit Tags>' submenu. What I'd like is for it to be at the bottom of the 'Find more from same>' submenu. I've been reading through the 'Getting Started (Addons)' help page and also tried to decipher the 'actions.js' file but I can't quite find the right code to get it placed under that submenu option. I've tried things like:

Code: Select all

window._menuItems.findMoreFromSame.action.submenu.push
But I just get an error. I'm happy to admit I know nothing about coding but I think I'm almost there! Can anyone give me the final hint to get this code placed under the 'Find more From' submenu?
drakinite
Posts: 965
Joined: Tue May 12, 2020 10:06 am
Contact:

Re: External Tools for MM5

Post by drakinite »

Took a bit to find, but it looks like it's defined in uitools.findMoreMenuActions.explorerFolder. It's a bit more complicated than adding to an array in window._menuItems.x. More info on the override method here: https://www.mediamonkey.com/wiki/Import ... )#Override

Code: Select all

uitools.findMoreMenuActions.explorerFolder.override({
    getMenuItems: function($super, track) {
        var ret = $super(track);
        ret.push({
            title: 'Hello World',
            icon: 'folder',
            execute: function () {
                console.log('Hello World');
            },
            order: 99
        });
        return ret;
    }
});
Change the title, icon, execute, and order inside of that ret.push statement to whatever you like. You could also change it to ret.push(actions.openFolderXYplorer); if you want.
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.
tbm72
Posts: 363
Joined: Tue Dec 09, 2008 3:04 pm
Location: UK

Re: External Tools for MM5

Post by tbm72 »

drakinite wrote: Thu Apr 07, 2022 1:13 pm Took a bit to find, but it looks like it's defined in uitools.findMoreMenuActions.explorerFolder. It's a bit more complicated than adding to an array in window._menuItems.x. More info on the override method here: https://www.mediamonkey.com/wiki/Import ... )#Override

Code: Select all

uitools.findMoreMenuActions.explorerFolder.override({
    getMenuItems: function($super, track) {
        var ret = $super(track);
        ret.push({
            title: 'Hello World',
            icon: 'folder',
            execute: function () {
                console.log('Hello World');
            },
            order: 99
        });
        return ret;
    }
});
Change the title, icon, execute, and order inside of that ret.push statement to whatever you like. You could also change it to ret.push(actions.openFolderXYplorer); if you want.
Thanks so much for looking into that Drakinite, really appreciate your help. I'll have a good look through that later :)
Ludek
Posts: 4964
Joined: Fri Mar 09, 2007 9:00 am

Re: External Tools for MM5

Post by Ludek »

Alternativelly use this:

Code: Select all

uitools.findMoreMenuActions.xyplorerFolder = {
            getMenuItems: function (track) {
                if (!_utils.isRemoteTrack(track))
                    return [{
                        title: function () {
                            return _('Folder') + ' (XYplorer)';
                        },
                        icon: 'folder',
                        execute: function () {
                        	    bindAction( actions.openFolderXYplorer,  track).execute();	
                        },
                        order: 90
                    }];
            }
        }
And in the execute method of action openFolderXYplorer you can access the track via this.boundObject.
So the path to open will be this.boundObject.path
Post Reply