aboutsummaryrefslogtreecommitdiffhomepage
path: root/client
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
parent7b9f22ed2a993689e37f6914f47a635b0f20e1f4 (diff)
downloadPeerTube-10f26f4203b8cef32778bf3435d8112eaea3c093.tar.gz
PeerTube-10f26f4203b8cef32778bf3435d8112eaea3c093.tar.zst
PeerTube-10f26f4203b8cef32778bf3435d8112eaea3c093.zip
Fix viewers for lives
Diffstat (limited to 'client')
-rw-r--r--client/src/assets/player/peertube-player-manager.ts3
-rw-r--r--client/src/assets/player/peertube-plugin.ts14
-rw-r--r--client/src/assets/player/peertube-videojs-typings.ts2
3 files changed, 16 insertions, 3 deletions
diff --git a/client/src/assets/player/peertube-player-manager.ts b/client/src/assets/player/peertube-player-manager.ts
index 9407cf123..1ff3a010e 100644
--- a/client/src/assets/player/peertube-player-manager.ts
+++ b/client/src/assets/player/peertube-player-manager.ts
@@ -229,7 +229,8 @@ export class PeertubePlayerManager {
229 userWatching: commonOptions.userWatching, 229 userWatching: commonOptions.userWatching,
230 subtitle: commonOptions.subtitle, 230 subtitle: commonOptions.subtitle,
231 videoCaptions: commonOptions.videoCaptions, 231 videoCaptions: commonOptions.videoCaptions,
232 stopTime: commonOptions.stopTime 232 stopTime: commonOptions.stopTime,
233 isLive: commonOptions.isLive
233 } 234 }
234 } 235 }
235 236
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 }
diff --git a/client/src/assets/player/peertube-videojs-typings.ts b/client/src/assets/player/peertube-videojs-typings.ts
index f1e614499..e5259092c 100644
--- a/client/src/assets/player/peertube-videojs-typings.ts
+++ b/client/src/assets/player/peertube-videojs-typings.ts
@@ -106,6 +106,8 @@ type PeerTubePluginOptions = {
106 videoCaptions: VideoJSCaption[] 106 videoCaptions: VideoJSCaption[]
107 107
108 stopTime: number | string 108 stopTime: number | string
109
110 isLive: boolean
109} 111}
110 112
111type PlaylistPluginOptions = { 113type PlaylistPluginOptions = {