A democratic music player for offices

Jesse Ditson
jesseditson
Published in
3 min readJan 11, 2014

I’ve been playing a lot of music in the We Heart It office lately.

I usually just put on my Last.fm or add stuff to a Spotify playlist as I go — however, I have a wide range of music taste, some of which is not office appropriate. I’ve gotten a reputation for playing music nobody has heard of, and sometimes songs come on that people don’t like. I’m more than happy to skip them, but usually people are too nice to let me know that they’re not digging my current song.

We use Heartbot, a Hubot clone in our campfire, so I added a quick script this afternoon to allow people to ask heartbot what I’m playing (it just does some regexing on my Last.fm now page) . This is cool, but didn’t really solve the issue of people not liking the music, so I decided to write something a little more complex to allow people to skip the current song if they’re not into it.

Enter remote-skip, a package of scripts & servers that allows people to request a skip from campfire. Here’s how it works:

  • A user clones the repo (no fork needed), and sets up a heroku server for it (or connects it to an existing one).
  • The user optionally pushes the repo to heroku, which runs a server that listens for clients and handles requests from heartbot.
  • The user then runs a local server, which proxies via ngrok to a public url. This server also pings the heroku server to let it know that the client is ready to accept skip requests.
  • When heartbot hits the skip url, it then sends requests to all of the connected clients asking them to skip.
  • When a client receives a skip request, it pops up a dialog asking the user if they’d like to accept or deny the skip request.
  • If the request is approved, the client uses node-applescript to select the skip menu item from any running music players.
  • Once a decision is made, heartbot reports back to the user wether or not the skip was approved.

Here’s what that process looks like in practice:

It currently supports Last.fm, Spotify and iTunes, but can be easily extended to support any application.

Like any good democracy, the person playing the music has veto power if they really want to hear the song, or if someone is just being annoying in campfire. However, the dialog expires and the song is skipped automatically after 15 seconds, in case I’m away from my desk and some At The Gates comes on.

So far it’s working smoothly — because the remote server can support multiple clients, any number of people can point to the same remote app, and it will send skip requests to any connected clients. If a client disconnects or restarts, the server automatically drops old clients after 30 seconds, so it’s not necessary to babysit it, just start the server and forget.

Here’s the repo for remote-skip:

https://github.com/jesseditson/remote-skip

Give it a whirl, setup only takes a few minutes (including adding the script to your hubot), and it’ll work with any client — so in theory, you could arduino a big red skip button and stick it at someone’s desk — it’s just HTTP, so anything that can speak internet can now skip your music!

In addition, this combination of a publicly exposed local applescript runner has all sorts of cool application. Nearly anything on your mac can be automated remotely using the same concepts — I’d love to hear any cool ideas you think of, or fork away and give your hubot a little more power.

Questions? Stick them in the comments or file a github issue, and I’ll do my best to help get your office music setup better for everyone.

Originally published at jesseditson.com on January 11, 2014.

--

--