Skip to content

Instantly share code, notes, and snippets.

@ellcom
Created August 2, 2014 17:02
Show Gist options
  • Save ellcom/58f47d7eeb3601734ef9 to your computer and use it in GitHub Desktop.
Save ellcom/58f47d7eeb3601734ef9 to your computer and use it in GitHub Desktop.
Tell spotify to play/pause using AppleScript
using terms from application "Spotify"
if player state of application "Spotify" is paused then
tell application "Spotify" to play
else
tell application "Spotify" to pause
end if
end using terms from
@gcerquant
Copy link

A more simple version is possible (Things might have changed since 7 ! years, ago):

using terms from application "Spotify"
	tell application "Spotify" to playpause
end using terms from

@B1zguy
Copy link

B1zguy commented Feb 11, 2022

Another alternative I found in this thread may be of help. It allows execution if play state is either 'playing' or 'paused':

if player state is playing or player state is paused then

E.G

if application "Spotify" is running then
	
	tell application "Spotify"
		
		if player state is playing or player state is paused then
			
			set trackID to (get id of current track)
			
		end if
		
	end tell
	
end if

Like gcerquant, this could've worked because things have changed over the years. I tried it in Catalina (10.15.7) when working on my own Spotify-Applescript program.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment