From d5fd8227b4ebb6481f1cc33d183e753a66b58317 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 14 Dec 2023 09:52:50 +0100 Subject: [PATCH] Avoid sending seek event on video start time --- .../src/assets/player/shared/peertube/peertube-plugin.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/client/src/assets/player/shared/peertube/peertube-plugin.ts b/client/src/assets/player/shared/peertube/peertube-plugin.ts index 30a2d8538..1a7ca4d4d 100644 --- a/client/src/assets/player/shared/peertube/peertube-plugin.ts +++ b/client/src/assets/player/shared/peertube/peertube-plugin.ts @@ -38,6 +38,8 @@ class PeerTubePlugin extends Plugin { private errorModal: videojs.ModalDialog + private hasInitialSeek = false + private videoViewOnPlayHandler: (...args: any[]) => void private videoViewOnSeekedHandler: (...args: any[]) => void private videoViewOnEndedHandler: (...args: any[]) => void @@ -253,6 +255,12 @@ class PeerTubePlugin extends Plugin { } this.videoViewOnSeekedHandler = () => { + // Bypass the first initial seek + if (this.hasInitialSeek) { + this.hasInitialSeek = false + return + } + const diff = Math.floor(this.player.currentTime()) - lastCurrentTime // Don't take into account small forwards @@ -418,6 +426,7 @@ class PeerTubePlugin extends Plugin { if (startTime !== null && startTime !== undefined) { debugLogger('Start the video at ' + startTime) + this.hasInitialSeek = true this.player.currentTime(timeToInt(startTime)) }