mirror of
https://github.com/anatolykopyl/movieroom-front.git
synced 2026-03-26 21:05:21 +00:00
More logical syncronisation
This commit is contained in:
@@ -7,4 +7,5 @@ export interface Room {
|
|||||||
downloaded?: boolean;
|
downloaded?: boolean;
|
||||||
downloadedAt?: Date;
|
downloadedAt?: Date;
|
||||||
position: number;
|
position: number;
|
||||||
|
syncedAt: Date;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,9 +71,8 @@ export default defineComponent({
|
|||||||
this.positionInterval = setInterval(async () => {
|
this.positionInterval = setInterval(async () => {
|
||||||
if (this.playing) {
|
if (this.playing) {
|
||||||
const serverPosition = await getPosition(this.id);
|
const serverPosition = await getPosition(this.id);
|
||||||
// this.room.position = element.currentTime;
|
// console.log(`L: ${element.currentTime}; S: ${serverPosition}`);
|
||||||
if (Math.abs(this.room.position - serverPosition) > 2) {
|
if (Math.abs(element.currentTime - serverPosition) > 2) {
|
||||||
this.room.position = serverPosition;
|
|
||||||
element.currentTime = serverPosition;
|
element.currentTime = serverPosition;
|
||||||
console.log('Synced');
|
console.log('Synced');
|
||||||
}
|
}
|
||||||
@@ -83,8 +82,7 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
seeked() {
|
seeked() {
|
||||||
const element = this.$refs.video as HTMLVideoElement;
|
const element = this.$refs.video as HTMLVideoElement;
|
||||||
const position = element.currentTime;
|
setPosition(this.id, element.currentTime);
|
||||||
setPosition(this.id, position);
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user