playable
Version:
Video player based on HTML5Video
100 lines • 4.15 kB
JavaScript
"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 picture_in_picture_view_1 = (0, tslib_1.__importDefault)(require("./picture-in-picture.view"));
var PictureInPictureControl = /** @class */ (function () {
function PictureInPictureControl(_a) {
var eventEmitter = _a.eventEmitter, pictureInPicture = _a.pictureInPicture, textMap = _a.textMap, tooltipService = _a.tooltipService, theme = _a.theme;
this._eventEmitter = eventEmitter;
this._pictureInPictureManager = pictureInPicture;
this._textMap = textMap;
this._theme = theme;
this._tooltipService = tooltipService;
this._bindCallbacks();
this._initUI();
this._bindEvents();
if (!this._pictureInPictureManager.isEnabled) {
this.hide();
}
this._initInterceptor();
}
PictureInPictureControl.prototype.getElement = function () {
return this.view.getElement();
};
PictureInPictureControl.prototype._bindCallbacks = function () {
this._togglePictureInPicture = this._togglePictureInPicture.bind(this);
};
PictureInPictureControl.prototype._bindEvents = function () {
this._unbindEvents = this._eventEmitter.bindEvents([
[
constants_1.UIEvent.PICTURE_IN_PICTURE_STATUS_CHANGE,
this.view.setPictureInPictureState,
],
], this.view);
};
PictureInPictureControl.prototype._initUI = function () {
var config = {
callbacks: {
onButtonClick: this._togglePictureInPicture,
},
textMap: this._textMap,
tooltipService: this._tooltipService,
theme: this._theme,
};
this.view = new PictureInPictureControl.View(config);
};
PictureInPictureControl.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));
};
PictureInPictureControl.prototype._destroyInterceptor = function () {
this._interceptor.destroy();
};
PictureInPictureControl.prototype._togglePictureInPicture = function () {
if (this._pictureInPictureManager.isInPictureInPicture) {
this._pictureInPictureManager.exitPictureInPicture();
this._eventEmitter.emitAsync(constants_1.UIEvent.EXIT_PICTURE_IN_PICTURE_CLICK);
}
else {
this._pictureInPictureManager.enterPictureInPicture();
this._eventEmitter.emitAsync(constants_1.UIEvent.ENTER_PICTURE_IN_PICTURE_CLICK);
}
};
PictureInPictureControl.prototype.hide = function () {
this.isHidden = true;
this.view.hide();
};
PictureInPictureControl.prototype.show = function () {
this.isHidden = false;
this.view.show();
};
PictureInPictureControl.prototype.destroy = function () {
this._destroyInterceptor();
this._unbindEvents();
this.view.destroy();
};
PictureInPictureControl.moduleName = 'pictureInPictureControl';
PictureInPictureControl.View = picture_in_picture_view_1.default;
PictureInPictureControl.dependencies = [
'eventEmitter',
'pictureInPicture',
'textMap',
'tooltipService',
'theme',
];
return PictureInPictureControl;
}());
exports.default = PictureInPictureControl;
//# sourceMappingURL=picture-in-picture.js.map