Spotify Apps -- a taste of the future of desktop apps?
I had a go at building a Spotify App at the weekend. I was pleasantly surprised how simple and intuitive it is. Enjoyable too -- highly recommended. If you've ever tried any client-side web development, you're already familiar with the technologies involved. Premium account not required. Have you tried it yet? What did you think?
A Spotify App is really just an Index.html file which you can hack any way you want, along with any CSS or JS files -- just as you might expect from a HTML5-based dev platform. It seems you can access every aspect of the Spotify application, from the obvious stuff like user data and playlists etc to the player engine; and more too including authentication, some evidence of filesystem access, third-party social platforms and APIs, etc.
// Spotify App JavaScript example: get playlist.
var playlist = sp.core.getPlaylist('spotify:user:tim_acheson:playlist:64WuH2cJahz6BYDLKVWJ5m');
for (i=0; i<=playlist.length; i++) {
var track = playlist.getTrack(i);
console.log(track.name);
}
The first thing I noticed, just by traversing the object model with my JavaScript code, is that there's much more to it than what's currently covered in the documentation. In fact, I even found myself wondering whether developers were supposed to be meddling with some of this stuff yet...
Another thing that really struck me is how nice it is being able to extend desktop software using existing technologies and knowledge and skills I already have from developing for the web. I could imagine this sort of think being the future of desktop apps. I hope building Windows 8 apps using HTML5/JS/CSS is a bit like this! ;P
The richness of the objects available to the JavaScript reminded me of working with Silverlight using JavaScript. (Silverlight embedded in a web page is integrated with JavaScript by default in stark contrast to Flash where the developer has to explicitly write daft boilerplate ActionScript for every aspect of the Flash-JavaScript bridge, and even then the resulting object model in JavaScript is inflexible and often counter-intuitive).
Documentation
- Introduction to Spotify Apps (for users)
- Download the next version of Spotify (beta version to preview the new Apps feature)
- Spotify Apps API (docs for developers)
- Spotify App developer guidelines
- Spotify App development example (with downloadable example)
- Spotify App basic API Reference and object model
Also, here's my concise and abridged quick-start Spotify App JavaScript API reference, which I jotted down as I played with it. ;)
-
sp.core (main Spotify functionality)
- sp.core.country
- sp.core.user
- sp.core.product
- sp.core.library
- sp.core.getAuthToken
- sp.core.getMetadata
- sp.core.getPlaylist
- sp.desktop
- sp.social
- sp.trackPlayer (the audio player engine)
- sp.whatsnew
- sp.installer
- sp.require
- sp.requireAsync
I'll add to this too, because there's a stuff that the official documentation doesn't mention -- a lot of stuff which you wouldn't even know is there! So watch this space...
If you have any questions, feel free to ask me -- if it's your first attempt, I might be able to save you running into problems or questions that I've already sorted out.
Enjoy! ;)
08 December 2011
Tags: spotify app api html5 apps hack mash-up
Comments: 1
Add Comment
Related: Will Spotify create a new breed of HTML5 developer?