Created
September 11, 2021 11:01
-
-
Save johnstcn/725438aa7f99e75badf587b244590e51 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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