UNPKG

playable

Version:

Video player based on HTML5Video

110 lines 4.11 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var device_detection_1 = require("../../utils/device-detection"); var player_api_decorator_1 = (0, tslib_1.__importDefault)(require("../../core/player-api-decorator")); var chrome_1 = (0, tslib_1.__importDefault)(require("./chrome")); var safari_1 = (0, tslib_1.__importDefault)(require("./safari")); var constants_1 = require("../../constants"); var PictureInPicture = /** @class */ (function () { function PictureInPicture(_a) { var eventEmitter = _a.eventEmitter, engine = _a.engine; this._isEnabled = true; this._eventEmitter = eventEmitter; this._onChange = this._onChange.bind(this); if ((0, device_detection_1.isSafari)()) { this._helper = new safari_1.default(engine.getElement(), this._onChange); } else { this._helper = new chrome_1.default(engine.getElement(), this._onChange); } } PictureInPicture.prototype._onChange = function () { this._eventEmitter.emitAsync(constants_1.UIEvent.PICTURE_IN_PICTURE_STATUS_CHANGE, this.isInPictureInPicture); }; /** * Player would try to enter fullscreen mode. * Behavior of fullscreen mode on different platforms may differ. * @example * player.enterFullScreen(); */ PictureInPicture.prototype.enterPictureInPicture = function () { if (!this.isEnabled) { return; } this._helper.request(); }; /** * Player would try to exit fullscreen mode. * @example * player.exitFullScreen(); */ PictureInPicture.prototype.exitPictureInPicture = function () { if (!this.isEnabled) { return; } this._helper.exit(); }; /** * Disable functionality for entering picture in picture mode * @example * player.disablePictureInPicture(); */ PictureInPicture.prototype.disablePictureInPicture = function () { this._helper.exit(); this._isEnabled = false; }; /** * Enable functionality for entering picture in picture mode * @example * player.enablePictureInPicture(); */ PictureInPicture.prototype.enablePictureInPicture = function () { this._isEnabled = true; }; Object.defineProperty(PictureInPicture.prototype, "isInPictureInPicture", { /** * Return true if player is in picture in picture mode * @example * console.log(player.isInPictureInPicture); // false */ get: function () { if (!this.isEnabled) { return false; } return this._helper.isInPictureInPicture; }, enumerable: false, configurable: true }); Object.defineProperty(PictureInPicture.prototype, "isEnabled", { get: function () { return this._helper.isEnabled && this._isEnabled; }, enumerable: false, configurable: true }); PictureInPicture.prototype.destroy = function () { this._helper.destroy(); }; PictureInPicture.moduleName = 'pictureInPicture'; PictureInPicture.dependencies = ['eventEmitter', 'engine', 'config']; (0, tslib_1.__decorate)([ (0, player_api_decorator_1.default)() ], PictureInPicture.prototype, "enterPictureInPicture", null); (0, tslib_1.__decorate)([ (0, player_api_decorator_1.default)() ], PictureInPicture.prototype, "exitPictureInPicture", null); (0, tslib_1.__decorate)([ (0, player_api_decorator_1.default)() ], PictureInPicture.prototype, "disablePictureInPicture", null); (0, tslib_1.__decorate)([ (0, player_api_decorator_1.default)() ], PictureInPicture.prototype, "enablePictureInPicture", null); (0, tslib_1.__decorate)([ (0, player_api_decorator_1.default)() ], PictureInPicture.prototype, "isInPictureInPicture", null); return PictureInPicture; }()); exports.default = PictureInPicture; //# sourceMappingURL=picture-in-picture.js.map