Guest User

Untitled

a guest
Jan 20th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. --
  2. -- Created by: Alan Duncan
  3. -- Created on: 2018-01-11
  4. --
  5. -- Copyright (c) 2018 OjisanSeiuchi
  6. -- All Rights Reserved
  7. --
  8.  
  9. use AppleScript version "2.4" -- Yosemite (10.10) or later
  10. use scripting additions
  11.  
  12. property minimumVolume : 10
  13.  
  14. -- initial volume, set by user
  15. global volume0, trackRepeatMode0
  16.  
  17. on run
  18. set trackDuration to the text returned of (display dialog "Minutes to play track?" default answer "5")
  19. tell application "iTunes"
  20. set volume0 to sound volume
  21. set trackRepeatMode0 to song repeat
  22.  
  23. -- probe to see that we have a track selected
  24. try
  25. set t to the current track
  26. on error errMsg number errNum
  27. if errNum is -1728 then
  28. display dialog "Please select a track first"
  29. else
  30. display dialog "Unable to begin playback"
  31. end if
  32. return
  33. end try
  34.  
  35. -- set track repeat 1
  36. set song repeat to one
  37. -- begin playing track
  38. set player position to 0
  39. play
  40.  
  41. -- calculate the delay between fades
  42. set fadeDelay to (trackDuration * 60) / (volume0 - minimumVolume)
  43. repeat with i from minimumVolume to volume0
  44. delay fadeDelay
  45. set sound volume to (sound volume) - 1
  46. end repeat
  47.  
  48. -- stop playing
  49. pause
  50. set player position to 0
  51.  
  52. -- restore iTunes settings
  53. set sound volume to volume0
  54. set song repeat to trackRepeatMode0
  55.  
  56. quit me
  57. end tell
  58. end run
Add Comment
Please, Sign In to add comment