Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --
- -- Created by: Alan Duncan
- -- Created on: 2018-01-11
- --
- -- Copyright (c) 2018 OjisanSeiuchi
- -- All Rights Reserved
- --
- use AppleScript version "2.4" -- Yosemite (10.10) or later
- use scripting additions
- property minimumVolume : 10
- -- initial volume, set by user
- global volume0, trackRepeatMode0
- on run
- set trackDuration to the text returned of (display dialog "Minutes to play track?" default answer "5")
- tell application "iTunes"
- set volume0 to sound volume
- set trackRepeatMode0 to song repeat
- -- probe to see that we have a track selected
- try
- set t to the current track
- on error errMsg number errNum
- if errNum is -1728 then
- display dialog "Please select a track first"
- else
- display dialog "Unable to begin playback"
- end if
- return
- end try
- -- set track repeat 1
- set song repeat to one
- -- begin playing track
- set player position to 0
- play
- -- calculate the delay between fades
- set fadeDelay to (trackDuration * 60) / (volume0 - minimumVolume)
- repeat with i from minimumVolume to volume0
- delay fadeDelay
- set sound volume to (sound volume) - 1
- end repeat
- -- stop playing
- pause
- set player position to 0
- -- restore iTunes settings
- set sound volume to volume0
- set song repeat to trackRepeatMode0
- quit me
- end tell
- end run
Add Comment
Please, Sign In to add comment