Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Mar 18, 2013, 08:07 PM   #1
macman7002
macrumors regular
 
Join Date: Apr 2008
Issues Lowering Volume of Spotify with AppleScript

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
macman7002 is offline   1 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 08:10 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC