Created
April 2, 2011 12:34
-
-
Save mirka/899458 to your computer and use it in GitHub Desktop.
This file contains 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
property resolution : 10 (* Increase for smoother fades. Default: 10 *) | |
property delayIncr : 0.2 (* Decrease for faster fades. Default: 0.2 *) | |
tell application "iTunes" | |
set originalVol to sound volume | |
set volIncr to originalVol div resolution | |
if player state is not playing then | |
set sound volume to 0 | |
play | |
-- Fade in | |
repeat while (sound volume ≤ (originalVol - volIncr)) | |
set sound volume to (sound volume + volIncr) | |
delay delayIncr | |
end repeat | |
else | |
-- Fade out | |
repeat while (sound volume > 0) | |
set sound volume to (sound volume - volIncr) | |
delay delayIncr | |
end repeat | |
pause | |
end if | |
set sound volume to originalVol | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment