Skip to content

Commit

Permalink
Invalid ID On Join Fix
Browse files Browse the repository at this point in the history
Fixed the bug where the Youtube ID would be invalid if the host socket
was playing a video on a different player. Now the new socket that joins
will load the old YT video on the spot and auto sync when the player is
switched back to YT.
  • Loading branch information
kyle8998 committed Mar 23, 2018
1 parent 775206e commit 5ff9fe0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,17 @@ socket.on('createYoutube', function(data) {
you.style.display = 'block';
currPlayer = 0

console.log("Player state: "+playerStatus)
// If it is -1, there was an error and needs to resync to host
if (playerStatus == -1) {
socket.emit('get video', function(id) {
player.loadVideoById(id);
// Auto sync with host after 1000ms of changing video
setTimeout(function() {
socket.emit('sync host', {});
}, 1000);
})
}
}
});

Expand Down

0 comments on commit 5ff9fe0

Please sign in to comment.