@aidenlx/player
Version:
Headless web components that make integrating media on the a web a breeze.
57 lines (56 loc) • 1.98 kB
JavaScript
import "../../../chunks/chunk.LNH2V2XS.js";
import {
FullscreenController,
listen,
noop
} from "@vidstack/foundation";
class VideoFullscreenController extends FullscreenController {
constructor(host, screenOrientationController, _presentationController) {
super(host, screenOrientationController);
this._presentationController = _presentationController;
}
get isFullscreen() {
return this.isSupportedNatively ? this.isNativeFullscreen : this._presentationController.isFullscreenMode;
}
get isSupported() {
return this.isSupportedNatively || this.isSupportedOnSafari;
}
get isSupportedOnSafari() {
return this._presentationController.isSupported;
}
async _makeEnterFullscreenRequest() {
return this.isSupportedNatively ? super._makeEnterFullscreenRequest() : this._makeFullscreenRequestOnSafari();
}
async _makeFullscreenRequestOnSafari() {
return this._presentationController.setPresentationMode("fullscreen");
}
async _makeExitFullscreenRequest() {
return this.isSupportedNatively ? super._makeExitFullscreenRequest() : this._makeExitFullscreenRequestOnSafari();
}
async _makeExitFullscreenRequestOnSafari() {
return this._presentationController.setPresentationMode("inline");
}
_addFullscreenChangeEventListener(handler) {
if (this.isSupportedNatively) {
return super._addFullscreenChangeEventListener(handler);
}
if (this.isSupportedOnSafari) {
if (false) {
this._logger?.debug("adding `vds-video-presentation-change` listener");
}
return listen(this._host, "vds-video-presentation-change", this._handlePresentationModeChange.bind(this));
}
return noop;
}
_handlePresentationModeChange(event) {
this._handleFullscreenChange(event);
}
_addFullscreenErrorEventListener(handler) {
if (!this.isSupportedNatively)
return noop;
return super._addFullscreenErrorEventListener(handler);
}
}
export {
VideoFullscreenController
};