bitmovin-player-ui
Version:
Bitmovin Player UI Framework
53 lines (52 loc) • 2.42 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.AdCounterLabel = void 0;
var Label_1 = require("../labels/Label");
/**
* A label that displays the index of the currently playing ad out of the total number of ads.
*
* @category Labels
*/
var AdCounterLabel = /** @class */ (function (_super) {
__extends(AdCounterLabel, _super);
function AdCounterLabel(config) {
if (config === void 0) { config = {}; }
var _this = _super.call(this, config) || this;
_this.config = _this.mergeConfig(config, {
cssClass: 'ui-label-ad-counter',
}, _this.config);
return _this;
}
AdCounterLabel.prototype.configure = function (player, uimanager) {
var _this = this;
_super.prototype.configure.call(this, player, uimanager);
var clearText = function () {
_this.setText('');
};
player.on(player.exports.PlayerEvent.AdStarted, function () {
var _a, _b;
var activeAdIndex = player.ads.getActiveAdBreak().ads.findIndex(function (ad) { return ad === player.ads.getActiveAd(); }) + 1;
var totalAdsCount = (_b = (_a = player.ads.getActiveAdBreak().ads) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : activeAdIndex;
_this.setText("Ad ".concat(activeAdIndex, " of ").concat(totalAdsCount));
});
player.on(player.exports.PlayerEvent.AdBreakStarted, clearText);
player.on(player.exports.PlayerEvent.AdBreakFinished, clearText);
};
return AdCounterLabel;
}(Label_1.Label));
exports.AdCounterLabel = AdCounterLabel;