private userWatchingVideoInterval: any
private lastResolutionChange: ResolutionUpdateData
+ private isLive: boolean
+
private menuOpened = false
private mouseInControlBar = false
private readonly savedInactivityTimeout: number
this.videoViewUrl = options.videoViewUrl
this.videoDuration = options.videoDuration
this.videoCaptions = options.videoCaptions
+ this.isLive = options.isLive
this.savedInactivityTimeout = player.options_.inactivityTimeout
// 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(() => {
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))
}
}
private alterInactivity () {
- if (this.menuOpened || this.mouseInControlBar) {
+ if (this.menuOpened) {
this.player.options_.inactivityTimeout = this.savedInactivityTimeout
return
}
- this.player.options_.inactivityTimeout = 1
+ if (!this.mouseInControlBar && !this.isTouchEnabled()) {
+ this.player.options_.inactivityTimeout = 1
+ }
+ }
+
+ private isTouchEnabled () {
+ return ('ontouchstart' in window) ||
+ navigator.maxTouchPoints > 0 ||
+ navigator.msMaxTouchPoints > 0
}
private initCaptions () {