Amazon Cloud Player, now with Keyboard Shortcuts & Growl Notifications!
Amazon Cloud Player, now with Keyboard Shortcuts & Growl Notifications!
…Sorta. :) Code is at GitHub! Explanation below:
Andy Lemay made a very useful post on how to use fluid to run Amazon CloudPlayer as its own app. In a nutshell: You can download an excellent application called Fluid to create a desktop version of a webpage - in this case, the newly released Amazon Cloud Player. This worked great, however I was hoping to get keyboard shortcuts and Growl notifications working. Luckily, Fluid has a UserScript API to allow you to write UserScripts (essentially just js files) which can be loaded into the web application.
Now to poke around! Digging into the page and js files in Amazon CloudPlayer revealed a nice API that I figured I could hack into. TextMate’s ‘Reformat Document’ was a huge help here to turn the minimized js files into something human readable.
The resulting UserScript I wrote polls amznMusic.widgets.player.getCurrent (which returns a lot of metadata on the current song playing) to display growl notifications when the metadata that it returns changes. The script also adds dock menu items to play/pause, play the previous song and play the next song. After some searching, I found that it’s possible to get keyboard shortcuts working with this, but it’s quite a hack. Keyboard triggers can be defined in Quicksilver to run AppleScripts, which in turn do some UI Scripting to “click” the dock menu items. There are a number of problems with this - it can be quite slow initially (taking up to a few seconds), you’ll see the dock menu flash on screen for a brief period, and you can’t use the media keys. It may be possible to overcome this by building a Cocoa plugin for Fluid, however I don’t have the Cocoa chops for that.
Get the code on the GitHubs. The README has a full rundown of all the steps you’ll need.