UNPKG

playable

Version:

Video player based on HTML5Video

292 lines 10.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var player_api_decorator_1 = (0, tslib_1.__importDefault)(require("../../../core/player-api-decorator")); var bottom_block_view_1 = (0, tslib_1.__importDefault)(require("./bottom-block.view")); var constants_1 = require("../../../constants"); var BottomBlock = /** @class */ (function () { function BottomBlock(dependencies) { this._isBlockFocused = false; this.isHidden = false; var eventEmitter = dependencies.eventEmitter; this._eventEmitter = eventEmitter; this._bindViewCallbacks(); this._initUI(this._getControlElements(dependencies)); this._bindEvents(); } BottomBlock.prototype._getControlElements = function (dependencies) { var playControl = dependencies.playControl, progressControl = dependencies.progressControl, timeControl = dependencies.timeControl, volumeControl = dependencies.volumeControl, fullScreenControl = dependencies.fullScreenControl, logo = dependencies.logo, downloadButton = dependencies.downloadButton, pictureInPictureControl = dependencies.pictureInPictureControl; return { play: playControl.getElement(), progress: progressControl.getElement(), time: timeControl.getElement(), volume: volumeControl.getElement(), fullScreen: fullScreenControl.getElement(), download: downloadButton.getElement(), logo: logo.getElement(), pictureInPicture: pictureInPictureControl.getElement(), }; }; BottomBlock.prototype.getElement = function () { return this.view.getElement(); }; BottomBlock.prototype.addControl = function (key, element, options) { var _a = (options || {}).position, position = _a === void 0 ? 'right' : _a; this.view.addControl(key, element, position); }; BottomBlock.prototype._initUI = function (elements) { var config = { elements: elements, callbacks: { onBlockMouseMove: this._setFocusState, onBlockMouseOut: this._removeFocusState, }, }; this.view = new BottomBlock.View(config); this.hideLogo(); this.hideDownloadButton(); }; BottomBlock.prototype._bindEvents = function () { this._unbindEvents = this._eventEmitter.bindEvents([[constants_1.UIEvent.FULL_SCREEN_STATE_CHANGED, this._removeFocusState]], this); }; BottomBlock.prototype._bindViewCallbacks = function () { this._setFocusState = this._setFocusState.bind(this); this._removeFocusState = this._removeFocusState.bind(this); }; BottomBlock.prototype._setFocusState = function () { this._isBlockFocused = true; }; BottomBlock.prototype._removeFocusState = function () { this._isBlockFocused = false; }; Object.defineProperty(BottomBlock.prototype, "isFocused", { get: function () { return this._isBlockFocused; }, enumerable: false, configurable: true }); BottomBlock.prototype.showContent = function () { this.view.showContent(); }; BottomBlock.prototype.hideContent = function () { this.view.hideContent(); }; BottomBlock.prototype.hide = function () { this.isHidden = true; this.view.hide(); }; BottomBlock.prototype.show = function () { this.isHidden = false; this.view.show(); }; /** * Method for allowing logo to be always shown in bottom block * @param flag - `true` for showing always * @example * player.setAlwaysShowLogo(true); * */ BottomBlock.prototype.setAlwaysShowLogo = function (flag) { this.view.setShouldLogoShowAlwaysFlag(flag); }; /** * Method for hiding logo. If you use `setAlwaysShowLogo` or `setControlsShouldAlwaysShow`, logo would automaticaly appear. * @example * player.hideLogo(); */ BottomBlock.prototype.hideLogo = function () { this.view.hideLogo(); }; /** * Method for showing logo. * @example * player.showLogo(); */ BottomBlock.prototype.showLogo = function () { this.view.showLogo(); }; /** * Method for showing play control. * @example * player.showPlayControl(); */ BottomBlock.prototype.showPlayControl = function () { this.view.showPlayControl(); }; /** * Method for showing volume control. * @example * player.showVolumeControl(); */ BottomBlock.prototype.showVolumeControl = function () { this.view.showVolumeControl(); }; /** * Method for showing time control. * @example * player.showTimeControl(); */ BottomBlock.prototype.showTimeControl = function () { this.view.showTimeControl(); }; /** * Method for showing full screen control. * @example * player.showFullScreenControl(); */ BottomBlock.prototype.showFullScreenControl = function () { this.view.showFullScreenControl(); }; /** * Method for showing picture-in-picture control. * @example * player.showPictureInPictureControl(); */ BottomBlock.prototype.showPictureInPictureControl = function () { this.view.showPictureInPictureControl(); }; /** * Method for showing progress control. * @example * player.showProgressControl(); */ BottomBlock.prototype.showProgressControl = function () { this.view.showProgressControl(); }; /** * Method for showing download button. * @example * player.showDownloadButton(); */ BottomBlock.prototype.showDownloadButton = function () { this.view.showDownloadButton(); }; /** * Method for hiding play control. * @example * player.hidePlayControl(); */ BottomBlock.prototype.hidePlayControl = function () { this.view.hidePlayControl(); }; /** * Method for hiding voluem control. * @example * player.hideVolumeControl(); */ BottomBlock.prototype.hideVolumeControl = function () { this.view.hideVolumeControl(); }; /** * Method for hiding time control. * @example * player.hideTimeControl(); */ BottomBlock.prototype.hideTimeControl = function () { this.view.hideTimeControl(); }; /** * Method for hiding full screen control. * @example * player.hideFullScreenControl(); */ BottomBlock.prototype.hideFullScreenControl = function () { this.view.hideFullScreenControl(); }; /** * Method for hiding picture-in-picture control. * @example * player.hidePictureInPictureControl(); */ BottomBlock.prototype.hidePictureInPictureControl = function () { this.view.hidePictureInPictureControl(); }; /** * Method for hiding progress control. * @example * player.hideProgressControl(); */ BottomBlock.prototype.hideProgressControl = function () { this.view.hideProgressControl(); }; /** * Method for hiding download button. * @example * player.hideDownloadButton(); */ BottomBlock.prototype.hideDownloadButton = function () { this.view.hideDownloadButton(); }; BottomBlock.prototype.destroy = function () { this._unbindEvents(); this.view.destroy(); }; BottomBlock.moduleName = 'bottomBlock'; BottomBlock.View = bottom_block_view_1.default; BottomBlock.dependencies = [ 'playControl', 'progressControl', 'timeControl', 'volumeControl', 'fullScreenControl', 'logo', 'downloadButton', 'eventEmitter', 'pictureInPictureControl', ]; (0, tslib_1.__decorate)([ (0, player_api_decorator_1.default)() ], BottomBlock.prototype, "setAlwaysShowLogo", null); (0, tslib_1.__decorate)([ (0, player_api_decorator_1.default)() ], BottomBlock.prototype, "hideLogo", null); (0, tslib_1.__decorate)([ (0, player_api_decorator_1.default)() ], BottomBlock.prototype, "showLogo", null); (0, tslib_1.__decorate)([ (0, player_api_decorator_1.default)() ], BottomBlock.prototype, "showPlayControl", null); (0, tslib_1.__decorate)([ (0, player_api_decorator_1.default)() ], BottomBlock.prototype, "showVolumeControl", null); (0, tslib_1.__decorate)([ (0, player_api_decorator_1.default)() ], BottomBlock.prototype, "showTimeControl", null); (0, tslib_1.__decorate)([ (0, player_api_decorator_1.default)() ], BottomBlock.prototype, "showFullScreenControl", null); (0, tslib_1.__decorate)([ (0, player_api_decorator_1.default)() ], BottomBlock.prototype, "showPictureInPictureControl", null); (0, tslib_1.__decorate)([ (0, player_api_decorator_1.default)() ], BottomBlock.prototype, "showProgressControl", null); (0, tslib_1.__decorate)([ (0, player_api_decorator_1.default)() ], BottomBlock.prototype, "showDownloadButton", null); (0, tslib_1.__decorate)([ (0, player_api_decorator_1.default)() ], BottomBlock.prototype, "hidePlayControl", null); (0, tslib_1.__decorate)([ (0, player_api_decorator_1.default)() ], BottomBlock.prototype, "hideVolumeControl", null); (0, tslib_1.__decorate)([ (0, player_api_decorator_1.default)() ], BottomBlock.prototype, "hideTimeControl", null); (0, tslib_1.__decorate)([ (0, player_api_decorator_1.default)() ], BottomBlock.prototype, "hideFullScreenControl", null); (0, tslib_1.__decorate)([ (0, player_api_decorator_1.default)() ], BottomBlock.prototype, "hidePictureInPictureControl", null); (0, tslib_1.__decorate)([ (0, player_api_decorator_1.default)() ], BottomBlock.prototype, "hideProgressControl", null); (0, tslib_1.__decorate)([ (0, player_api_decorator_1.default)() ], BottomBlock.prototype, "hideDownloadButton", null); return BottomBlock; }()); exports.default = BottomBlock; //# sourceMappingURL=bottom-block.js.map