Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- The fadetime in seconds
- property fadetime : 3
- -- The target Volume of the fade 0-100
- property targetVolume : 0
- -- Pause the player when the fade is done true/false
- property stopWhenDone : false
- -----------------------------------------------------------------------------
- tell application "Spotify"
- set deltaVolume to targetVolume - sound volume
- if deltaVolume is not equal to 0 then
- -- calculate the time for each step to end
- set steptime to fadetime / deltaVolume
- -- inc/dec step size
- set step to 1
- -- if it is a decrease in volume
- if deltaVolume < 0 then
- set steptime to -steptime
- set step to -step
- end if
- -- Do the fade
- repeat with v from sound volume to targetVolume by step
- set sound volume to v
- delay steptime
- end repeat
- end if
- -- optional stop
- if stopWhenDone then pause
- end tell
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement