to hide the standard controls and UI
-
- if (this.isVimeo && this.supported.ui) {
- var height = 240;
- var offset = (height - padding) / (height / 50);
- this.media.style.transform = "translateY(-".concat(offset, "%)");
- }
-
- return {
- padding: padding,
- ratio: ratio
- };
- }
-
var Listeners =
/*#__PURE__*/
function () {
@@ -8510,7 +20400,7 @@ typeof navigator === "object" && (function () {
// Firefox doesn't get the keycode for whatever reason
- if (!is$1.number(code)) {
+ if (!is$2.number(code)) {
return;
} // Seek by the number keys
@@ -8528,15 +20418,15 @@ typeof navigator === "object" && (function () {
// and any that accept key input http://webaim.org/techniques/keyboard/
var focused = document.activeElement;
- if (is$1.element(focused)) {
+ if (is$2.element(focused)) {
var editable = player.config.selectors.editable;
var seek = elements.inputs.seek;
- if (focused !== seek && matches$1(focused, editable)) {
+ if (focused !== seek && matches$2(focused, editable)) {
return;
}
- if (event.which === 32 && matches$1(focused, 'button, [role^="menuitem"]')) {
+ if (event.which === 32 && matches$2(focused, 'button, [role^="menuitem"]')) {
return;
}
} // Which keycodes should we prevent default
@@ -8623,14 +20513,14 @@ typeof navigator === "object" && (function () {
break;
/* case 73:
- this.setLoop('start');
- break;
- case 76:
- this.setLoop();
- break;
- case 79:
- this.setLoop('end');
- break; */
+ this.setLoop('start');
+ break;
+ case 76:
+ this.setLoop();
+ break;
+ case 79:
+ this.setLoop('end');
+ break; */
default:
break;
@@ -8741,11 +20631,11 @@ typeof navigator === "object" && (function () {
on.call(player, elements.container, 'mousemove mouseleave touchstart touchmove enterfullscreen exitfullscreen', function (event) {
- var controls$$1 = elements.controls; // Remove button states for fullscreen
+ var controlsElement = elements.controls; // Remove button states for fullscreen
- if (controls$$1 && event.type === 'enterfullscreen') {
- controls$$1.pressed = false;
- controls$$1.hover = false;
+ if (controlsElement && event.type === 'enterfullscreen') {
+ controlsElement.pressed = false;
+ controlsElement.hover = false;
} // Show, then hide after a timeout unless another control event occurs
@@ -8764,15 +20654,7 @@ typeof navigator === "object" && (function () {
timers.controls = setTimeout(function () {
return ui.toggleControls.call(player, false);
}, delay);
- }); // Force edge to repaint on exit fullscreen
- // TODO: Fix weird bug where Edge doesn't re-draw when exiting fullscreen
-
- /* if (browser.isEdge) {
- on.call(player, elements.container, 'exitfullscreen', () => {
- setTimeout(() => repaint(elements.container), 100);
- });
- } */
- // Set a gutter for Vimeo
+ }); // Set a gutter for Vimeo
var setGutter = function setGutter(ratio, padding, toggle) {
if (!player.isVimeo) {
@@ -8781,16 +20663,15 @@ typeof navigator === "object" && (function () {
var target = player.elements.wrapper.firstChild;
- var _ratio$split$map = ratio.split(':').map(Number),
- _ratio$split$map2 = _slicedToArray(_ratio$split$map, 2),
- height = _ratio$split$map2[1];
+ var _ratio = _slicedToArray(ratio, 2),
+ y = _ratio[1];
- var _player$embed$ratio$s = player.embed.ratio.split(':').map(Number),
- _player$embed$ratio$s2 = _slicedToArray(_player$embed$ratio$s, 2),
- videoWidth = _player$embed$ratio$s2[0],
- videoHeight = _player$embed$ratio$s2[1];
+ var _getAspectRatio$call = getAspectRatio.call(player),
+ _getAspectRatio$call2 = _slicedToArray(_getAspectRatio$call, 2),
+ videoX = _getAspectRatio$call2[0],
+ videoY = _getAspectRatio$call2[1];
- target.style.maxWidth = toggle ? "".concat(height / videoHeight * videoWidth, "px") : null;
+ target.style.maxWidth = toggle ? "".concat(y / videoY * videoX, "px") : null;
target.style.margin = toggle ? '0 auto' : null;
}; // Resize on fullscreen change
@@ -8808,16 +20689,21 @@ typeof navigator === "object" && (function () {
};
var resized = function resized() {
- window.clearTimeout(timers.resized);
- timers.resized = window.setTimeout(setPlayerSize, 50);
+ clearTimeout(timers.resized);
+ timers.resized = setTimeout(setPlayerSize, 50);
};
on.call(player, elements.container, 'enterfullscreen exitfullscreen', function (event) {
var _player$fullscreen = player.fullscreen,
target = _player$fullscreen.target,
- usingNative = _player$fullscreen.usingNative; // Ignore for iOS native
+ usingNative = _player$fullscreen.usingNative; // Ignore events not from target
- if (!player.isEmbed || target !== elements.container) {
+ if (target !== elements.container) {
+ return;
+ } // If it's not an embed and no ratio specified
+
+
+ if (!player.isEmbed && is$2.empty(player.config.ratio)) {
return;
}
@@ -8890,7 +20776,7 @@ typeof navigator === "object" && (function () {
// Re-fetch the wrapper
var wrapper = getElement.call(player, ".".concat(player.config.classNames.video)); // Bail if there's no wrapper (this should never happen)
- if (!is$1.element(wrapper)) {
+ if (!is$2.element(wrapper)) {
return;
} // On click play, pause or restart
@@ -8949,7 +20835,7 @@ typeof navigator === "object" && (function () {
}); // Update download link when ready and if quality changes
on.call(player, player.media, 'ready qualitychange', function () {
- controls.setDownloadLink.call(player);
+ controls.setDownloadUrl.call(player);
}); // Proxy events to container
// Bubble up key events for Edge
@@ -8971,7 +20857,7 @@ typeof navigator === "object" && (function () {
value: function proxy(event, defaultHandler, customHandlerKey) {
var player = this.player;
var customHandler = player.config.listeners[customHandlerKey];
- var hasCustomHandler = is$1.function(customHandler);
+ var hasCustomHandler = is$2.function(customHandler);
var returned = true; // Execute custom handler
if (hasCustomHandler) {
@@ -8979,7 +20865,7 @@ typeof navigator === "object" && (function () {
} // Only call default handler if not prevented in custom handler
- if (returned && is$1.function(defaultHandler)) {
+ if (returned && is$2.function(defaultHandler)) {
defaultHandler.call(player, event);
}
} // Trigger custom and default handlers
@@ -8992,7 +20878,7 @@ typeof navigator === "object" && (function () {
var passive = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
var player = this.player;
var customHandler = player.config.listeners[customHandlerKey];
- var hasCustomHandler = is$1.function(customHandler);
+ var hasCustomHandler = is$2.function(customHandler);
on.call(player, element, type, function (event) {
return _this2.proxy(event, defaultHandler, customHandlerKey);
}, passive && !hasCustomHandler);
@@ -9000,7 +20886,7 @@ typeof navigator === "object" && (function () {
}, {
key: "controls",
- value: function controls$$1() {
+ value: function controls$1() {
var _this3 = this;
var player = this.player;
@@ -9092,7 +20978,7 @@ typeof navigator === "object" && (function () {
var code = event.keyCode ? event.keyCode : event.which;
var attribute = 'play-on-seeked';
- if (is$1.keyboardEvent(event) && code !== 39 && code !== 37) {
+ if (is$2.keyboardEvent(event) && code !== 39 && code !== 37) {
return;
} // Record seek time so we can prevent hiding controls for a few seconds after seek
@@ -9129,7 +21015,7 @@ typeof navigator === "object" && (function () {
var seekTo = seek.getAttribute('seek-value');
- if (is$1.empty(seekTo)) {
+ if (is$2.empty(seekTo)) {
seekTo = seek.value;
}
@@ -9183,7 +21069,7 @@ typeof navigator === "object" && (function () {
// Only if one time element is used for both currentTime and duration
- if (player.config.toggleInvert && !is$1.element(elements.display.duration)) {
+ if (player.config.toggleInvert && !is$2.element(elements.display.duration)) {
this.bind(elements.display.currentTime, 'click', function () {
// Do nothing if we're at the start
if (player.currentTime === 0) {
@@ -9211,7 +21097,6 @@ typeof navigator === "object" && (function () {
this.bind(elements.controls, 'focusin', function () {
var config = player.config,
- elements = player.elements,
timers = player.timers; // Skip transition to prevent focus from scrolling the parent element
toggleClass(elements.controls, config.classNames.noTransition, true); // Toggle
@@ -9260,299 +21145,378 @@ typeof navigator === "object" && (function () {
return Listeners;
}();
- var loadjs_umd = createCommonjsModule(function (module, exports) {
- (function(root, factory) {
- {
- module.exports = factory();
- }
- }(commonjsGlobal, function() {
- /**
- * Global dependencies.
- * @global {Object} document - DOM
- */
+ var defineProperty$a = objectDefineProperty$1.f;
- var devnull = function() {},
- bundleIdCache = {},
- bundleResultCache = {},
- bundleCallbackQueue = {};
+ var FunctionPrototype$1 = Function.prototype;
+ var FunctionPrototypeToString$1 = FunctionPrototype$1.toString;
+ var nameRE$1 = /^\s*function ([^ (]*)/;
+ var NAME$2 = 'name';
-
- /**
- * Subscribe to bundle load event.
- * @param {string[]} bundleIds - Bundle ids
- * @param {Function} callbackFn - The callback function
- */
- function subscribe(bundleIds, callbackFn) {
- // listify
- bundleIds = bundleIds.push ? bundleIds : [bundleIds];
-
- var depsNotFound = [],
- i = bundleIds.length,
- numWaiting = i,
- fn,
- bundleId,
- r,
- q;
-
- // define callback function
- fn = function (bundleId, pathsNotFound) {
- if (pathsNotFound.length) depsNotFound.push(bundleId);
-
- numWaiting--;
- if (!numWaiting) callbackFn(depsNotFound);
- };
-
- // register callback
- while (i--) {
- bundleId = bundleIds[i];
-
- // execute callback if in result cache
- r = bundleResultCache[bundleId];
- if (r) {
- fn(bundleId, r);
- continue;
- }
-
- // add to callback queue
- q = bundleCallbackQueue[bundleId] = bundleCallbackQueue[bundleId] || [];
- q.push(fn);
- }
- }
-
-
- /**
- * Publish bundle load event.
- * @param {string} bundleId - Bundle id
- * @param {string[]} pathsNotFound - List of files not found
- */
- function publish(bundleId, pathsNotFound) {
- // exit if id isn't defined
- if (!bundleId) return;
-
- var q = bundleCallbackQueue[bundleId];
-
- // cache result
- bundleResultCache[bundleId] = pathsNotFound;
-
- // exit if queue is empty
- if (!q) return;
-
- // empty callback queue
- while (q.length) {
- q[0](bundleId, pathsNotFound);
- q.splice(0, 1);
- }
- }
-
-
- /**
- * Execute callbacks.
- * @param {Object or Function} args - The callback args
- * @param {string[]} depsNotFound - List of dependencies not found
- */
- function executeCallbacks(args, depsNotFound) {
- // accept function as argument
- if (args.call) args = {success: args};
-
- // success and error callbacks
- if (depsNotFound.length) (args.error || devnull)(depsNotFound);
- else (args.success || devnull)(args);
- }
-
-
- /**
- * Load individual file.
- * @param {string} path - The file path
- * @param {Function} callbackFn - The callback function
- */
- function loadFile(path, callbackFn, args, numTries) {
- var doc = document,
- async = args.async,
- maxTries = (args.numRetries || 0) + 1,
- beforeCallbackFn = args.before || devnull,
- pathStripped = path.replace(/^(css|img)!/, ''),
- isCss,
- e;
-
- numTries = numTries || 0;
-
- if (/(^css!|\.css$)/.test(path)) {
- isCss = true;
-
- // css
- e = doc.createElement('link');
- e.rel = 'stylesheet';
- e.href = pathStripped; //.replace(/^css!/, ''); // remove "css!" prefix
- } else if (/(^img!|\.(png|gif|jpg|svg)$)/.test(path)) {
- // image
- e = doc.createElement('img');
- e.src = pathStripped;
- } else {
- // javascript
- e = doc.createElement('script');
- e.src = path;
- e.async = async === undefined ? true : async;
- }
-
- e.onload = e.onerror = e.onbeforeload = function (ev) {
- var result = ev.type[0];
-
- // Note: The following code isolates IE using `hideFocus` and treats empty
- // stylesheets as failures to get around lack of onerror support
- if (isCss && 'hideFocus' in e) {
+ // Function instances `.name` property
+ // https://tc39.github.io/ecma262/#sec-function-instances-name
+ if (descriptors$1 && !(NAME$2 in FunctionPrototype$1)) {
+ defineProperty$a(FunctionPrototype$1, NAME$2, {
+ configurable: true,
+ get: function () {
try {
- if (!e.sheet.cssText.length) result = 'e';
- } catch (x) {
- // sheets objects created from load errors don't allow access to
- // `cssText` (unless error is Code:18 SecurityError)
- if (x.code != 18) result = 'e';
+ return FunctionPrototypeToString$1.call(this).match(nameRE$1)[1];
+ } catch (error) {
+ return '';
}
}
-
- // handle retries in case of load failure
- if (result == 'e') {
- // increment counter
- numTries += 1;
-
- // exit function and try again
- if (numTries < maxTries) {
- return loadFile(path, callbackFn, args, numTries);
- }
- }
-
- // execute callback
- callbackFn(path, result, ev.defaultPrevented);
- };
-
- // add to document (unless callback returns `false`)
- if (beforeCallbackFn(path, e) !== false) doc.head.appendChild(e);
- }
-
-
- /**
- * Load multiple files.
- * @param {string[]} paths - The file paths
- * @param {Function} callbackFn - The callback function
- */
- function loadFiles(paths, callbackFn, args) {
- // listify paths
- paths = paths.push ? paths : [paths];
-
- var numWaiting = paths.length,
- x = numWaiting,
- pathsNotFound = [],
- fn,
- i;
-
- // define callback function
- fn = function(path, result, defaultPrevented) {
- // handle error
- if (result == 'e') pathsNotFound.push(path);
-
- // handle beforeload event. If defaultPrevented then that means the load
- // will be blocked (ex. Ghostery/ABP on Safari)
- if (result == 'b') {
- if (defaultPrevented) pathsNotFound.push(path);
- else return;
- }
-
- numWaiting--;
- if (!numWaiting) callbackFn(pathsNotFound);
- };
-
- // load scripts
- for (i=0; i < x; i++) loadFile(paths[i], fn, args);
- }
-
-
- /**
- * Initiate script load and register bundle.
- * @param {(string|string[])} paths - The file paths
- * @param {(string|Function)} [arg1] - The bundleId or success callback
- * @param {Function} [arg2] - The success or error callback
- * @param {Function} [arg3] - The error callback
- */
- function loadjs(paths, arg1, arg2) {
- var bundleId,
- args;
-
- // bundleId (if string)
- if (arg1 && arg1.trim) bundleId = arg1;
-
- // args (default is {})
- args = (bundleId ? arg2 : arg1) || {};
-
- // throw error if bundle is already defined
- if (bundleId) {
- if (bundleId in bundleIdCache) {
- throw "LoadJS";
- } else {
- bundleIdCache[bundleId] = true;
- }
- }
-
- // load scripts
- loadFiles(paths, function (pathsNotFound) {
- // execute callbacks
- executeCallbacks(args, pathsNotFound);
-
- // publish bundle load event
- publish(bundleId, pathsNotFound);
- }, args);
- }
-
-
- /**
- * Execute callbacks when dependencies have been satisfied.
- * @param {(string|string[])} deps - List of bundle ids
- * @param {Object} args - success/error arguments
- */
- loadjs.ready = function ready(deps, args) {
- // subscribe to bundle load event
- subscribe(deps, function (depsNotFound) {
- // execute callbacks
- executeCallbacks(args, depsNotFound);
});
+ }
- return loadjs;
- };
+ var max$7 = Math.max;
+ var min$c = Math.min;
+ var MAX_SAFE_INTEGER$3 = 0x1FFFFFFFFFFFFF;
+ var MAXIMUM_ALLOWED_LENGTH_EXCEEDED$1 = 'Maximum allowed length exceeded';
-
- /**
- * Manually satisfy bundle dependencies.
- * @param {string} bundleId - The bundle id
- */
- loadjs.done = function done(bundleId) {
- publish(bundleId, []);
- };
-
-
- /**
- * Reset loadjs dependencies statuses
- */
- loadjs.reset = function reset() {
- bundleIdCache = {};
- bundleResultCache = {};
- bundleCallbackQueue = {};
- };
-
-
- /**
- * Determine if bundle has already been defined
- * @param String} bundleId - The bundle id
- */
- loadjs.isDefined = function isDefined(bundleId) {
- return bundleId in bundleIdCache;
- };
-
-
- // export
- return loadjs;
-
- }));
+ // `Array.prototype.splice` method
+ // https://tc39.github.io/ecma262/#sec-array.prototype.splice
+ // with adding support of @@species
+ _export$1({ target: 'Array', proto: true, forced: !arrayMethodHasSpeciesSupport$1('splice') }, {
+ splice: function splice(start, deleteCount /* , ...items */) {
+ var O = toObject$1(this);
+ var len = toLength$1(O.length);
+ var actualStart = toAbsoluteIndex$1(start, len);
+ var argumentsLength = arguments.length;
+ var insertCount, actualDeleteCount, A, k, from, to;
+ if (argumentsLength === 0) {
+ insertCount = actualDeleteCount = 0;
+ } else if (argumentsLength === 1) {
+ insertCount = 0;
+ actualDeleteCount = len - actualStart;
+ } else {
+ insertCount = argumentsLength - 2;
+ actualDeleteCount = min$c(max$7(toInteger$1(deleteCount), 0), len - actualStart);
+ }
+ if (len + insertCount - actualDeleteCount > MAX_SAFE_INTEGER$3) {
+ throw TypeError(MAXIMUM_ALLOWED_LENGTH_EXCEEDED$1);
+ }
+ A = arraySpeciesCreate$1(O, actualDeleteCount);
+ for (k = 0; k < actualDeleteCount; k++) {
+ from = actualStart + k;
+ if (from in O) createProperty$1(A, k, O[from]);
+ }
+ A.length = actualDeleteCount;
+ if (insertCount < actualDeleteCount) {
+ for (k = actualStart; k < len - actualDeleteCount; k++) {
+ from = k + actualDeleteCount;
+ to = k + insertCount;
+ if (from in O) O[to] = O[from];
+ else delete O[to];
+ }
+ for (k = len; k > len - actualDeleteCount + insertCount; k--) delete O[k - 1];
+ } else if (insertCount > actualDeleteCount) {
+ for (k = len - actualDeleteCount; k > actualStart; k--) {
+ from = k + actualDeleteCount - 1;
+ to = k + insertCount - 1;
+ if (from in O) O[to] = O[from];
+ else delete O[to];
+ }
+ }
+ for (k = 0; k < insertCount; k++) {
+ O[k + actualStart] = arguments[k + 2];
+ }
+ O.length = len - actualDeleteCount + insertCount;
+ return A;
+ }
+ });
+
+ var loadjs_umd = createCommonjsModule(function (module, exports) {
+ (function (root, factory) {
+ {
+ module.exports = factory();
+ }
+ })(commonjsGlobal, function () {
+ /**
+ * Global dependencies.
+ * @global {Object} document - DOM
+ */
+ var devnull = function devnull() {},
+ bundleIdCache = {},
+ bundleResultCache = {},
+ bundleCallbackQueue = {};
+ /**
+ * Subscribe to bundle load event.
+ * @param {string[]} bundleIds - Bundle ids
+ * @param {Function} callbackFn - The callback function
+ */
+
+
+ function subscribe(bundleIds, callbackFn) {
+ // listify
+ bundleIds = bundleIds.push ? bundleIds : [bundleIds];
+ var depsNotFound = [],
+ i = bundleIds.length,
+ numWaiting = i,
+ fn,
+ bundleId,
+ r,
+ q; // define callback function
+
+ fn = function fn(bundleId, pathsNotFound) {
+ if (pathsNotFound.length) depsNotFound.push(bundleId);
+ numWaiting--;
+ if (!numWaiting) callbackFn(depsNotFound);
+ }; // register callback
+
+
+ while (i--) {
+ bundleId = bundleIds[i]; // execute callback if in result cache
+
+ r = bundleResultCache[bundleId];
+
+ if (r) {
+ fn(bundleId, r);
+ continue;
+ } // add to callback queue
+
+
+ q = bundleCallbackQueue[bundleId] = bundleCallbackQueue[bundleId] || [];
+ q.push(fn);
+ }
+ }
+ /**
+ * Publish bundle load event.
+ * @param {string} bundleId - Bundle id
+ * @param {string[]} pathsNotFound - List of files not found
+ */
+
+
+ function publish(bundleId, pathsNotFound) {
+ // exit if id isn't defined
+ if (!bundleId) return;
+ var q = bundleCallbackQueue[bundleId]; // cache result
+
+ bundleResultCache[bundleId] = pathsNotFound; // exit if queue is empty
+
+ if (!q) return; // empty callback queue
+
+ while (q.length) {
+ q[0](bundleId, pathsNotFound);
+ q.splice(0, 1);
+ }
+ }
+ /**
+ * Execute callbacks.
+ * @param {Object or Function} args - The callback args
+ * @param {string[]} depsNotFound - List of dependencies not found
+ */
+
+
+ function executeCallbacks(args, depsNotFound) {
+ // accept function as argument
+ if (args.call) args = {
+ success: args
+ }; // success and error callbacks
+
+ if (depsNotFound.length) (args.error || devnull)(depsNotFound);else (args.success || devnull)(args);
+ }
+ /**
+ * Load individual file.
+ * @param {string} path - The file path
+ * @param {Function} callbackFn - The callback function
+ */
+
+
+ function loadFile(path, callbackFn, args, numTries) {
+ var doc = document,
+ async = args.async,
+ maxTries = (args.numRetries || 0) + 1,
+ beforeCallbackFn = args.before || devnull,
+ pathStripped = path.replace(/^(css|img)!/, ''),
+ isLegacyIECss,
+ e;
+ numTries = numTries || 0;
+
+ if (/(^css!|\.css$)/.test(path)) {
+ // css
+ e = doc.createElement('link');
+ e.rel = 'stylesheet';
+ e.href = pathStripped; // tag IE9+
+
+ isLegacyIECss = 'hideFocus' in e; // use preload in IE Edge (to detect load errors)
+
+ if (isLegacyIECss && e.relList) {
+ isLegacyIECss = 0;
+ e.rel = 'preload';
+ e.as = 'style';
+ }
+ } else if (/(^img!|\.(png|gif|jpg|svg)$)/.test(path)) {
+ // image
+ e = doc.createElement('img');
+ e.src = pathStripped;
+ } else {
+ // javascript
+ e = doc.createElement('script');
+ e.src = path;
+ e.async = async === undefined ? true : async;
+ }
+
+ e.onload = e.onerror = e.onbeforeload = function (ev) {
+ var result = ev.type[0]; // treat empty stylesheets as failures to get around lack of onerror
+ // support in IE9-11
+
+ if (isLegacyIECss) {
+ try {
+ if (!e.sheet.cssText.length) result = 'e';
+ } catch (x) {
+ // sheets objects created from load errors don't allow access to
+ // `cssText` (unless error is Code:18 SecurityError)
+ if (x.code != 18) result = 'e';
+ }
+ } // handle retries in case of load failure
+
+
+ if (result == 'e') {
+ // increment counter
+ numTries += 1; // exit function and try again
+
+ if (numTries < maxTries) {
+ return loadFile(path, callbackFn, args, numTries);
+ }
+ } else if (e.rel == 'preload' && e.as == 'style') {
+ // activate preloaded stylesheets
+ return e.rel = 'stylesheet'; // jshint ignore:line
+ } // execute callback
+
+
+ callbackFn(path, result, ev.defaultPrevented);
+ }; // add to document (unless callback returns `false`)
+
+
+ if (beforeCallbackFn(path, e) !== false) doc.head.appendChild(e);
+ }
+ /**
+ * Load multiple files.
+ * @param {string[]} paths - The file paths
+ * @param {Function} callbackFn - The callback function
+ */
+
+
+ function loadFiles(paths, callbackFn, args) {
+ // listify paths
+ paths = paths.push ? paths : [paths];
+ var numWaiting = paths.length,
+ x = numWaiting,
+ pathsNotFound = [],
+ fn,
+ i; // define callback function
+
+ fn = function fn(path, result, defaultPrevented) {
+ // handle error
+ if (result == 'e') pathsNotFound.push(path); // handle beforeload event. If defaultPrevented then that means the load
+ // will be blocked (ex. Ghostery/ABP on Safari)
+
+ if (result == 'b') {
+ if (defaultPrevented) pathsNotFound.push(path);else return;
+ }
+
+ numWaiting--;
+ if (!numWaiting) callbackFn(pathsNotFound);
+ }; // load scripts
+
+
+ for (i = 0; i < x; i++) {
+ loadFile(paths[i], fn, args);
+ }
+ }
+ /**
+ * Initiate script load and register bundle.
+ * @param {(string|string[])} paths - The file paths
+ * @param {(string|Function|Object)} [arg1] - The (1) bundleId or (2) success
+ * callback or (3) object literal with success/error arguments, numRetries,
+ * etc.
+ * @param {(Function|Object)} [arg2] - The (1) success callback or (2) object
+ * literal with success/error arguments, numRetries, etc.
+ */
+
+
+ function loadjs(paths, arg1, arg2) {
+ var bundleId, args; // bundleId (if string)
+
+ if (arg1 && arg1.trim) bundleId = arg1; // args (default is {})
+
+ args = (bundleId ? arg2 : arg1) || {}; // throw error if bundle is already defined
+
+ if (bundleId) {
+ if (bundleId in bundleIdCache) {
+ throw "LoadJS";
+ } else {
+ bundleIdCache[bundleId] = true;
+ }
+ }
+
+ function loadFn(resolve, reject) {
+ loadFiles(paths, function (pathsNotFound) {
+ // execute callbacks
+ executeCallbacks(args, pathsNotFound); // resolve Promise
+
+ if (resolve) {
+ executeCallbacks({
+ success: resolve,
+ error: reject
+ }, pathsNotFound);
+ } // publish bundle load event
+
+
+ publish(bundleId, pathsNotFound);
+ }, args);
+ }
+
+ if (args.returnPromise) return new Promise(loadFn);else loadFn();
+ }
+ /**
+ * Execute callbacks when dependencies have been satisfied.
+ * @param {(string|string[])} deps - List of bundle ids
+ * @param {Object} args - success/error arguments
+ */
+
+
+ loadjs.ready = function ready(deps, args) {
+ // subscribe to bundle load event
+ subscribe(deps, function (depsNotFound) {
+ // execute callbacks
+ executeCallbacks(args, depsNotFound);
+ });
+ return loadjs;
+ };
+ /**
+ * Manually satisfy bundle dependencies.
+ * @param {string} bundleId - The bundle id
+ */
+
+
+ loadjs.done = function done(bundleId) {
+ publish(bundleId, []);
+ };
+ /**
+ * Reset loadjs dependencies statuses
+ */
+
+
+ loadjs.reset = function reset() {
+ bundleIdCache = {};
+ bundleResultCache = {};
+ bundleCallbackQueue = {};
+ };
+ /**
+ * Determine if bundle has already been defined
+ * @param String} bundleId - The bundle id
+ */
+
+
+ loadjs.isDefined = function isDefined(bundleId) {
+ return bundleId in bundleIdCache;
+ }; // export
+
+
+ return loadjs;
+ });
});
- // ==========================================================================
function loadScript(url) {
return new Promise(function (resolve, reject) {
loadjs_umd(url, {
@@ -9563,11 +21527,11 @@ typeof navigator === "object" && (function () {
}
function parseId(url) {
- if (is$1.empty(url)) {
+ if (is$2.empty(url)) {
return null;
}
- if (is$1.number(Number(url))) {
+ if (is$2.number(Number(url))) {
return url;
}
@@ -9594,26 +21558,26 @@ typeof navigator === "object" && (function () {
// Add embed class for responsive
toggleClass(this.elements.wrapper, this.config.classNames.embed, true); // Set intial ratio
- setAspectRatio.call(this); // Load the API if not already
+ setAspectRatio.call(this); // Load the SDK if not already
- if (!is$1.object(window.Vimeo)) {
+ if (!is$2.object(window.Vimeo)) {
loadScript(this.config.urls.vimeo.sdk).then(function () {
vimeo.ready.call(_this);
}).catch(function (error) {
- _this.debug.warn('Vimeo API failed to load', error);
+ _this.debug.warn('Vimeo SDK (player.js) failed to load', error);
});
} else {
vimeo.ready.call(this);
}
},
// API Ready
- ready: function ready$$1() {
+ ready: function ready() {
var _this2 = this;
var player = this;
var config = player.config.vimeo; // Get Vimeo params for the iframe
- var params = buildUrlParams(extend({}, {
+ var params = buildUrlParams(extend$1({}, {
loop: player.config.loop.active,
autoplay: player.autoplay,
muted: player.muted,
@@ -9623,13 +21587,13 @@ typeof navigator === "object" && (function () {
var source = player.media.getAttribute('src'); // Get from
if needed
- if (is$1.empty(source)) {
+ if (is$2.empty(source)) {
source = player.media.getAttribute(player.config.attributes.embed.id);
}
var id = parseId(source); // Build an iframe
- var iframe = createElement('iframe');
+ var iframe = createElement$1('iframe');
var src = format(player.config.urls.vimeo.iframe, id, params);
iframe.setAttribute('src', src);
iframe.setAttribute('allowfullscreen', '');
@@ -9638,7 +21602,7 @@ typeof navigator === "object" && (function () {
var poster = player.poster; // Inject the package
- var wrapper = createElement('div', {
+ var wrapper = createElement$1('div', {
poster: poster,
class: player.config.classNames.embedContainer
});
@@ -9646,7 +21610,7 @@ typeof navigator === "object" && (function () {
player.media = replaceElement(wrapper, player.media); // Get poster image
fetch(format(player.config.urls.vimeo.api, id), 'json').then(function (response) {
- if (is$1.empty(response)) {
+ if (is$2.empty(response)) {
return;
} // Get the URL for thumbnail
@@ -9755,7 +21719,7 @@ typeof navigator === "object" && (function () {
return muted;
},
set: function set(input) {
- var toggle = is$1.boolean(input) ? input : false;
+ var toggle = is$2.boolean(input) ? input : false;
player.embed.setVolume(toggle ? 0 : player.config.volume).then(function () {
muted = toggle;
triggerEvent.call(player, player.media, 'volumechange');
@@ -9769,7 +21733,7 @@ typeof navigator === "object" && (function () {
return loop;
},
set: function set(input) {
- var toggle = is$1.boolean(input) ? input : player.config.loop.active;
+ var toggle = is$2.boolean(input) ? input : player.config.loop.active;
player.embed.setLoop(toggle).then(function () {
loop = toggle;
});
@@ -9779,7 +21743,7 @@ typeof navigator === "object" && (function () {
var currentSrc;
player.embed.getVideoUrl().then(function (value) {
currentSrc = value;
- controls.setDownloadLink.call(player);
+ controls.setDownloadUrl.call(player);
}).catch(function (error) {
_this2.debug.warn(error);
});
@@ -9800,8 +21764,8 @@ typeof navigator === "object" && (function () {
width = _dimensions[0],
height = _dimensions[1];
- player.embed.ratio = "".concat(width, ":").concat(height);
- setAspectRatio.call(_this2, player.embed.ratio);
+ player.embed.ratio = [width, height];
+ setAspectRatio.call(_this2);
}); // Set autopause
player.embed.setAutopause(player.config.autopause).then(function (state) {
@@ -9845,7 +21809,7 @@ typeof navigator === "object" && (function () {
}
});
- if (is$1.element(player.embed.element) && player.supported.ui) {
+ if (is$2.element(player.embed.element) && player.supported.ui) {
var frame = player.embed.element; // Fix keyboard focus issues
// https://github.com/sampotts/plyr/issues/317
@@ -9900,10 +21864,8 @@ typeof navigator === "object" && (function () {
}
};
- // ==========================================================================
-
function parseId$1(url) {
- if (is$1.empty(url)) {
+ if (is$2.empty(url)) {
return null;
}
@@ -9923,82 +21885,84 @@ typeof navigator === "object" && (function () {
}
}
+ function getHost$2(config) {
+ if (config.noCookie) {
+ return 'https://www.youtube-nocookie.com';
+ }
+
+ if (window.location.protocol === 'http:') {
+ return 'http://www.youtube.com';
+ } // Use YouTube's default
+
+
+ return undefined;
+ }
+
var youtube = {
setup: function setup() {
var _this = this;
// Add embed class for responsive
- toggleClass(this.elements.wrapper, this.config.classNames.embed, true); // Set aspect ratio
+ toggleClass(this.elements.wrapper, this.config.classNames.embed, true); // Setup API
- setAspectRatio.call(this); // Setup API
-
- if (is$1.object(window.YT) && is$1.function(window.YT.Player)) {
+ if (is$2.object(window.YT) && is$2.function(window.YT.Player)) {
youtube.ready.call(this);
} else {
- // Load the API
- loadScript(this.config.urls.youtube.sdk).catch(function (error) {
- _this.debug.warn('YouTube API failed to load', error);
- }); // Setup callback for the API
- // YouTube has it's own system of course...
-
- window.onYouTubeReadyCallbacks = window.onYouTubeReadyCallbacks || []; // Add to queue
-
- window.onYouTubeReadyCallbacks.push(function () {
- youtube.ready.call(_this);
- }); // Set callback to process queue
+ // Reference current global callback
+ var callback = window.onYouTubeIframeAPIReady; // Set callback to process queue
window.onYouTubeIframeAPIReady = function () {
- window.onYouTubeReadyCallbacks.forEach(function (callback) {
+ // Call global callback if set
+ if (is$2.function(callback)) {
callback();
- });
- };
+ }
+
+ youtube.ready.call(_this);
+ }; // Load the SDK
+
+
+ loadScript(this.config.urls.youtube.sdk).catch(function (error) {
+ _this.debug.warn('YouTube API failed to load', error);
+ });
}
},
// Get the media title
getTitle: function getTitle(videoId) {
var _this2 = this;
- // Try via undocumented API method first
- // This method disappears now and then though...
- // https://github.com/sampotts/plyr/issues/709
- if (is$1.function(this.embed.getVideoData)) {
- var _this$embed$getVideoD = this.embed.getVideoData(),
- title = _this$embed$getVideoD.title;
+ var url = format(this.config.urls.youtube.api, videoId);
+ fetch(url).then(function (data) {
+ if (is$2.object(data)) {
+ var title = data.title,
+ height = data.height,
+ width = data.width; // Set title
- if (is$1.empty(title)) {
- this.config.title = title;
- ui.setTitle.call(this);
- return;
+ _this2.config.title = title;
+ ui.setTitle.call(_this2); // Set aspect ratio
+
+ _this2.embed.ratio = [width, height];
}
- } // Or via Google API
-
- var key = this.config.keys.google;
-
- if (is$1.string(key) && !is$1.empty(key)) {
- var url = format(this.config.urls.youtube.api, videoId, key);
- fetch(url).then(function (result) {
- if (is$1.object(result)) {
- _this2.config.title = result.items[0].snippet.title;
- ui.setTitle.call(_this2);
- }
- }).catch(function () {});
- }
+ setAspectRatio.call(_this2);
+ }).catch(function () {
+ // Set aspect ratio
+ setAspectRatio.call(_this2);
+ });
},
// API ready
- ready: function ready$$1() {
+ ready: function ready() {
var player = this; // Ignore already setup (race condition)
- var currentId = player.media.getAttribute('id');
+ var currentId = player.media && player.media.getAttribute('id');
- if (!is$1.empty(currentId) && currentId.startsWith('youtube-')) {
+ if (!is$2.empty(currentId) && currentId.startsWith('youtube-')) {
return;
} // Get the source URL or ID
var source = player.media.getAttribute('src'); // Get from
if needed
- if (is$1.empty(source)) {
+ if (is$2.empty(source)) {
source = player.media.getAttribute(this.config.attributes.embed.id);
} // Replace the