diff --git a/channel.js b/channel.js index 21310f35..2662c070 100644 --- a/channel.js +++ b/channel.js @@ -355,7 +355,7 @@ Channel.prototype.playNext = function() { Channel.prototype.update = function(data) { if(this.currentMedia == null) { this.currentMedia = new Media(data.id, data.title, data.seconds, data.type); - this.currentMedia.currentTIme = data.currentTime; + this.currentMedia.currentTime = data.currentTime; } else this.currentMedia.currentTime = data.seconds; @@ -476,6 +476,7 @@ Channel.prototype.changeLeader = function(name) { this.broadcastRankUpdate(old); } if(name == "") { + channelVideoUpdate(this, this.currentMedia.id); return; } for(var i = 0; i < this.users.length; i++) { @@ -563,6 +564,7 @@ function channelVideoUpdate(chan, id) { return; // Add dt since last update chan.currentMedia.currentTime += (new Date().getTime() - time)/1000.0; + time = new Date().getTime(); // Video over, move on to next if(chan.currentMedia.currentTime > chan.currentMedia.seconds) { chan.playNext(); @@ -571,7 +573,6 @@ function channelVideoUpdate(chan, id) { else if(i % 5 == 0) chan.sendAll('mediaUpdate', chan.currentMedia.packupdate()); i++; - time = new Date().getTime(); // Do it all over again in about a second setTimeout(function() { channelVideoUpdate(chan, id); }, 1000); } diff --git a/www/assets/js/functions.js b/www/assets/js/functions.js index d58f45de..7c337703 100644 --- a/www/assets/js/functions.js +++ b/www/assets/js/functions.js @@ -264,7 +264,7 @@ function updateSC(data) { // Soundcloud's API is async // Query the playback position and compare that with the sync packet PLAYER.getPosition(function(pos) { - if(Math.abs(pos - data.currentTime * 1000) > SYNC_THRESHOLD) { + if(Math.abs(pos / 1000 - data.currentTime) > SYNC_THRESHOLD) { PLAYER.seekTo(data.currentTime * 1000); } });