Help for addon - display "track contained in playlists" directly

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

Moderators: jiri, drakinite, Addon Administrators

ekant
Posts: 9
Joined: Thu Apr 20, 2023 11:46 am

Help for addon - display "track contained in playlists" directly

Post by ekant »

Hello,
I'd like to try to write a first addon for MM5:
I would like to get the function of the context menu on a track "Find more of -> Playlists" more direct accessible.
E.g., a little icon (in a new row?) right to the track title - on Mouseover it should show all playlists containing the current track.

Any (little) help is very appreciated - as I am quite experienced in JS and programming, but never done anything in MM5 so far - seems to be quite complex :-)

How can I find/access the already existent dialog for displaying the required function (as described)?
How can I add a row/icon - and how to bind the action "showing the dialog" to the mouseover?

Thank you for your guide and time...
Ludek
Posts: 4964
Joined: Fri Mar 09, 2007 9:00 am

Re: Help for addon - display "track contained in playlists" directly

Post by Ludek »

Hi,
you can get inspired by showLinks addon https://www.mediamonkey.com/addons/brow ... how-links/

and in \Scripts\showLinks\controls\trackListView_add.js

you could use
getFindMoreFromSameMenuPlaylist (from uitools.js)
in the body of TrackListView.prototype.getShortcutContextMenu

to get the list of Playlists on right-click the shortcut..
Ludek
Posts: 4964
Joined: Fri Mar 09, 2007 9:00 am

Re: Help for addon - display "track contained in playlists" directly

Post by Ludek »

OK, redefining the
window.uitools.tracklistFieldDefs.title.shortcutFunc
like this

Code: Select all


window.uitools.tracklistFieldDefs.title.shortcutFunc = function (item, shortcutID) {                 
        let list = app.playlists.getPlaylistsForTrackAsync(item);
        list.whenLoaded().then(() => {                                                           
            let retArray = [];
            list.locked(function () {                
                if (list.count == 0)
                    retArray.push({
                        title: _('No playlist found'),
                        icon: 'none'
                    });
                else
                    for (let index = 0; index < list.count; index++) {
                        let playlist = list.getValue(index);
                        let useIcon = 'playlist';
                        if (playlist.isAutoPlaylist)
                            useIcon = 'autoplaylist';
                        retArray.push({
                            title: playlist.name,
                            noAccessKey: true,
                            icon: useIcon,
                            playlist: playlist,
                            execute: function () {
                                navigationHandlers['playlist'].navigate(this.playlist);
                            },
                            order: index
                        });
                    }
            });                                                                                   
            let menu = new Menu(retArray);
            menu.show(window.mouseX, window.mouseY);
        });                                   
    }

will show the playlists once you click the shortcut arrow button next to track title in filelisting
ekant
Posts: 9
Joined: Thu Apr 20, 2023 11:46 am

Re: Help for addon - display "track contained in playlists" directly

Post by ekant »

Hello Ludek,
thank you very much. I saw your answer just now (did not receive a notification...?).
I will try this and give a report, if and how it works.

Would be a big help to create new playlists (for freedance and meditation evenings) without repeating the favorite tracks too often.
Post Reply