aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player/peertube-plugin.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-12-07 15:58:57 +0100
committerChocobozzz <me@florianbigard.com>2020-12-07 16:07:52 +0100
commit10f26f4203b8cef32778bf3435d8112eaea3c093 (patch)
tree4ce9abf68bb74337a6e8de7c41780be019e5329d /client/src/assets/player/peertube-plugin.ts
parent7b9f22ed2a993689e37f6914f47a635b0f20e1f4 (diff)
downloadPeerTube-10f26f4203b8cef32778bf3435d8112eaea3c093.tar.gz
PeerTube-10f26f4203b8cef32778bf3435d8112eaea3c093.tar.zst
PeerTube-10f26f4203b8cef32778bf3435d8112eaea3c093.zip
Fix viewers for lives
Diffstat (limited to 'client/src/assets/player/peertube-plugin.ts')
-rw-r--r--client/src/assets/player/peertube-plugin.ts14
1 files changed, 12 insertions, 2 deletions
diff --git a/client/src/assets/player/peertube-plugin.ts b/client/src/assets/player/peertube-plugin.ts
index a2b038b77..75a6e662e 100644
--- a/client/src/assets/player/peertube-plugin.ts
+++ b/client/src/assets/player/peertube-plugin.ts
@@ -32,6 +32,8 @@ class PeerTubePlugin extends Plugin {
32 private userWatchingVideoInterval: any 32 private userWatchingVideoInterval: any
33 private lastResolutionChange: ResolutionUpdateData 33 private lastResolutionChange: ResolutionUpdateData
34 34
35 private isLive: boolean
36
35 private menuOpened = false 37 private menuOpened = false
36 private mouseInControlBar = false 38 private mouseInControlBar = false
37 private readonly savedInactivityTimeout: number 39 private readonly savedInactivityTimeout: number
@@ -42,6 +44,7 @@ class PeerTubePlugin extends Plugin {
42 this.videoViewUrl = options.videoViewUrl 44 this.videoViewUrl = options.videoViewUrl
43 this.videoDuration = options.videoDuration 45 this.videoDuration = options.videoDuration
44 this.videoCaptions = options.videoCaptions 46 this.videoCaptions = options.videoCaptions
47 this.isLive = options.isLive
45 48
46 this.savedInactivityTimeout = player.options_.inactivityTimeout 49 this.savedInactivityTimeout = player.options_.inactivityTimeout
47 50
@@ -152,7 +155,9 @@ class PeerTubePlugin extends Plugin {
152 // After 30 seconds (or 3/4 of the video), add a view to the video 155 // After 30 seconds (or 3/4 of the video), add a view to the video
153 let minSecondsToView = 30 156 let minSecondsToView = 30
154 157
155 if (this.videoDuration < minSecondsToView) minSecondsToView = (this.videoDuration * 3) / 4 158 if (!this.isLive && this.videoDuration < minSecondsToView) {
159 minSecondsToView = (this.videoDuration * 3) / 4
160 }
156 161
157 let secondsViewed = 0 162 let secondsViewed = 0
158 this.videoViewInterval = setInterval(() => { 163 this.videoViewInterval = setInterval(() => {
@@ -160,7 +165,12 @@ class PeerTubePlugin extends Plugin {
160 secondsViewed += 1 165 secondsViewed += 1
161 166
162 if (secondsViewed > minSecondsToView) { 167 if (secondsViewed > minSecondsToView) {
163 this.clearVideoViewInterval() 168 // Restart the loop if this is a live
169 if (this.isLive) {
170 secondsViewed = 0
171 } else {
172 this.clearVideoViewInterval()
173 }
164 174
165 this.addViewToVideo().catch(err => console.error(err)) 175 this.addViewToVideo().catch(err => console.error(err))
166 } 176 }