mirror of https://github.com/calzoneman/sync.git
Preserve current playing item when shuffling (#812)
This commit is contained in:
parent
27e8885285
commit
1ec3eab0dc
|
@ -748,6 +748,8 @@ PlaylistModule.prototype.handleShuffle = function (user) {
|
||||||
this.channel.logger.log("[playlist] " + user.getName() + " shuffled the playlist");
|
this.channel.logger.log("[playlist] " + user.getName() + " shuffled the playlist");
|
||||||
|
|
||||||
var pl = this.items.toArray(false);
|
var pl = this.items.toArray(false);
|
||||||
|
let currentUid = this.current ? this.current.uid : null;
|
||||||
|
let currentTime = this.current ? this.current.media.currentTime : undefined;
|
||||||
this.items.clear();
|
this.items.clear();
|
||||||
this.semaphore.reset();
|
this.semaphore.reset();
|
||||||
while (pl.length > 0) {
|
while (pl.length > 0) {
|
||||||
|
@ -758,7 +760,12 @@ PlaylistModule.prototype.handleShuffle = function (user) {
|
||||||
queueby: pl[i].queueby
|
queueby: pl[i].queueby
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (pl[i].uid === currentUid) {
|
||||||
|
this.items.prepend(item);
|
||||||
|
} else {
|
||||||
this.items.append(item);
|
this.items.append(item);
|
||||||
|
}
|
||||||
|
|
||||||
pl.splice(i, 1);
|
pl.splice(i, 1);
|
||||||
}
|
}
|
||||||
this._listDirty = true;
|
this._listDirty = true;
|
||||||
|
@ -772,7 +779,7 @@ PlaylistModule.prototype.handleShuffle = function (user) {
|
||||||
u.socket.emit("playlist", pl);
|
u.socket.emit("playlist", pl);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.startPlayback();
|
this.startPlayback(currentTime);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue