From 9929edba6167dafd80b1e9f6915aab17bf8da54c Mon Sep 17 00:00:00 2001
From: ale <ale@incal.net>
Date: Sun, 24 Jul 2011 16:16:43 +0100
Subject: [PATCH] hopefully fix addChunk / 3

---
 server/djrandom/frontend/static/player.js | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/server/djrandom/frontend/static/player.js b/server/djrandom/frontend/static/player.js
index 84b0160..09fa4bf 100644
--- a/server/djrandom/frontend/static/player.js
+++ b/server/djrandom/frontend/static/player.js
@@ -112,15 +112,16 @@ djr.Playlist.prototype.allSongs = function() {
 // Returns the chunk ID, or -1 if no songs were added.
 djr.Playlist.prototype.addChunk = function(playlist_chunk) {
   djr.debug('adding chunk to playlist ' + this.uuid);
-  chunk_id = this.next_chunk_id++;
+  var chunk_id = this.next_chunk_id++;
 
-  var songs = [];
+  var songs = [], i;
   for (i = 0; i < playlist_chunk.songs.length; i++) {
+    var song = playlist_chunk.songs[i];
     if (this.song_map[song]) {
       continue;
     }
-    songs.push(playlist_chunk.songs[i]);
-    this.song_map[playlist_chunk.songs[i]] = chunk_id;
+    songs.push(song);
+    this.song_map[song] = chunk_id;
   }
 
   if (songs.length == 0) {
@@ -183,7 +184,9 @@ djr.Player = function(backend, selector) {
 
   // Setup the jPlayer interface.
   this.player.jPlayer({
-    ready: function() {},
+    ready: function() {
+      djr.debug('player ready');
+    },
   });
   this.player.bind($.jPlayer.event.ended + '.djr', 
                    function () {djr.state.player.nextSong(); });
-- 
GitLab