From 9ede4dbc2dcf7d2615d9510819d3b06c0c417a9a Mon Sep 17 00:00:00 2001 From: calzoneman Date: Wed, 6 Mar 2013 23:21:08 -0600 Subject: [PATCH] Fix end of playlist bug --- channel.js | 3 +-- user.js | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/channel.js b/channel.js index 987c418e..8e94281a 100644 --- a/channel.js +++ b/channel.js @@ -339,7 +339,6 @@ Channel.prototype.unqueue = function(data) { Channel.prototype.playNext = function() { if(this.currentPosition + 1 >= this.queue.length) { this.currentMedia = null; - this.currentPosition = -1; return; } this.currentPosition++; @@ -570,7 +569,7 @@ var time = new Date().getTime(); function channelVideoUpdate(chan, id) { // Someone changed the video or there's a manual leader, so your // argument is invalid - if(id != chan.currentMedia.id || chan.leader != null) + if(chan.currentMedia == null || id != chan.currentMedia.id || chan.leader != null) return; // Add dt since last update chan.currentMedia.currentTime += (new Date().getTime() - time)/1000.0; diff --git a/user.js b/user.js index 212546d2..37c2d254 100644 --- a/user.js +++ b/user.js @@ -116,6 +116,9 @@ User.prototype.initCallbacks = function() { this.socket.on('playNext', function() { if(Rank.hasPermission(this, "queue") || (this.channel != null && this.channel.leader == this)) { + if(this.channel.currentPosition + 1 >= this.channel.queue.length) { + this.channel.currentPosition = -1; + } this.channel.playNext(); } }.bind(this));