Displaying the Stop Description as a Notification at the end of Songs

I just wrote this script in response to a customer request and thought it might be useful to others as well.

This project script reacts to song changes and displays the stop description of the previous song after jumping to the next one at the end of the song:

// How recent the playback stop must be (in ms) relative to the song jump
const MAX_STOP_AGE_MS = 1000;

let lastStopTime = 0;
let previousStopDescription = osc("/setlist/activeSongStopDescription");

// Track exactly when playback transitions from playing to stopped
onOscChange("/global/isPlaying", ([isPlaying]) => {
  if (!isPlaying) {
    lastStopTime = now();
  }
});

onOscChange("/setlist/activeSongIndex", () => {
  const stoppedRecently = now() - lastStopTime < MAX_STOP_AGE_MS;

  if (previousStopDescription && stoppedRecently) {
    sendOsc("/notify/big", "all", previousStopDescription, 6000);
  }

  previousStopDescription = osc("/setlist/activeSongStopDescription");
}, true);

For this to work, the “Auto-Jump to the Next Song” setting needs to be enabled.

2 Likes