UNPKG

playable

Version:

Video player based on HTML5Video

95 lines 3.85 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var constants_1 = require("../../../../constants"); var keyboard_interceptor_1 = (0, tslib_1.__importStar)(require("../../../../utils/keyboard-interceptor")); var full_screen_view_1 = (0, tslib_1.__importDefault)(require("./full-screen.view")); var FullScreenControl = /** @class */ (function () { function FullScreenControl(_a) { var eventEmitter = _a.eventEmitter, fullScreenManager = _a.fullScreenManager, textMap = _a.textMap, tooltipService = _a.tooltipService, theme = _a.theme; this._eventEmitter = eventEmitter; this._fullScreenManager = fullScreenManager; this._textMap = textMap; this._theme = theme; this._tooltipService = tooltipService; this._bindCallbacks(); this._initUI(); this._bindEvents(); if (!this._fullScreenManager.isEnabled) { this.hide(); } this._initInterceptor(); } FullScreenControl.prototype.getElement = function () { return this.view.getElement(); }; FullScreenControl.prototype._bindCallbacks = function () { this._toggleFullScreen = this._toggleFullScreen.bind(this); }; FullScreenControl.prototype._bindEvents = function () { this._unbindEvents = this._eventEmitter.bindEvents([[constants_1.UIEvent.FULL_SCREEN_STATE_CHANGED, this.view.setFullScreenState]], this.view); }; FullScreenControl.prototype._initUI = function () { var config = { callbacks: { onButtonClick: this._toggleFullScreen, }, textMap: this._textMap, tooltipService: this._tooltipService, theme: this._theme, }; this.view = new FullScreenControl.View(config); }; FullScreenControl.prototype._initInterceptor = function () { var _a; var _this = this; this._interceptor = new keyboard_interceptor_1.default(this.getElement(), (_a = {}, _a[keyboard_interceptor_1.KEYCODES.SPACE_BAR] = function (e) { e.stopPropagation(); _this._eventEmitter.emitAsync(constants_1.UIEvent.KEYBOARD_KEYDOWN_INTERCEPTED); }, _a[keyboard_interceptor_1.KEYCODES.ENTER] = function (e) { e.stopPropagation(); _this._eventEmitter.emitAsync(constants_1.UIEvent.KEYBOARD_KEYDOWN_INTERCEPTED); }, _a)); }; FullScreenControl.prototype._destroyInterceptor = function () { this._interceptor.destroy(); }; FullScreenControl.prototype._toggleFullScreen = function () { if (this._fullScreenManager.isInFullScreen) { this._fullScreenManager.exitFullScreen(); this._eventEmitter.emitAsync(constants_1.UIEvent.EXIT_FULL_SCREEN_CLICK); } else { this._fullScreenManager.enterFullScreen(); this._eventEmitter.emitAsync(constants_1.UIEvent.ENTER_FULL_SCREEN_CLICK); } }; FullScreenControl.prototype.hide = function () { this.isHidden = true; this.view.hide(); }; FullScreenControl.prototype.show = function () { this.isHidden = false; this.view.show(); }; FullScreenControl.prototype.destroy = function () { this._destroyInterceptor(); this._unbindEvents(); this.view.destroy(); }; FullScreenControl.moduleName = 'fullScreenControl'; FullScreenControl.View = full_screen_view_1.default; FullScreenControl.dependencies = [ 'eventEmitter', 'fullScreenManager', 'textMap', 'tooltipService', 'theme', ]; return FullScreenControl; }()); exports.default = FullScreenControl; //# sourceMappingURL=full-screen.js.map