Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Mar 18, 2013, 09: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

Similar Threads
thread Thread Starter Forum Replies Last Post
Incremental volume adjustments with AppleScript? wrignj08 Mac Programming 5 Jul 28, 2013 06:41 AM
Get current track from Spotify in Messages status(AppleScript) pinyourwings22 Mac Programming 6 Mar 26, 2013 08:13 AM
Mount ssh volume with Applescript MacPC Windows, Linux & Others on the Mac 2 Feb 18, 2013 06:36 AM
AppleScript to zip sub folders on a volume kevinless Mac Basics and Help 2 Nov 11, 2012 06:37 PM
Spotify issues since yesterday bhigh8 iPhone Tips, Help and Troubleshooting 6 Nov 8, 2012 10:47 AM

Forum Jump

All times are GMT -5. The time now is 12:47 PM.

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

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