Thanks to Sean Heisler for giving me the motivation to play around with this.

Setting the scene

You listen to music through Spotify. You listen at work, on your Mac, and when you leave for lunch or at the end of the day, you connect your iPhone to your car stereo or EarPods to listen to Spotify on the commute home.

The Problem

You were listening to a specific song, on an album or playlist, and you want to continue listening from where you left off. Sean had asked me if there was a simple way to do this and after we both explored the app and the forums we determined that there wasn’t something already out there.

The Solution

**In short**: I wrote some AppleScript that builds and sends a Spotify URL of the current track in Spotify for Mac to your iOS device. You can run this directly from the script or build a Service using Automator and tie it to a keyboard shortcut. Fork it on github here – [https://github.com/wdadev/SpotifySync](https://github.com/wdadev/SpotifySync "SpotifySync on github") – or copy and paste the AppleScript below in Script Editor on your Mac. https://gist.github.com/wdadev/4a7f3671e326618a1653

Setting it up

I’m going to focus on setting this up as a Service using Apple’s Automator app. There are many other ways to get this script to run but I like using the built in tools as everyone already has them.

Pre-flight Checklist

  1. As far as I know this only works on a Mac and iOS device (I have tested with an iMac running 10.10 and iPhone and iPad running 8.0.2).
  2. You need Spotify on both your Mac and iOS device (I’m a Premium subscriber but I don’t think that matters).
  3. You need Messages (Apple’s built in IM client) configured with iCloud on both devices (Mac and iOS).
  4. You need to have an existing conversation started with the phone number or iCloud email you are sending the message to.

Creating the Service

  1. On your Mac, open up Automator (in the system Applications folder) and choose New Document from the open dialog box (lower left corner).
  2. Choose Service from the menu that drops in.
  3. Select Run AppleScript from the action menu. You can search for it or choose it under Utilities from the Library (see videos below)

AppleScript in Automator

AppleScript in Automator with search

  1. Copy the AppleScript above and paste it in place of the (* Your script goes here *) text in your Automator window.
  2. In the text you just pasted into Automator, find the line that contains [Your Phone Number Here] and replace that text with your phone number or iCloud email address that is set up on your iOS device.
  3. Now open up Messages and compose and send a message to that same number/email.
  4. Switch back to Automator and click the Run button (highlighted in the image below). This should bring Spotify to the foreground and send an iMessage with a link in it (see pre-flight checklist if you get errors)

Automator Run Button

  1. If everything ran correctly you will have received the message on your iOS device with the link. Clicking that link will open Spotify on the device and start playing the track.
  2. Jump back over to Automator on your Mac and save the service (File>Save) and name it something memorable. Spotify Sync is an easy choice.

Bonus Step

For a quick and easy way to run the script lets to set up a keyboard shortcut for it. That way as you’re running out the door you can bang on your keyboard and send the song over to your iOS device.

  1. Open System Preferences, select Keyboard. From the menu tabs select Shortcuts and then choose Services from the left menu. Scroll to the bottom to find your newly created service, under General and select it.
  2. To the right of your selected Service you see a button that reads “add shortcut.” Click that button and then punch in the combination of keystrokes you wish to use to activate the Service. Choose something unique so you don’t get conficts. I have mine set to ⌃⌥⌘I

Keyboard shortcut for newly created Service

I encountered a few issues when adding the Service on other people’s Mac’s so if you have any problems feel free to get in touch and I’ll help anyway I can.