Skip to content

Instantly share code, notes, and snippets.

@johnstcn
Created September 11, 2021 11:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnstcn/725438aa7f99e75badf587b244590e51 to your computer and use it in GitHub Desktop.
Save johnstcn/725438aa7f99e75badf587b244590e51 to your computer and use it in GitHub Desktop.
(function({fadeDuration=5000}={}) {
function fadeOutPlaylist(playlist, fadeDuration) {
if (!playlist.playing) return;
let playingSound = playlist.sounds.filter(s => s.playing).find(_ => true).sound;
if (!!!playingSound) return; // should not happen
let currVol = playingSound.volume;
let globalVol = game.settings.get("core", "globalPlaylistVolume");
if (currVol == 0) return;
playingSound.fade(0, { duration: fadeDuration, from: currVol})
setTimeout(() => playlist.stopAll(), fadeDuration);
return;
}
game.playlists.filter(p => p.playing).forEach(p => fadeOutPlaylist(p, fadeDuration));
ui.notifications.info("Stopping all playlists");
})({fadeDuration: 5000});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment