mirror of https://github.com/Chocobozzz/PeerTube
Fix viewers for lives
parent
7b9f22ed2a
commit
10f26f4203
|
@ -229,7 +229,8 @@ export class PeertubePlayerManager {
|
||||||
userWatching: commonOptions.userWatching,
|
userWatching: commonOptions.userWatching,
|
||||||
subtitle: commonOptions.subtitle,
|
subtitle: commonOptions.subtitle,
|
||||||
videoCaptions: commonOptions.videoCaptions,
|
videoCaptions: commonOptions.videoCaptions,
|
||||||
stopTime: commonOptions.stopTime
|
stopTime: commonOptions.stopTime,
|
||||||
|
isLive: commonOptions.isLive
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,8 @@ class PeerTubePlugin extends Plugin {
|
||||||
private userWatchingVideoInterval: any
|
private userWatchingVideoInterval: any
|
||||||
private lastResolutionChange: ResolutionUpdateData
|
private lastResolutionChange: ResolutionUpdateData
|
||||||
|
|
||||||
|
private isLive: boolean
|
||||||
|
|
||||||
private menuOpened = false
|
private menuOpened = false
|
||||||
private mouseInControlBar = false
|
private mouseInControlBar = false
|
||||||
private readonly savedInactivityTimeout: number
|
private readonly savedInactivityTimeout: number
|
||||||
|
@ -42,6 +44,7 @@ class PeerTubePlugin extends Plugin {
|
||||||
this.videoViewUrl = options.videoViewUrl
|
this.videoViewUrl = options.videoViewUrl
|
||||||
this.videoDuration = options.videoDuration
|
this.videoDuration = options.videoDuration
|
||||||
this.videoCaptions = options.videoCaptions
|
this.videoCaptions = options.videoCaptions
|
||||||
|
this.isLive = options.isLive
|
||||||
|
|
||||||
this.savedInactivityTimeout = player.options_.inactivityTimeout
|
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
|
// After 30 seconds (or 3/4 of the video), add a view to the video
|
||||||
let minSecondsToView = 30
|
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
|
let secondsViewed = 0
|
||||||
this.videoViewInterval = setInterval(() => {
|
this.videoViewInterval = setInterval(() => {
|
||||||
|
@ -160,7 +165,12 @@ class PeerTubePlugin extends Plugin {
|
||||||
secondsViewed += 1
|
secondsViewed += 1
|
||||||
|
|
||||||
if (secondsViewed > minSecondsToView) {
|
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))
|
this.addViewToVideo().catch(err => console.error(err))
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,6 +106,8 @@ type PeerTubePluginOptions = {
|
||||||
videoCaptions: VideoJSCaption[]
|
videoCaptions: VideoJSCaption[]
|
||||||
|
|
||||||
stopTime: number | string
|
stopTime: number | string
|
||||||
|
|
||||||
|
isLive: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
type PlaylistPluginOptions = {
|
type PlaylistPluginOptions = {
|
||||||
|
|
Loading…
Reference in New Issue