Closed spodpn closed 1 year ago
We can maybe try to avoid this by having each client send the url of the next video along with the "finished" event. If it doesn't match, then ignore the message
The current implementation attempts to wait until half the clients have submitted a "playlistNext" event:
private playlistNext = (socket: Socket | null, data?: string) => {
if (data && data.length > 20000) {
return;
}
if (socket && data === this.video) {
this.nextVotes[socket.id] = data;
}
const votes = this.roster.filter((user) => this.nextVotes[user.id]).length;
if (!socket || votes >= Math.floor(this.roster.length / 2)) {
const next = this.playlist.shift();
this.io.of(this.roomId).emit('playlist', this.playlist);
if (next) {
this.cmdHost(null, next.url);
}
}
};
How to reproduce:
The first playlist item is loaded but after a very short amount of time it is replaced by the next one. The playlist counter goes quickly from (2) to (0). The first item on the playlist was effectively skipped.
Server log: (I inserted some debug printing)
When the slowest 2 clients reach the end, they trigger again a video change even though the video was already changed. The playlist is advanced twice, the first item was quickly skipped.
Defective client log: (I inserted some debug printing)
After the video was changed (REC:host) and should be now stopped, the defective client still gets an ENDED event on his player which triggers another playlistNext.
I wonder if we could reliably prevent this ENDED event from firing after the video was already changed by another client.