Files
shaka-player/lib/ads/ads_stats.js
T
Joey Parrish f539147d48 fix: Correct license headers in compiled output
This fixes all the license headers in the main library, which corrects
the appearance of the main license in the compiled output.

It seems that the `!` in the header forces the compiler to keep it in
the output.  I believe older compiler releases did this purely based
on `@license`.

Issue #2638

Change-Id: I7f0e918caad10c9af689c9d07672b7fe9be7b2f3
2020-06-09 16:05:09 -07:00

73 lines
1.4 KiB
JavaScript

/*! @license
* Shaka Player
* Copyright 2016 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
goog.provide('shaka.ads.AdsStats');
/**
* This class tracks all the various components (some optional) that are used to
* populate |shaka.extern.AdsStats| which is passed to the app.
*
* @final
*/
shaka.ads.AdsStats = class {
constructor() {
/** @private {!Array.<number>} */
this.loadTimes_ = [];
/** @private {number} */
this.started_ = 0;
/** @private {number} */
this.playedCompletely_ = 0;
/** @private {number} */
this.skipped_ = 0;
}
/**
* Record the time it took to get the final manifest.
*
* @param {number} seconds
*/
addLoadTime(seconds) {
this.loadTimes_.push(seconds);
}
/**
* Increase the number of ads started by one.
*/
incrementStarted() {
this.started_++;
}
/**
* Increase the number of ads played completely by one.
*/
incrementPlayedCompletely() {
this.playedCompletely_++;
}
/**
* Increase the number of ads skipped by one.
*/
incrementSkipped() {
this.skipped_++;
}
/**
* Create a stats blob that we can pass up to the app. This blob will not
* reference any internal data.
*
* @return {shaka.extern.AdsStats}
*/
getBlob() {
return {
loadTimes: this.loadTimes_,
started: this.started_,
playedCompletely: this.playedCompletely_,
skipped: this.skipped_,
};
}
};