Track End-Time

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

Moderators: jiri, drakinite, Addon Administrators

rossy5502
Posts: 6
Joined: Wed Jan 19, 2022 9:10 am

Track End-Time

Post by rossy5502 »

looking for a script that help to edit end-time for a number of tracks at once example : track length minus last 18 seconds
the existing one need to be done for each individual track, it will be helpful if there is a syntax for the length of the track and all you have to do is add the minus what ever seconds from the end of the tracks, as each track length differ from the next one.
Thank you :D
Ludek
Posts: 4945
Joined: Fri Mar 09, 2007 9:00 am

Re: Track End-Time

Post by Ludek »

You can get inspired by the Andre's code here:
https://www.mediamonkey.com/forum/viewt ... 22#p493322

and instead of changing track.playCounter there use code like:

Code: Select all

track.stopTime = track.songLength - 18000; // milliseconds
rossy5502
Posts: 6
Joined: Wed Jan 19, 2022 9:10 am

Re: Track End-Time

Post by rossy5502 »

thank you so much luke, much appreciated, i am so bad at writing code, but i cannot for the life of me do it, if not too much trouble could you please show me where to change the code to
track.stopTime = track.songLength - 18000; // milliseconds
many thanks
Ludek
Posts: 4945
Joined: Fri Mar 09, 2007 9:00 am

Re: Track End-Time

Post by Ludek »

Sure, the code looks like:

Code: Select all

actions.subtractMilliseconds = {
    title: _('Sutract 18 seconds ...'),
    hotkeyAble: true,
    icon: 'edit',
    disabled: uitools.notMediaListSelected,
    visible: window.uitools.getCanEdit,
    execute: async function () {
        var list = await uitools.getSelectedTracklist().whenLoaded();
        if (list.count === 0) {
            return;
        }
        list.forEach(function (track) {
            track.stopTime = track.songLength - 18000; // milliseconds
            track.commitAsync();
        });
    }
}

window._menuItems.editTags.action.submenu.push({
    action: actions.subtractMilliseconds,
    order: 10,
    grouporder: 10
});
The whole addon to install is here: https://www.dropbox.com/s/98qig8vms1q69 ... .mmip?dl=0
i.e. go to menu Addons > Add ..., select the subtractSeconds.mmip and install it.

Usage: Select group of tracks > Edit tags > Subtract 18 seconds...
rossy5502
Posts: 6
Joined: Wed Jan 19, 2022 9:10 am

Re: Track End-Time

Post by rossy5502 »

Cannot thank you enough, God bless you and your family
that helped a lot
stay safe and thanks once again
Ross
Post Reply