playable
Version:
Video player based on HTML5Video
95 lines • 3.97 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var constants_1 = require("../../../constants");
var debug_panel_view_1 = (0, tslib_1.__importDefault)(require("./debug-panel.view"));
var keyboard_interceptor_1 = require("../../../utils/keyboard-interceptor");
var UPDATE_TIME = 1000;
var DebugPanel = /** @class */ (function () {
function DebugPanel(_a) {
var engine = _a.engine, rootContainer = _a.rootContainer, keyboardControl = _a.keyboardControl;
this._engine = engine;
this._bindCallbacks();
this._initUI();
this.hide();
rootContainer.appendComponentElement(this.getElement());
keyboardControl.addKeyControl(keyboard_interceptor_1.KEYCODES.DEBUG_KEY, this._keyControlCallback);
}
DebugPanel.prototype._keyControlCallback = function (e) {
if (e.ctrlKey && e.shiftKey) {
this.show();
}
};
DebugPanel.prototype.getElement = function () {
return this.view.getElement();
};
DebugPanel.prototype._initUI = function () {
this.view = new debug_panel_view_1.default({
callbacks: {
onCloseButtonClick: this.hide,
},
});
};
DebugPanel.prototype._bindCallbacks = function () {
this.updateInfo = this.updateInfo.bind(this);
this.hide = this.hide.bind(this);
this._keyControlCallback = this._keyControlCallback.bind(this);
};
DebugPanel.prototype.getDebugInfo = function () {
var info = this._engine.getDebugInfo();
if (info.output === 'html5video') {
var _a = info, url = _a.url, type = _a.type, deliveryPriority = _a.deliveryPriority, currentBitrate = _a.currentBitrate, overallBufferLength = _a.overallBufferLength, nearestBufferSegInfo = _a.nearestBufferSegInfo, viewDimensions = _a.viewDimensions, currentTime = _a.currentTime, duration = _a.duration, loadingStateTimestamps = _a.loadingStateTimestamps, bitrates = _a.bitrates, bwEstimate = _a.bwEstimate, output = _a.output;
return {
url: url,
type: type,
deliveryPriority: constants_1.MediaStreamDeliveryPriority[deliveryPriority],
currentBitrate: currentBitrate,
overallBufferLength: overallBufferLength,
nearestBufferSegInfo: nearestBufferSegInfo,
viewDimensions: viewDimensions,
currentTime: currentTime,
duration: duration,
loadingStateTimestamps: loadingStateTimestamps,
bitrates: bitrates,
bwEstimate: bwEstimate,
output: output,
};
}
return info;
};
DebugPanel.prototype.updateInfo = function () {
this.view.setInfo(this.getDebugInfo());
};
DebugPanel.prototype.setUpdateInterval = function () {
this.clearUpdateInterval();
this._interval = window.setInterval(this.updateInfo, UPDATE_TIME);
};
DebugPanel.prototype.clearUpdateInterval = function () {
window.clearInterval(this._interval);
};
DebugPanel.prototype.show = function () {
if (this.isHidden) {
this.updateInfo();
this.setUpdateInterval();
this.view.show();
this.isHidden = false;
}
};
DebugPanel.prototype.hide = function () {
if (!this.isHidden) {
this.clearUpdateInterval();
this.view.hide();
this.isHidden = true;
}
};
DebugPanel.prototype.destroy = function () {
this.clearUpdateInterval();
this.view.destroy();
};
DebugPanel.moduleName = 'debugPanel';
DebugPanel.View = debug_panel_view_1.default;
DebugPanel.dependencies = ['engine', 'rootContainer', 'keyboardControl'];
return DebugPanel;
}());
exports.default = DebugPanel;
//# sourceMappingURL=debug-panel.js.map