aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player/shared/peertube/peertube-plugin.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/assets/player/shared/peertube/peertube-plugin.ts')
-rw-r--r--client/src/assets/player/shared/peertube/peertube-plugin.ts11
1 files changed, 5 insertions, 6 deletions
diff --git a/client/src/assets/player/shared/peertube/peertube-plugin.ts b/client/src/assets/player/shared/peertube/peertube-plugin.ts
index ec8fbb320..b5f177f30 100644
--- a/client/src/assets/player/shared/peertube/peertube-plugin.ts
+++ b/client/src/assets/player/shared/peertube/peertube-plugin.ts
@@ -27,9 +27,7 @@ class PeerTubePlugin extends Plugin {
27 private readonly videoUUID: string 27 private readonly videoUUID: string
28 private readonly startTime: number 28 private readonly startTime: number
29 29
30 private readonly CONSTANTS = { 30 private readonly videoViewIntervalMs: number
31 USER_VIEW_VIDEO_INTERVAL: 5000 // Every 5 seconds, notify the user is watching the video
32 }
33 31
34 private videoCaptions: VideoJSCaption[] 32 private videoCaptions: VideoJSCaption[]
35 private defaultSubtitle: string 33 private defaultSubtitle: string
@@ -48,6 +46,7 @@ class PeerTubePlugin extends Plugin {
48 this.authorizationHeader = options.authorizationHeader 46 this.authorizationHeader = options.authorizationHeader
49 this.videoUUID = options.videoUUID 47 this.videoUUID = options.videoUUID
50 this.startTime = timeToInt(options.startTime) 48 this.startTime = timeToInt(options.startTime)
49 this.videoViewIntervalMs = options.videoViewIntervalMs
51 50
52 this.videoCaptions = options.videoCaptions 51 this.videoCaptions = options.videoCaptions
53 this.initialInactivityTimeout = this.player.options_.inactivityTimeout 52 this.initialInactivityTimeout = this.player.options_.inactivityTimeout
@@ -188,7 +187,7 @@ class PeerTubePlugin extends Plugin {
188 }) 187 })
189 188
190 this.player.one('ended', () => { 189 this.player.one('ended', () => {
191 const currentTime = Math.round(this.player.duration()) 190 const currentTime = Math.floor(this.player.duration())
192 lastCurrentTime = currentTime 191 lastCurrentTime = currentTime
193 192
194 this.notifyUserIsWatching(currentTime, lastViewEvent) 193 this.notifyUserIsWatching(currentTime, lastViewEvent)
@@ -197,7 +196,7 @@ class PeerTubePlugin extends Plugin {
197 }) 196 })
198 197
199 this.videoViewInterval = setInterval(() => { 198 this.videoViewInterval = setInterval(() => {
200 const currentTime = Math.round(this.player.currentTime()) 199 const currentTime = Math.floor(this.player.currentTime())
201 200
202 // No need to update 201 // No need to update
203 if (currentTime === lastCurrentTime) return 202 if (currentTime === lastCurrentTime) return
@@ -213,7 +212,7 @@ class PeerTubePlugin extends Plugin {
213 if (!this.authorizationHeader()) { 212 if (!this.authorizationHeader()) {
214 saveVideoWatchHistory(this.videoUUID, currentTime) 213 saveVideoWatchHistory(this.videoUUID, currentTime)
215 } 214 }
216 }, this.CONSTANTS.USER_VIEW_VIDEO_INTERVAL) 215 }, this.videoViewIntervalMs)
217 } 216 }
218 217
219 private notifyUserIsWatching (currentTime: number, viewEvent: VideoViewEvent) { 218 private notifyUserIsWatching (currentTime: number, viewEvent: VideoViewEvent) {