speculative loop fix
This commit is contained in:
+12
-11
@@ -14,6 +14,7 @@ export default class VideoListener {
|
||||
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);
|
||||
@@ -22,24 +23,23 @@ export default class VideoListener {
|
||||
}
|
||||
updateStatus(newStatus) {
|
||||
this.video = Object.assign({}, this.video, newStatus);
|
||||
if (this.server.status !== this.video.status) {
|
||||
if (this.server.status !== this.video.status && this.caughtUp === true) {
|
||||
if (this.video.showName) this.listener(this.video);
|
||||
}
|
||||
}
|
||||
doUpdate(serverPlayer) {
|
||||
this.server = serverPlayer;
|
||||
if (serverPlayer.updatedBy === window.localStorage.getItem('watchPartyUserUid')) return;
|
||||
else {
|
||||
this.caughtUp = false;
|
||||
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:
|
||||
if (
|
||||
this.server.status === PLAYER_STATUS.PAUSED &&
|
||||
this.video.status === PLAYER_STATUS.PLAYING
|
||||
)
|
||||
this.video.element.pause();
|
||||
this.video.element.pause();
|
||||
window.postMessage({ type: 'SEEK', time: serverPlayer.time * 1000 }, '*');
|
||||
break;
|
||||
case PLAYER_SOURCE.AMAZON:
|
||||
@@ -70,6 +70,7 @@ export default class VideoListener {
|
||||
}
|
||||
}
|
||||
}
|
||||
this.caughtUp = true;
|
||||
}
|
||||
timeout(n) {
|
||||
return new Promise((resolve, reject) => {
|
||||
@@ -143,9 +144,9 @@ export default class VideoListener {
|
||||
time: videoElement.currentTime,
|
||||
showName: await this.getShowName(),
|
||||
});
|
||||
videoElement.onended = async (ev) => {
|
||||
this.updateStatus({ status: PLAYER_STATUS.NOT_PLAYING, showName: '', time: 0 });
|
||||
};
|
||||
// videoElement.onended = async (ev) => {
|
||||
// this.updateStatus({ status: PLAYER_STATUS.NOT_PLAYING, showName: '', time: 0 });
|
||||
// };
|
||||
}
|
||||
async start() {
|
||||
this.updateStatus({ source: getPlayerSource(), showName: await this.getShowName() });
|
||||
|
||||
Reference in New Issue
Block a user