event blocker
This commit is contained in:
@@ -11,10 +11,10 @@ export default class VideoListener {
|
|||||||
source: '',
|
source: '',
|
||||||
element: null,
|
element: null,
|
||||||
};
|
};
|
||||||
|
this.isUpdating = false;
|
||||||
this.server = {
|
this.server = {
|
||||||
status: PLAYER_STATUS.NOT_PLAYING,
|
status: PLAYER_STATUS.NOT_PLAYING,
|
||||||
};
|
};
|
||||||
this.caughtUp = true;
|
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
this.updateStatus = this.updateStatus.bind(this);
|
this.updateStatus = this.updateStatus.bind(this);
|
||||||
this.firstTimeSync = this.firstTimeSync.bind(this);
|
this.firstTimeSync = this.firstTimeSync.bind(this);
|
||||||
@@ -23,19 +23,18 @@ export default class VideoListener {
|
|||||||
}
|
}
|
||||||
updateStatus(newStatus) {
|
updateStatus(newStatus) {
|
||||||
this.video = Object.assign({}, this.video, newStatus);
|
this.video = Object.assign({}, this.video, newStatus);
|
||||||
if (this.server.status !== this.video.status && this.caughtUp === true) {
|
if (this.server.status !== this.video.status) {
|
||||||
if (this.video.showName) this.listener(this.video);
|
if (this.video.showName && !this.isUpdating) this.listener(this.video);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
doUpdate(serverPlayer) {
|
doUpdate(serverPlayer) {
|
||||||
this.server = serverPlayer;
|
this.server = serverPlayer;
|
||||||
this.caughtUp = false;
|
if (!this.isUpdating) {
|
||||||
|
this.isUpdating = true;
|
||||||
if (serverPlayer.updatedBy === window.localStorage.getItem('watchPartyUserUid')) {
|
if (serverPlayer.updatedBy === window.localStorage.getItem('watchPartyUserUid')) {
|
||||||
this.caughtUp = true;
|
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
// SEEK
|
// SEEK
|
||||||
console.log('GETTING UPDATE', serverPlayer, this.video);
|
|
||||||
if (this.video.element) {
|
if (this.video.element) {
|
||||||
switch (this.video.source) {
|
switch (this.video.source) {
|
||||||
case PLAYER_SOURCE.NETFLIX:
|
case PLAYER_SOURCE.NETFLIX:
|
||||||
@@ -69,7 +68,8 @@ export default class VideoListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.caughtUp = true;
|
this.isUpdating = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
timeout(n) {
|
timeout(n) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@@ -130,7 +130,6 @@ export default class VideoListener {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
videoElement.onplay = async (ev) => {
|
videoElement.onplay = async (ev) => {
|
||||||
console.log(ev);
|
|
||||||
this.updateStatus({
|
this.updateStatus({
|
||||||
status: PLAYER_STATUS.PLAYING,
|
status: PLAYER_STATUS.PLAYING,
|
||||||
time: videoElement.currentTime,
|
time: videoElement.currentTime,
|
||||||
|
|||||||
Reference in New Issue
Block a user