Page 2 of 2

Re: IncrementPlayerCount / DecrementPlayerCount

Posted: Fri Jun 17, 2022 10:15 pm
by Barry4679
Erwin Hanzl wrote: Fri Jun 17, 2022 6:01 am This request was from 20.9.2021 - and today, 9 months later, you answer.
I didn't notice that the beginning of this thread was that long ago.
But I was primarily responding to your suggestion from a few days ago.
There is a bug worth knowing about in the facility that you suggesting.
I wanted to warn about that. You have a problem with that?

Re: IncrementPlayerCount / DecrementPlayerCount

Posted: Sat Jun 18, 2022 2:03 am
by Erwin Hanzl
If you read my post carefully, I'm referring to individual songs, with a note on multi-selection - direct entry of the Played# value.
NOTHING is added.

And no, I have no problem with your reference.

Re: IncrementPlayerCount and set Last Played to now

Posted: Sun Aug 14, 2022 9:33 pm
by OzPonder
I found this thread researching options to resolve a similar sync need, and followed the suggestion to clone and modify the swapArtistTitle script to achieve both incrementing the playCounter and Last Played date (I drive a few smart playlists from Last Played). Here it is if it helps anyone:

Code: Select all

// C:\Program Files (x86)\MediaMonkey 5\Scripts\setLastPlayed\actions_add.js
// A simple script that sets last played
actions.setLastPlayednow = {
    title: _('Set Last Played to now'),
    hotkeyAble: true,
    disabled: uitools.notMediaListSelected,
    visible: window.uitools.getCanEdit,
    execute: async function () {
        var list = await uitools.getSelectedTracklist().whenLoaded();
        if (list. Count === 0) {
            return;
        }
		
        var msg = sprint(_('Are you sure that you want to set Last Played to now on %d files ?'), list.count);
        messageDlg(msg, 'Confirmation', ['btnYes', 'btnNo'], {
            defaultButton: 'btnNo',
            title: _('Set Last Played to now'),
        }, function (result) {
            if (result.btnID === 'btnYes') {
				var tmp;
				list.forEach(function(itm) {
					// Swap the fields
					itm.beginUpdate();
					itm.lastTimePlayed_UTC = app.utils.timestamp2DateTime( new Date().toISOString());
					itm.playCounter = itm.playCounter + 1;
					itm.endUpdate();
				});
				list.commitAsync();  
            }
        });                      
    }
}

window._menuItems.editTags.action.submenu.push({
        action: actions.setLastPlayednow,
        order: 22,
        grouporder: 10
});