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

Mephistopelus

macrumors newbie
Original poster
Oct 12, 2012
10
0
A script made for muting Spotify ads is polling Spotify every 0.5 seconds. By doing it, it makes Spotify impossible to quit (it instantly relaunches).

Could anybody please help me solve this issue?
 
I have three solutions, two helpful, one not.

The helpful:

Try polling every few seconds instead of every half second. That way the application can still quit.

Create a 'shutdown Spotify' script that quits the first script, then tells Spotify to quit.

The unhelpful:
Throw them $5/month for Spotify Unlimited and the ads go away.
 
I have three solutions, two helpful, one not.

The helpful:

Try polling every few seconds instead of every half second. That way the application can still quit.

Create a 'shutdown Spotify' script that quits the first script, then tells Spotify to quit.

The unhelpful:
Throw them $5/month for Spotify Unlimited and the ads go away.

Hi!

1. This way, the ads won't be muted "instantly".

2. Thanks for the idea! I still hope to find a way to fix the script in the first place, though.

3. I would love to! But in my country, Spotify (and practically all of the other American and EU services) do not work. So they won't take my money.
 

Attachments

  • Screen shot 2012-10-16 at 23.04.23.png
    Screen shot 2012-10-16 at 23.04.23.png
    39.2 KB · Views: 128
  • Screen shot 2012-10-16 at 23.04.01.png
    Screen shot 2012-10-16 at 23.04.01.png
    22.3 KB · Views: 110
Post the code of your script. I get an error eg error "This script contains uncompiled changes and cannot be run." when trying to open it. I'm running Snow Leopard. The Read My Scripts utility found at this link http://www.macosxautomation.com/applescript/apps/readmyscripts.html says it's Not an uncompiled script.

Wow, thanks.

Here it is:

Code:
repeat #Repeat forever
	try #Try to do this thing, and on error... (look at "on error" at the bottom)
		tell application "Spotify"
			#Setting variables
			set cur_vol to sound volume
			set trackk to track number of current track
			set namme to name of current track
			set pop to popularity of current track
			set dur to duration of current track
			set pos to player position
		end tell
		
		if pop is 0 and dur is less than 40 then #If popularity is 0 and duration of current track is less then 40
			tell application "Spotify" #Do our thing
				pause
				set sound volume to 0
				play
			end tell
			delay dur - pos + 1 #When an ad ends,
			tell application "Spotify"
				set sound volume to cur_vol #restore the volume to the level it was before
			end tell
		else
			delay 0.5 #If nothing worked (it must be a music track, not an ad), try and run this script again in 0.5 seconds.
		end if
		
	on error errorMessage #On any error 
		delay 0.5 #Run this script again in 0.5 seconds
	end try
	
end repeat
 
Try this :

Code:
repeat
	tell application "System Events"
		set isRunning to (count of (every process whose bundle identifier is "com.spotify.client")) > 0
	end tell
	if isRunning then
		-- do your stuff with Spotify
	else
		exit repeat
	end if
end repeat
 
Try this :

Code:
repeat
	tell application "System Events"
		set isRunning to (count of (every process whose bundle identifier is "com.spotify.client")) > 0
	end tell
	if isRunning then
		-- do your stuff with Spotify
	else
		exit repeat
	end if
end repeat

That's it! Thank you so much!
 
Try this :

Code:
repeat
	tell application "System Events"
		set isRunning to (count of (every process whose bundle identifier is "com.spotify.client")) > 0
	end tell
	if isRunning then
		-- do your stuff with Spotify
	else
		exit repeat
	end if
end repeat

Hi!
Do you by any chance know how to detect if Spotify is playing currently?
It would be of great help to me!

Update:
I've found it!
Sorry:)
 
Last edited:
Code:
tell application "Spotify" to set playerState to player state


Tip :Take a look at the Spotify dictionary in scripteditor to see
how to use it with Applescript.
 
Code:
tell application "Spotify" to set playerState to player state


Tip :Take a look at the Spotify dictionary in scripteditor to see
how to use it with Applescript.

Wow, thank you a billion times!
Didn't know about the dictionary :)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.