Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

macman7002

macrumors regular
Original poster
Apr 28, 2008
100
0
Can anyone help explain why this script doesn't yield the expected result of decreasing Spotify's volume by units of 10? When I run it for iTunes, iTunes will decrease from say 100 to 90 to 80. Any ideas why it doesn't work the same with Spotify, and how I could correct it?

While we're at it, is there a better way I could rewrite this subroutine?

Thanks for the help!

Code:

Code:
tell application "Spotify"
	set currentVolume to sound volume
end tell

on fadeOut(currentVolume, desiredVolume, delayTime)
	tell application "Spotify"
		set currentVolume to sound volume
		repeat while currentVolume is greater than desiredVolume
			set sound volume to currentVolume - 10
			set currentVolume to sound volume
			delay delayTime
		end repeat
	end tell
	
end fadeOut

fadeOut(currentVolume, 30, 10)

Response:
Code:
tell application "Spotify"
	get sound volume
		--> 100
	get sound volume
		--> 100
	set sound volume to 90
	get sound volume
		--> 89
	set sound volume to 79
	get sound volume
		--> 78
	set sound volume to 68
	get sound volume
		--> 67
	set sound volume to 57
	get sound volume
		--> 56
	set sound volume to 46
	get sound volume
		--> 45
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.