Say you're having a party with a few of your friends, and a few of their friends, and so on. You grab your phone, load up Spotify, and plug in the aux cord. You've got this awesome playlist, probably called mah sickest jamzz and you spent something like 9,200 hours picking the best songs for the people to dance to.

Suddenly you're confronted by a bunch of armchair DJs.

Ugh, I hate this song!

I'm not really a fan of X, can you put some Y on instead?

lol bruh what is up with your playlist, give me the phone, I only play the hottest music

And, of course, endless song requests.

You could oblige and let these people mess with the play queue and screw around with your playlist, but they keep locking your phone and you have to keep coming back to enter the PIN, or someone else comes up to complain about the new music anyway.

What it does

Chord puts the proverbial aux cord in the hands of everyone in the party. Anyone with the app can create a "party" which:

  1. Plays from a Spotify playlist first.
  2. Allows people in the same party to suggest and vote on songs to be queued up.

App users can discover parties near them by being connected to the same Wi-Fi network (or LAN in general, but 4G can be really broken with this).

Using mystical voodoo powers, Chord is able to locate parties on the same network, present a list of said parties, and let you join any of them you want.

How I built it

Essentially a client-server model with network discovery. The party host becomes a server which is responsible for playing/queuing songs and determining the outcomes of votes. Everyone else is just a client that connects, sees what's playing, and votes.

Device discovery is done using Android's Network Service Discovery (NSD). Upon creating a server, the IP address and port are announced via NSD, which clients can then query to find Chord servers.

Important resources:

  • Spotify Android SDK for API calls and the streaming SDK. Everything in this app is done through Spotify. The downside to this is that only premium users can host parties, as the streaming permission is premium-only.
  • Kryonet for networking. Makes it really easy to create request/response classes and communicate between the server and client. This is literally the glue holding this thing together and I would not have been able to come anywhere close to how far I got in this 36 hours without it.
  • Stack Overflow. Not a library but extremely handy for finding one-off snippets to abuse by copying and pasting throughout the code to save a decent chunk of time. Also has better documentation than Spotify (see below).

Challenges I ran into

The UX is about as ugly as the code and there are more than a few broken actions. For example, the "refresh" action on the party menu is a no-op, and isn't necessary so it could easily be removed. Moreover, in the rush to get this to at least a semi-working state, a lot of the code is spaghetti. Oh well.

By far the biggest issue I ran into was simply testing this app. It's only really possible to test this on a physical Android device, as it relies on Wi-Fi, which is not available in Android emulators, and I only had one physical device on hand for testing. All I'll say is that it probably works. This also ruins the entire presentation because I can really only demo this with at least two devices.

Lastly, the Spotify API documentation is terrible. If you try to do something like this, you'll probably be looking at GitHub issues and Stack Overflow for code reference more than their docs.

Stuff I did and learned

I figured out how to get the Spotify API to play music after a grueling three hours to write maybe 100 lines of code. BUT IT WORKS NOW. I also learned about Android's NSD management for announcing services, which is pretty nifty, and how to use Intents and a custom Application class in Android for managing the application state, even if done in a kind of half-baked effort.

What's next for Chord

Code needs a massive cleanup and will probably need to be rewritten (for the third time). UI needs to be polished a little bit more. From there it'll likely end up on the Play Store.

(An iOS port will be difficult, though as I don't have a Mac. Either I'll work with an iOS dev or just work on the Macs in the CS labs.)

Built With

Share this project: