event blocker

This commit is contained in:
Ayushya Amitabh
2020-05-06 13:36:52 -04:00
parent d7ce19e1fb
commit dd5bf955c5
+7 -8
View File
@@ -11,10 +11,10 @@ export default class VideoListener {
source: '',
element: null,
};
this.isUpdating = false;
this.server = {
status: PLAYER_STATUS.NOT_PLAYING,
};
this.caughtUp = true;
this.listener = listener;
this.updateStatus = this.updateStatus.bind(this);
this.firstTimeSync = this.firstTimeSync.bind(this);
@@ -23,19 +23,18 @@ export default class VideoListener {
}
updateStatus(newStatus) {
this.video = Object.assign({}, this.video, newStatus);
if (this.server.status !== this.video.status && this.caughtUp === true) {
if (this.video.showName) this.listener(this.video);
if (this.server.status !== this.video.status) {
if (this.video.showName && !this.isUpdating) this.listener(this.video);
}
}
doUpdate(serverPlayer) {
this.server = serverPlayer;
this.caughtUp = false;
if (!this.isUpdating) {
this.isUpdating = true;
if (serverPlayer.updatedBy === window.localStorage.getItem('watchPartyUserUid')) {
this.caughtUp = true;
return;
} else {
// SEEK
console.log('GETTING UPDATE', serverPlayer, this.video);
if (this.video.element) {
switch (this.video.source) {
case PLAYER_SOURCE.NETFLIX:
@@ -69,7 +68,8 @@ export default class VideoListener {
}
}
}
this.caughtUp = true;
this.isUpdating = false;
}
}
timeout(n) {
return new Promise((resolve, reject) => {
@@ -130,7 +130,6 @@ export default class VideoListener {
});
}
videoElement.onplay = async (ev) => {
console.log(ev);
this.updateStatus({
status: PLAYER_STATUS.PLAYING,
time: videoElement.currentTime,