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.
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.
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.
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.
- 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).
- You need Spotify on both your Mac and iOS device (I’m a Premium subscriber but I don’t think that matters).
- You need Messages (Apple’s built in IM client) configured with iCloud on both devices (Mac and iOS).
- You need to have an existing conversation started with the phone number or iCloud email you are sending the message to.
Creating the Service
- On your Mac, open up Automator (in the system Applications folder) and choose New Document from the open dialog box (lower left corner).
- Choose Service from the menu that drops in.
- Select Run AppleScript from the action menu. You can search for it or choose it under Utilities from the Library (see videos below)
- Copy the AppleScript above and paste it in place of the (* Your script goes here *) text in your Automator window.
- 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.
- Now open up Messages and compose and send a message to that same number/email.
- 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)
- 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.
- 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.
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.
- 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.
- 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
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.