getStoredVolume,
saveLastSubtitle,
saveMuteInStore,
+ saveVideoWatchHistory,
saveVolumeInStore
} from './peertube-player-local-storage'
this.initializePlayer()
this.runViewAdd()
- if (options.userWatching) this.runUserWatchVideo(options.userWatching)
+ this.runUserWatchVideo(options.userWatching, options.videoUUID)
})
}
}, 1000)
}
- private runUserWatchVideo (options: UserWatching) {
+ private runUserWatchVideo (options: UserWatching, videoUUID: string) {
let lastCurrentTime = 0
this.userWatchingVideoInterval = setInterval(() => {
if (currentTime - lastCurrentTime >= 1) {
lastCurrentTime = currentTime
- this.notifyUserIsWatching(currentTime, options.url, options.authorizationHeader)
- .catch(err => console.error('Cannot notify user is watching.', err))
+ if (options) {
+ this.notifyUserIsWatching(currentTime, options.url, options.authorizationHeader)
+ .catch(err => console.error('Cannot notify user is watching.', err))
+ } else {
+ saveVideoWatchHistory(videoUUID, currentTime)
+ }
}
}, this.CONSTANTS.USER_WATCHING_VIDEO_INTERVAL)
}