Avoid sending seek event on video start time

This commit is contained in:
Chocobozzz 2023-12-14 09:52:50 +01:00
parent 1aab639928
commit d5fd8227b4
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
1 changed files with 9 additions and 0 deletions

View File

@ -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))
}