mirror of https://github.com/calzoneman/sync.git
Fix server not taking over after leadership is removed; fix soundcloud sync bug [untested]
This commit is contained in:
parent
7d36f3e87a
commit
1e1e51a4ca
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue