Using node.js, electron, and AppleScripts to remotely control Spotify over the network from a stream deck via a REST API and socket.io

Somehow, it’s been a year since I’ve posted to this blog. I’ve been busy! Some financial circumstances in my family have meant I have needed to spend a lot of my spare time coding-for-hire. Over the past year, I’ve been developing custom apps, writing so many Companion modules, creating Ross Dashboard custom panels, and developing unique solutions through software development to meet the demands for clients. God continues to bring people to us who need my help, and He meets our needs.

I have also been hard at work developing solutions for the church.

  • Tally Arbiter is now in version 3.0 and continues to grow in support for more switchers and add more features.
  • PresentationBridge-Client has gained more features and continues to be a helpful resource for helping to automate church production.
  • I’ve written several more plugins for Cronicle to help with the various workflows around our facility. Every venue we support is managed through Cronicle now. As a room is reserved, we create the automated events, and people just show up! The AVL of the room is turned on and ready for them, automatically configured to meet the needs of their event.
  • TimeKeeper got some feature bumps as well, allowing us to easily automate things like switching OBS scenes “3 seconds before x timer ends”, etc. We even have it turning off the lights in the control room just as production is about to begin!
  • We are doing more and more with Companion to help our volunteers do more at the press of a button. Complex tasks on a video switcher are easy because they just press one button.

I’m excited to share my latest project here today that helps us meet a specific need at our church, and I hope will help you at yours. We use Spotify around the campus as people are walking in, pre-service music, etc. We have a dedicated Mac Mini running Dante Virtual Soundcard that outputs the Spotify music to our Dante VLAN. From there, any of the venues can receive the Spotify mix and play it – whether it is one of the auditoriums, the cafe/coffee bar, the outdoor speakers as people walk in, etc.

We run this Campus Spotify headless on the Mac mini so it’s located in a rack room where we never touch it. When we need to change playlists, we remote into the computer and control it. When we need to start/stop playing, we’ve been triggering an AppleScript file remotely to play/pause.

But that all just got a lot easier. I recently developed a node.js/electron app, for MacOS only, that will run in the system tray of this Campus Spotify machine. It controls Spotify using AppleScripts, and it gets data out of Spotify, like the current playing track, through Apple’s built-in Distributed Notification Center, which Electron can easily pick up and process. (Electron is the framework that allows you to create cross-platform “native” apps that can be run on the computer without having to install the node.js runtime. You might be surprised to learn that several apps you already use are written in node.js and use Electron!)

Why not just use the Spotify Web API? Sure – you could gain control of Spotify through their Web API – but for some users, the OAuth process and creation of App Keys is a stumbling block. This process is much easier – just download the app and run it!

To enable remote control, this app exposes both a simple REST API as well as socket.io connections for real-time event based communication. Whenever Spotify changes tracks or play/pauses, it will automatically communicate this information to any of the connected socket.io clients.

I’m calling the app, “spotify-controller”.

It runs in the system tray so it’s nice and tidy!

I’ve also created a partner Companion module to work with it. It supports variables, feedbacks, and presets to make things a lot easier to control!

When you’ve connected the Companion module to spotify-controller, you can see all of the playback information as variables.
Feedback status on buttons! This will update whether Spotify is controlled from Companion, another Companion instance, Spotify itself, Spotify from your phone…. anywhere!
You also get fancy little notifications whenever a song changes on the Mac running spotify-controller!

Like all of the software I write for the church, this is free and open-source. My hope is that it will not only help you use technology more effectively for ministry, but by releasing it open source, it will continue to foster a community for contribution. We can do so much more together when we share resources and time.

You can download this new app today over at my Github repository: http://github.com/josephdadams/spotify-controller/

The partner Companion module is available in the beta builds as well. If you’re a Cronicle user like us, the plugin to control it will be available here: https://github.com/josephdadams/cronicleplugins

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s