UNPKG

rx-player

Version:
53 lines (52 loc) 2.37 kB
"use strict"; /** * Copyright 2015 CANAL+ Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.default = canRelyOnVideoVisibilityAndSize; var browser_version_1 = require("./browser_version"); var env_detector_1 = require("./env_detector"); /** * This functions tells if the RxPlayer can trust on any browser data * about video element visibility and size. * * On Firefox (version >= 67) : * - The PIP feature exists but can be disabled by default according * to the OS and the channel used for updating / getting Firefox binaries. * - There is no API to know if the Picture-in-picture (PIP) is enabled * - There is no API to get the width of the PIP window * * The element clientWidth tells the width of the original video element, and * no PIP window API exists to determine its presence or width. Thus, there are * no way to determine the real width of the video window, as we can't know when * the PIP feature or window is enabled, and we can't have access to the windo * size information. * * Moreover, when the document is considered as hidden (e.g. in case of hidden * tab), as there is no way to know if the PIP feature or window is enabled, * we can't know if the video window is visible or not. * @returns {boolean} */ function canRelyOnVideoVisibilityAndSize() { if (env_detector_1.default.browser !== env_detector_1.default.BROWSERS.Firefox) { return true; } var firefoxVersion = (0, browser_version_1.getFirefoxVersion)(); if (firefoxVersion === null || firefoxVersion < 67) { return true; } var proto = HTMLVideoElement === null || HTMLVideoElement === void 0 ? void 0 : HTMLVideoElement.prototype; return (proto === null || proto === void 0 ? void 0 : proto.requirePictureInPicture) !== undefined; }