Files
shaka-player/lib/ads/ads_stats.js
T
Álvaro Velad Galván 697a6ff785 Add initial DAI support (#2382)
This PR ads initial logic to enable support for IMA DAI streams.
Ad-containing streams can now be requested from the IMA stream manager and played.

Integration with the ad UI will follow in a separate CL.
2020-02-18 14:11:51 -08:00

60 lines
1.1 KiB
JavaScript

/** @license
* 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 {number} */
this.started_ = 0;
/** @private {number} */
this.playedCompletely_ = 0;
/** @private {number} */
this.skipped_ = 0;
}
/**
* 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 {
started: this.started_,
playedCompletely: this.playedCompletely_,
skipped: this.skipped_,
};
}
};