Skip to content

Commit

Permalink
Fix playlist movement bug (Issue#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
calzoneman committed Apr 2, 2013
1 parent fab4039 commit c175f46
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ var Channel = function(name) {
pl: this.queue
});
this.currentPosition = data.currentPosition - 1;
this.playNext();
if(this.currentPosition < -1)
this.currentPosition = -1;
if(this.queue.length > 0)
this.playNext();
this.opts = data.opts;
if(data.filters) {
this.filters = new Array(data.filters.length);
Expand Down Expand Up @@ -750,8 +753,13 @@ Channel.prototype.moveMedia = function(data) {
return;

var media = this.queue[data.src];
this.queue.splice(data.dest + 1, 0, media);
this.queue.splice(data.src, 1);
// Took me a while to figure out why the queue was going insane
// Gotta account for when you've copied it to the destination
// but not removed the source yet
var dest = data.dest > data.src ? data.dest + 1 : data.dest;
var src = data.dest > data.src ? data.src : data.src + 1;
this.queue.splice(dest, 0, media);
this.queue.splice(src, 1);
this.sendAll("moveVideo", {
src: data.src,
dest: data.dest
Expand Down

0 comments on commit c175f46

Please sign in to comment.