Permalink
Browse files

Adding option to load Sonos image. Fixes issue #12

  • Loading branch information...
1 parent aca5d03 commit defc1aa987776f1dcb30c769b2840efd8ba9dc95 @monsur committed Apr 30, 2015
Showing with 22 additions and 2 deletions.
  1. +2 −1 Gruntfile.js
  2. +3 −1 src/client/js/main.js
  3. +17 −0 src/client/js/sonos-album-art.js
View
@@ -35,8 +35,9 @@ module.exports = function(grunt) {
dist: {
src: [
'src/client/js/intro.js',
- 'src/client/js/last-fm-album-art.js',
'src/client/js/memory-cache.js',
+ 'src/client/js/last-fm-album-art.js',
+ 'src/client/js/sonos-album-art.js',
'src/client/js/screensaver.js',
'src/client/js/ui-controller.js',
'src/client/js/main.js',
@@ -1,6 +1,8 @@
var currentTrack = null;
var previousTracks = [];
-var albumArtCache = new MemoryCache(new LastFmAlbumArt(options.lastFmApiKey));
+var albumArtCache = new MemoryCache(
+ new LastFmAlbumArt(options.lastFmApiKey,
+ new SonosAlbumArt()));
var socket = io.connect();
var isPlaying = false;
@@ -0,0 +1,17 @@
+var SonosAlbumArt = function(proxyCache) {
+ this.proxyCache = proxyCache;
+};
+
+SonosAlbumArt.prototype.get = function(data, callback) {
+ callback = callback || function() {};
+
+ if ('albumArt' in data) {
+ return callback(null, data.albumArt);
+ }
+
+ if (this.proxyCache) {
+ return this.proxyCache.get(data, callback);
+ }
+
+ callback();
+};

0 comments on commit defc1aa

Please sign in to comment.