]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Fix viewers for lives
authorChocobozzz <me@florianbigard.com>
Mon, 7 Dec 2020 14:58:57 +0000 (15:58 +0100)
committerChocobozzz <me@florianbigard.com>
Mon, 7 Dec 2020 15:07:52 +0000 (16:07 +0100)
client/src/assets/player/peertube-player-manager.ts
client/src/assets/player/peertube-plugin.ts
client/src/assets/player/peertube-videojs-typings.ts

index 9407cf123eef3608c100dd6f497e9c87abf21ab2..1ff3a010e800010871321667d6d08d416f1ad873 100644 (file)
@@ -229,7 +229,8 @@ export class PeertubePlayerManager {
         userWatching: commonOptions.userWatching,
         subtitle: commonOptions.subtitle,
         videoCaptions: commonOptions.videoCaptions,
-        stopTime: commonOptions.stopTime
+        stopTime: commonOptions.stopTime,
+        isLive: commonOptions.isLive
       }
     }
 
index a2b038b775693792813505ee6fb8e73c13a456be..75a6e662ebec2c260f5e185efc28b24ebbaacb10 100644 (file)
@@ -32,6 +32,8 @@ class PeerTubePlugin extends Plugin {
   private userWatchingVideoInterval: any
   private lastResolutionChange: ResolutionUpdateData
 
+  private isLive: boolean
+
   private menuOpened = false
   private mouseInControlBar = false
   private readonly savedInactivityTimeout: number
@@ -42,6 +44,7 @@ class PeerTubePlugin extends Plugin {
     this.videoViewUrl = options.videoViewUrl
     this.videoDuration = options.videoDuration
     this.videoCaptions = options.videoCaptions
+    this.isLive = options.isLive
 
     this.savedInactivityTimeout = player.options_.inactivityTimeout
 
@@ -152,7 +155,9 @@ class PeerTubePlugin extends Plugin {
     // After 30 seconds (or 3/4 of the video), add a view to the video
     let minSecondsToView = 30
 
-    if (this.videoDuration < minSecondsToView) minSecondsToView = (this.videoDuration * 3) / 4
+    if (!this.isLive && this.videoDuration < minSecondsToView) {
+      minSecondsToView = (this.videoDuration * 3) / 4
+    }
 
     let secondsViewed = 0
     this.videoViewInterval = setInterval(() => {
@@ -160,7 +165,12 @@ class PeerTubePlugin extends Plugin {
         secondsViewed += 1
 
         if (secondsViewed > minSecondsToView) {
-          this.clearVideoViewInterval()
+          // Restart the loop if this is a live
+          if (this.isLive) {
+            secondsViewed = 0
+          } else {
+            this.clearVideoViewInterval()
+          }
 
           this.addViewToVideo().catch(err => console.error(err))
         }
index f1e61449928e6f21be6577568912f190f4d6dd68..e5259092c6cdfaac0a056d424f0288faada30062 100644 (file)
@@ -106,6 +106,8 @@ type PeerTubePluginOptions = {
   videoCaptions: VideoJSCaption[]
 
   stopTime: number | string
+
+  isLive: boolean
 }
 
 type PlaylistPluginOptions = {