12

Essentially what I'd like to do is play an entire album via AppleScript. Right now, you can use their special URIs to load the album, but not play it. You can also play a specific track, but once that finishes playing, your queue resumes what was playing before.

Spotify's scripting dictionary is somewhat thin, does anyone know if there are plans to increase its depth a bit?

Jesse
  • 551
  • 1
  • 5
  • 8
  • I know that there are 3rd party libraries that allows you to stream music and maybe that's an option. It does require a premium license though. It also seems like they have their own library, but not sure how powerful it is. http://developer.spotify.com/en/libspotify/overview/ – eandersson Jan 17 '12 at 20:53

3 Answers3

30

More recent versions of Spotify have added this to the dictionary. For example:

tell application "Spotify"
    play track "spotify:album:7ppypgQppMf3mkRbZxYIFM"
end tell
Jesse
  • 551
  • 1
  • 5
  • 8
  • Sick. +1 for both of you. – crunkchitis Apr 18 '14 at 18:24
  • 15
    For those that might be curious as to where these commands are defined, open the `Spotify.app/Contents/Resources/Spotify.sdef` file. (via https://github.com/dronir/SpotifyControl/issues/2#issuecomment-8686456) – Sergio Oct 13 '14 at 03:40
  • 3
    The exact location (for those unfamiliar with Mac) is `/Applications/Spotify.app/Contents/Resources/Spotify.sdef` – Jordan Réjaud Oct 29 '20 at 12:05
11

If you want to play/pause whatever was most recently playing you can use the following scripts. If you save each of them as Automator applications and you can run them from Spotlight or Alfred.

Play:

tell application "Spotify"
    play
end tell

Pause:

tell application "Spotify"
    pause
end tell
Matt
  • 9,068
  • 12
  • 64
  • 84
  • 2
    Or if you want to toggle the state, you can pass `playpause`. You can also pass `next track` and `previous track`. There is a nice resource on this here: https://gist.github.com/NoobsArePeople2/5121597 and here are some nice applescripts for getting/setting the volume https://coderwall.com/p/22p0ja/set-get-osx-volume-mute-from-the-command-line – RobertMcReed Apr 07 '20 at 16:40
2

There's currently no way to do this with the current dictionary. We'd like to expand it in the future, but I'm not aware of any concrete plans to do so at the moment.

iKenndac
  • 18,730
  • 3
  • 35
  • 51