diff --git a/src/kava.js b/src/kava.js index 395cdf35..bc572aff 100644 --- a/src/kava.js +++ b/src/kava.js @@ -20,7 +20,6 @@ export default class Kava extends BasePlugin { _viewEventEnabled: boolean; _firstPlayRequestTime: number; _bufferStartTime: number; - _previousCurrentTime: number; _isFirstPlay: boolean; _isEnded: boolean; _isPaused: boolean; @@ -103,7 +102,6 @@ export default class Kava extends BasePlugin { } _resetFlags(): void { - this._previousCurrentTime = 0; this._isFirstPlay = true; this._isEnded = false; this._isPaused = false; @@ -131,7 +129,6 @@ export default class Kava extends BasePlugin { return; } - this._updatePlayTimeSumModel(); if (this._isBuffering) { this._updateBufferModel(); this._bufferStartTime = Date.now(); @@ -214,6 +211,7 @@ export default class Kava extends BasePlugin { _onReport(): void { if (this._viewEventEnabled) { + this._updatePlayTimeSumModel(); this._sendAnalytics(KavaEventModel.VIEW); } else { this.logger.warn(`VIEW event blocked because server response of viewEventsEnabled=false`); @@ -250,7 +248,6 @@ export default class Kava extends BasePlugin { } _onSeeking(): void { - this._previousCurrentTime = this.player.currentTime; this._model.updateModel({targetPosition: this.player.currentTime}); this._sendAnalytics(KavaEventModel.SEEK); } @@ -268,7 +265,6 @@ export default class Kava extends BasePlugin { } _onTimeUpdate(): void { - this._updatePlayTimeSumModel(); if (!this.player.isLive()) { const percent = this.player.currentTime / this.player.duration; if (!this._timePercentEvent.PLAY_REACHED_25 && percent >= 0.25) { @@ -364,9 +360,8 @@ export default class Kava extends BasePlugin { } _updatePlayTimeSumModel(): void { - const delta = this.player.currentTime - this._previousCurrentTime; + const delta = this.config.viewEventCountdown - this._model.getBufferTime(); this._model.updateModel({playTimeSum: this._model.getPlayTimeSum() + delta}); - this._previousCurrentTime = this.player.currentTime; } _setModelDelegates() {