From 347b262d20109f167cf39378189286f2dca5b60a Mon Sep 17 00:00:00 2001 From: Carson McManus Date: Fri, 10 May 2024 20:54:16 -0400 Subject: [PATCH] client: fix vimeo player not respecting seeks (#1775) --- client/src/components/composables/media-player.ts | 3 ++- client/src/views/Room.vue | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/client/src/components/composables/media-player.ts b/client/src/components/composables/media-player.ts index 43d2891d2..01975ca36 100644 --- a/client/src/components/composables/media-player.ts +++ b/client/src/components/composables/media-player.ts @@ -102,7 +102,8 @@ export class MediaPlayerV2 { } return this.player.value.pause(); } - getPosition(): number { + getPosition(): number | Promise { + // vimeo video player returns a promise, so we need to handle that if (!this.checkForPlayer(this.player.value)) { return 0; } diff --git a/client/src/views/Room.vue b/client/src/views/Room.vue index 11c44af65..8c6ba88f2 100644 --- a/client/src/views/Room.vue +++ b/client/src/views/Room.vue @@ -344,7 +344,12 @@ export default defineComponent({ } const currentTime = player.getPosition(); - if (Math.abs(newPosition - currentTime) > 1 && !mediaPlaybackBlocked.value) { + const diff = Math.abs(newPosition - (await currentTime)); + if (isNaN(diff)) { + console.error("player diff is NaN, this is a bug", newPosition, currentTime); + return; + } + if (diff > 1 && !mediaPlaybackBlocked.value) { player.setPosition(newPosition); } });