KZAK: an open source web-based jukebox

I’m happy to announce that I’ve made my latest side-project open source. It’s called KZAK. It’s a simple web-based jukebox that you can use to share and listen to music with your friends.

The feature set is pretty limited right, but I hope to continue to improve things over time. I’m already encouraged by how quickly some of my friends have taken to the app, and I think you’ll enjoy it – even in this early form.

So far you can:

  • Invite people to use the site via email
  • Upload mp3, mp4, and m4a (iTunes) tracks with an upload queue and progress
  • Listen to the uploaded music as a playlist, even in an inactive browser tab

Like I said, it’s pretty basic (invite, upload, listen) but surprisingly functional. Plus, I’m using all kinds of interesting stuff behind the scenes, which is why I really wanted to share the code😉

To begin with, we’ve got a Rails app that’s using the latest and greatest in user authentication technology: Devise. If you’re using something like restful_authentication or Authlogic, I implore you to take a look at Devise. It’s a phenomenal improvement from these other two popular options, and it’s being actively supported by José Valim, the latest Rails committer. Essentially, it’s a Rails Engine that sits on top of Warden – a generalized Rack authentication framework. This combination is extraordinarily flexible and easy to use. It’s opinionated (in a good way) while simultaneously doing a good job of staying out of the way. It introduces very little code into your application, and the source is well documented, well tested, and easy to follow. A++ highly recommended.

To handle the file uploads, I’ve switched from Paperclip to CarrierWave. While Paperclip has (and continues) to serve me well in many applications I work with, I really appreciate the modular approach that CarrierWave takes. It’s agnostic as to which of the popular S3 clients you use, supporting both aws/s3 and right_aws. It’s also ORM agnostic and not tightly coupled to Active Record. The tight coupling of Paperclip has caused us some grief at work, and I’m also confused about the state of Paperclip’s support for aws/s3 and right_aws. So, I was happy to find this new project, and the maintainer Jonas Nicklas seems to be an extremely responsive and helpful dude, which is always good thing. The code looks great, and I’ve had an easy time working with this library so far.

In concert with CarrierWave, I’m also using the venerable SWFUpload to support upload queues and progress meters. I’m absolutely baffled as to why this kind of thing isn’t easy/possible to support without Flash, but here we are. Of course, I have a fallback “regular upload form” that still uses some ajax to make things a little easier. There are a few blog posts and tutorial applications around on GitHub that helped me get SWFUpload working with Rails and jQuery, and I’m happy to put back out an example application that other people can refer to if they’re interested in supporting upload queues and/or upload progress meters.

Next, to support audio playback while I work on supporting html5 properly, I’m using the extremely awesome SoundManager 2. Unfortunately, this is another part of the infrastructure using Flash, but the features and functionality of SoundManager are really something special. I’ve only scratched the surface of what this library can do, but I’m already enjoying it quite a bit. If you’re working with jQuery and SoundManager, you may find the KZAK source code worth perusing. You might also take a look at Adrien Gibrat’s plugin, which is a cool jQuery plugin that packs a lot of functionality.

Also running in the background of KZAK is a Twitter-style following/unfollowing system that I haven’t exposed much of yet. It’s basically the same system that’s powering Flowcoder. You can check out this example app I made if you’re interested in seeing that on its own. Currently, all users in the system follow (and are followed by) all of the other users. I plan to allow for “unfollowing” users some time soon, which will allow for some healthy splintering of the community in the case that you’re not interested in everything that everyone is uploading.

Finally – and perhaps best of all – KZAK is fully compatible with and easy to install on Heroku. All you need is an S3 account and you’re ready to get started with a web-based jukebox for you and your friends for free.

http://github.com/trevorturk/kzak

Anyway, please feel free to dig around the source code if you’re interested in any of this. I think there’s a lot of good stuff in there, especially considering that the Ruby portion of the app is clocking in at under ~250 LOC right now. Thanks, open source community😉

Published by

Trevor Turk

A chess-playing machine of the late 18th century, promoted as an automaton but later proved a hoax.

11 thoughts on “KZAK: an open source web-based jukebox”

  1. very cool!

    Regarding SWFUpload; I've recently switched to Uploadify, which is an awesome and very flexible jQuery plugin. You should try it out.

  2. Can you talk a little more about why you recommend Devise so highly over the other solutions? I've been using Authlogic and have been 90% satisfied with it, but i'm very open to another solution.

    Mike H

  3. Daniel, I looked at Uploadify, but I was a little disappointed because it seemed hard to customize the way it looks. I'll give it another chance, though, because SWFUpload seems to really chug with Chrome.

    Mike, I think this is somewhat of a personal choice, and everyone has different opinions about authentication. I started using restful_authentication a long time ago, and I've had a lot of experience with it. At this point, I prefer not to use it because it generates a lot of application code, most of which is boilerplate. It also uses some constants that are stored in the plugin folder, so it's kind of a hybrid generator/plugin, which I also don't like. It also enforces one kind of authentication, and isn't based on something like Warden, which is meant to play well with other Rack apps you may be using. Devise also does a great job of staying out of the way, while still being very customizable. Devise also lets you have multiple "user" models (e.g. "user" and "admin" can be different and have different authentication methods).

    I tried Authlogic a couple of times, and I immediately didn't like it. Primarily, I found the source difficult to follow, and I didn't like that it enabled model validations by default. I also saw a few tweets from people I respect saying that they ran into problems with it, and ended up finding it difficult to debug. I think the Warden/Devise combo is extremely easy to understand, and the source is easy to follow. So, if you run into a problem, you should be able to figure out what's going on.

    Finally, it's a an actively maintained project with some really good and responsive people working on it. It's using the new style Engines, works nicely as a gem, and they say they're working on Rails 3 support as we speak. I'd say you should give it a try – I really doubt you'll be disappointed.

  4. I'll second Trevor's recommendation of Warden/Devise. The most important improvement over Authlogic is definitely the simplicity of the code. I've had a lot of trouble debugging Authlogic in the past and the simplicity of Devise is absolutely refreshing.

    I am excited to try CarrierWave…

  5. Hi,

    This sounds interesting – I follow and work with Soundmanager2 quite a bit. But I'm note a real hard-core coder, I'm someone who works more with how technologies get used by end -users… you know, regular folks. To that end, is there anywhere where kzak is running so we can just, you know, try it? It's interesting to hear about all the technologies behind the scenes and download code and all… but what does this thing do, actually?

    With respect,

    John

Comments are closed.