playable
Version:
Video player based on HTML5Video
78 lines • 2.86 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var HAVE_METADATA = 1;
var isFullScreenRequested = false;
var IOSFullScreen = /** @class */ (function () {
function IOSFullScreen(elem, callback) {
this._$elem = elem;
this._callback = callback;
this._bindEvents();
this._enterWhenHasMetaData = this._enterWhenHasMetaData.bind(this);
}
Object.defineProperty(IOSFullScreen.prototype, "isAPIExist", {
get: function () {
//@ts-expect-error
return Boolean(this._$elem && this._$elem.webkitSupportsFullscreen);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IOSFullScreen.prototype, "isInFullScreen", {
get: function () {
//@ts-expect-error
return Boolean(this._$elem && this._$elem.webkitDisplayingFullscreen);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IOSFullScreen.prototype, "isEnabled", {
get: function () {
return this.isAPIExist;
},
enumerable: false,
configurable: true
});
IOSFullScreen.prototype._bindEvents = function () {
this._$elem.addEventListener('webkitbeginfullscreen', this._callback);
this._$elem.addEventListener('webkitendfullscreen', this._callback);
};
IOSFullScreen.prototype._unbindEvents = function () {
this._$elem.removeEventListener('webkitbeginfullscreen', this._callback);
this._$elem.removeEventListener('webkitendfullscreen', this._callback);
this._$elem.removeEventListener('loadedmetadata', this._enterWhenHasMetaData);
};
IOSFullScreen.prototype._enterWhenHasMetaData = function () {
this._$elem.removeEventListener('loadedmetadata', this._enterWhenHasMetaData);
isFullScreenRequested = false;
this.request();
};
IOSFullScreen.prototype.request = function () {
if (!this.isEnabled || this.isInFullScreen || isFullScreenRequested) {
return;
}
try {
//@ts-expect-error
this._$elem.webkitEnterFullscreen();
}
catch (e) {
if (this._$elem.readyState < HAVE_METADATA) {
this._$elem.addEventListener('loadedmetadata', this._enterWhenHasMetaData);
isFullScreenRequested = true;
}
}
};
IOSFullScreen.prototype.exit = function () {
if (!this.isEnabled || !this.isInFullScreen) {
return;
}
//@ts-expect-error
this._$elem.webkitExitFullscreen();
};
IOSFullScreen.prototype.destroy = function () {
this._unbindEvents();
this._$elem = null;
};
return IOSFullScreen;
}());
exports.default = IOSFullScreen;
//# sourceMappingURL=ios.js.map