aboutsummaryrefslogtreecommitdiffstats
path: root/dist/plyr.mjs
diff options
context:
space:
mode:
authorSam Potts <sam@potts.es>2019-02-19 00:19:25 +1100
committerSam Potts <sam@potts.es>2019-02-19 00:19:25 +1100
commit153b8dc6bb96fdba8340a523c8828a72a832fcdf (patch)
tree14c60871a970b26e05b6b154a81302f65617f67f /dist/plyr.mjs
parentdf61e5cdd20f3bb4eb29a98000be8770690ad018 (diff)
downloadplyr-153b8dc6bb96fdba8340a523c8828a72a832fcdf.tar.lz
plyr-153b8dc6bb96fdba8340a523c8828a72a832fcdf.tar.xz
plyr-153b8dc6bb96fdba8340a523c8828a72a832fcdf.zip
Added RangeTouch, updated Shr lib in demo
Diffstat (limited to 'dist/plyr.mjs')
-rw-r--r--dist/plyr.mjs828
1 files changed, 552 insertions, 276 deletions
diff --git a/dist/plyr.mjs b/dist/plyr.mjs
index 47ecfed3..29852b70 100644
--- a/dist/plyr.mjs
+++ b/dist/plyr.mjs
@@ -93,93 +93,367 @@ function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance");
}
+const defaults = {
+ addCSS: true, // Add CSS to the element to improve usability (required here or in your CSS!)
+ thumbWidth: 15, // The width of the thumb handle
+ watch: true, // Watch for new elements that match a string target
+};
+
+// Element matches a selector
+function matches(element, selector) {
+
+ function match() {
+ return Array.from(document.querySelectorAll(selector)).includes(this);
+ }
+
+ const matches =
+ match;
+
+ return matches.call(element, selector);
+}
+
+// Trigger event
+function trigger(element, type) {
+ if (!element || !type) {
+ return;
+ }
+
+ // Create and dispatch the event
+ const event = new Event(type);
+
+ // Dispatch the event
+ element.dispatchEvent(event);
+}
+
// ==========================================================================
// Type checking utils
// ==========================================================================
-var getConstructor = function getConstructor(input) {
+
+const getConstructor = input => (input !== null && typeof input !== 'undefined' ? input.constructor : null);
+const instanceOf = (input, constructor) => Boolean(input && constructor && input instanceof constructor);
+
+const isNullOrUndefined = input => input === null || typeof input === 'undefined';
+const isObject = input => getConstructor(input) === Object;
+const isNumber = input => getConstructor(input) === Number && !Number.isNaN(input);
+const isString = input => getConstructor(input) === String;
+const isBoolean = input => getConstructor(input) === Boolean;
+const isFunction = input => getConstructor(input) === Function;
+const isArray = input => Array.isArray(input);
+const isNodeList = input => instanceOf(input, NodeList);
+const isElement = input => instanceOf(input, Element);
+const isEvent = input => instanceOf(input, Event);
+const isEmpty = input =>
+ isNullOrUndefined(input) ||
+ ((isString(input) || isArray(input) || isNodeList(input)) && !input.length) ||
+ (isObject(input) && !Object.keys(input).length);
+
+var is = {
+ nullOrUndefined: isNullOrUndefined,
+ object: isObject,
+ number: isNumber,
+ string: isString,
+ boolean: isBoolean,
+ function: isFunction,
+ array: isArray,
+ nodeList: isNodeList,
+ element: isElement,
+ event: isEvent,
+ empty: isEmpty,
+};
+
+// Get the number of decimal places
+function getDecimalPlaces(value) {
+ const match = `${value}`.match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);
+
+ if (!match) {
+ return 0;
+ }
+
+ return Math.max(
+ 0,
+ // Number of digits right of decimal point.
+ (match[1] ? match[1].length : 0) -
+ // Adjust for scientific notation.
+ (match[2] ? +match[2] : 0),
+ );
+}
+
+// Round to the nearest step
+function round(number, step) {
+ if (step < 1) {
+ const places = getDecimalPlaces(step);
+ return parseFloat(number.toFixed(places));
+ }
+ return Math.round(number / step) * step;
+}
+
+// ==========================================================================
+
+class RangeTouch {
+ /**
+ * Setup a new instance
+ * @param {String|Element} target
+ * @param {Object} options
+ */
+ constructor(target, options) {
+ if (is.element(target)) {
+ // An Element is passed, use it directly
+ this.element = target;
+ } else if (is.string(target)) {
+ // A CSS Selector is passed, fetch it from the DOM
+ this.element = document.querySelector(target);
+ }
+
+ if (!is.element(this.element) || !is.empty(this.element.rangeTouch)) {
+ return;
+ }
+
+ this.config = Object.assign({}, defaults, options);
+
+ this.init();
+ }
+
+ static get enabled() {
+ return 'ontouchstart' in document.documentElement;
+ }
+
+ /**
+ * Setup multiple instances
+ * @param {String|Element|NodeList|Array} target
+ * @param {Object} options
+ */
+ static setup(target, options = {}) {
+ let targets = null;
+
+ if (is.empty(target) || is.string(target)) {
+ targets = Array.from(document.querySelectorAll(is.string(target) ? target : 'input[type="range"]'));
+ } else if (is.element(target)) {
+ targets = [target];
+ } else if (is.nodeList(target)) {
+ targets = Array.from(target);
+ } else if (is.array(target)) {
+ targets = target.filter(is.element);
+ }
+
+ if (is.empty(targets)) {
+ return null;
+ }
+
+ const config = Object.assign({}, defaults, options);
+
+ if (is.string(target) && config.watch) {
+ // Create an observer instance
+ const observer = new MutationObserver(mutations => {
+ Array.from(mutations).forEach(mutation => {
+ Array.from(mutation.addedNodes).forEach(node => {
+ if (!is.element(node) || !matches(node, target)) {
+ return;
+ }
+
+ // eslint-disable-next-line no-unused-vars
+ const range = new RangeTouch(node, config);
+ });
+ });
+ });
+
+ // Pass in the target node, as well as the observer options
+ observer.observe(document.body, {
+ childList: true,
+ subtree: true,
+ });
+ }
+
+ return targets.map(t => new RangeTouch(t, options));
+ }
+
+ init() {
+ // Bail if not a touch enabled device
+ if (!RangeTouch.enabled) {
+ return;
+ }
+
+ // Add useful CSS
+ if (this.config.addCSS) {
+ // TODO: Restore original values on destroy
+ this.element.style.userSelect = 'none';
+ this.element.style.webKitUserSelect = 'none';
+ this.element.style.touchAction = 'manipulation';
+ }
+
+ this.listeners(true);
+
+ this.element.rangeTouch = this;
+ }
+
+ destroy() {
+ // Bail if not a touch enabled device
+ if (!RangeTouch.enabled) {
+ return;
+ }
+
+ this.listeners(false);
+
+ this.element.rangeTouch = null;
+ }
+
+ listeners(toggle) {
+ const method = toggle ? 'addEventListener' : 'removeEventListener';
+
+ // Listen for events
+ ['touchstart', 'touchmove', 'touchend'].forEach(type => {
+ this.element[method](type, event => this.set(event), false);
+ });
+ }
+
+ /**
+ * Get the value based on touch position
+ * @param {Event} event
+ */
+ get(event) {
+ if (!RangeTouch.enabled || !is.event(event)) {
+ return null;
+ }
+
+ const input = event.target;
+ const touch = event.changedTouches[0];
+ const min = parseFloat(input.getAttribute('min')) || 0;
+ const max = parseFloat(input.getAttribute('max')) || 100;
+ const step = parseFloat(input.getAttribute('step')) || 1;
+ const delta = max - min;
+
+ // Calculate percentage
+ let percent;
+ const clientRect = input.getBoundingClientRect();
+ const thumbWidth = ((100 / clientRect.width) * (this.config.thumbWidth / 2)) / 100;
+
+ // Determine left percentage
+ percent = (100 / clientRect.width) * (touch.clientX - clientRect.left);
+
+ // Don't allow outside bounds
+ if (percent < 0) {
+ percent = 0;
+ } else if (percent > 100) {
+ percent = 100;
+ }
+
+ // Factor in the thumb offset
+ if (percent < 50) {
+ percent -= (100 - percent * 2) * thumbWidth;
+ } else if (percent > 50) {
+ percent += (percent - 50) * 2 * thumbWidth;
+ }
+
+ // Find the closest step to the mouse position
+ return min + round(delta * (percent / 100), step);
+ }
+
+ /**
+ * Update range value based on position
+ * @param {Event} event
+ */
+ set(event) {
+ if (!RangeTouch.enabled || !is.event(event) || event.target.disabled) {
+ return;
+ }
+
+ // Prevent text highlight on iOS
+ event.preventDefault();
+
+ // Set value
+ event.target.value = this.get(event);
+
+ // Trigger event
+ trigger(event.target, event.type === 'touchend' ? 'change' : 'input');
+ }
+}
+
+// ==========================================================================
+// Type checking utils
+// ==========================================================================
+var getConstructor$1 = function getConstructor(input) {
return input !== null && typeof input !== 'undefined' ? input.constructor : null;
};
-var instanceOf = function instanceOf(input, constructor) {
+var instanceOf$1 = function instanceOf(input, constructor) {
return Boolean(input && constructor && input instanceof constructor);
};
-var isNullOrUndefined = function isNullOrUndefined(input) {
+var isNullOrUndefined$1 = function isNullOrUndefined(input) {
return input === null || typeof input === 'undefined';
};
-var isObject = function isObject(input) {
- return getConstructor(input) === Object;
+var isObject$1 = function isObject(input) {
+ return getConstructor$1(input) === Object;
};
-var isNumber = function isNumber(input) {
- return getConstructor(input) === Number && !Number.isNaN(input);
+var isNumber$1 = function isNumber(input) {
+ return getConstructor$1(input) === Number && !Number.isNaN(input);
};
-var isString = function isString(input) {
- return getConstructor(input) === String;
+var isString$1 = function isString(input) {
+ return getConstructor$1(input) === String;
};
-var isBoolean = function isBoolean(input) {
- return getConstructor(input) === Boolean;
+var isBoolean$1 = function isBoolean(input) {
+ return getConstructor$1(input) === Boolean;
};
-var isFunction = function isFunction(input) {
- return getConstructor(input) === Function;
+var isFunction$1 = function isFunction(input) {
+ return getConstructor$1(input) === Function;
};
-var isArray = function isArray(input) {
+var isArray$1 = function isArray(input) {
return Array.isArray(input);
};
var isWeakMap = function isWeakMap(input) {
- return instanceOf(input, WeakMap);
+ return instanceOf$1(input, WeakMap);
};
-var isNodeList = function isNodeList(input) {
- return instanceOf(input, NodeList);
+var isNodeList$1 = function isNodeList(input) {
+ return instanceOf$1(input, NodeList);
};
-var isElement = function isElement(input) {
- return instanceOf(input, Element);
+var isElement$1 = function isElement(input) {
+ return instanceOf$1(input, Element);
};
var isTextNode = function isTextNode(input) {
- return getConstructor(input) === Text;
+ return getConstructor$1(input) === Text;
};
-var isEvent = function isEvent(input) {
- return instanceOf(input, Event);
+var isEvent$1 = function isEvent(input) {
+ return instanceOf$1(input, Event);
};
var isKeyboardEvent = function isKeyboardEvent(input) {
- return instanceOf(input, KeyboardEvent);
+ return instanceOf$1(input, KeyboardEvent);
};
var isCue = function isCue(input) {
- return instanceOf(input, window.TextTrackCue) || instanceOf(input, window.VTTCue);
+ return instanceOf$1(input, window.TextTrackCue) || instanceOf$1(input, window.VTTCue);
};
var isTrack = function isTrack(input) {
- return instanceOf(input, TextTrack) || !isNullOrUndefined(input) && isString(input.kind);
+ return instanceOf$1(input, TextTrack) || !isNullOrUndefined$1(input) && isString$1(input.kind);
};
var isPromise = function isPromise(input) {
- return instanceOf(input, Promise);
+ return instanceOf$1(input, Promise);
};
-var isEmpty = function isEmpty(input) {
- return isNullOrUndefined(input) || (isString(input) || isArray(input) || isNodeList(input)) && !input.length || isObject(input) && !Object.keys(input).length;
+var isEmpty$1 = function isEmpty(input) {
+ return isNullOrUndefined$1(input) || (isString$1(input) || isArray$1(input) || isNodeList$1(input)) && !input.length || isObject$1(input) && !Object.keys(input).length;
};
var isUrl = function isUrl(input) {
// Accept a URL object
- if (instanceOf(input, window.URL)) {
+ if (instanceOf$1(input, window.URL)) {
return true;
} // Must be string from here
- if (!isString(input)) {
+ if (!isString$1(input)) {
return false;
} // Add the protocol if required
@@ -191,31 +465,31 @@ var isUrl = function isUrl(input) {
}
try {
- return !isEmpty(new URL(string).hostname);
+ return !isEmpty$1(new URL(string).hostname);
} catch (e) {
return false;
}
};
-var is = {
- nullOrUndefined: isNullOrUndefined,
- object: isObject,
- number: isNumber,
- string: isString,
- boolean: isBoolean,
- function: isFunction,
- array: isArray,
+var is$1 = {
+ nullOrUndefined: isNullOrUndefined$1,
+ object: isObject$1,
+ number: isNumber$1,
+ string: isString$1,
+ boolean: isBoolean$1,
+ function: isFunction$1,
+ array: isArray$1,
weakMap: isWeakMap,
- nodeList: isNodeList,
- element: isElement,
+ nodeList: isNodeList$1,
+ element: isElement$1,
textNode: isTextNode,
- event: isEvent,
+ event: isEvent$1,
keyboardEvent: isKeyboardEvent,
cue: isCue,
track: isTrack,
promise: isPromise,
url: isUrl,
- empty: isEmpty
+ empty: isEmpty$1
};
// ==========================================================================
@@ -250,7 +524,7 @@ function toggleListener(element, event, callback) {
var capture = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
// Bail if no element, event, or callback
- if (!element || !('addEventListener' in element) || is.empty(event) || !is.function(callback)) {
+ if (!element || !('addEventListener' in element) || is$1.empty(event) || !is$1.function(callback)) {
return;
} // Allow multiple events
@@ -328,7 +602,7 @@ function triggerEvent(element) {
var detail = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
// Bail if no element
- if (!is.element(element) || is.empty(type)) {
+ if (!is$1.element(element) || is$1.empty(type)) {
return;
} // Create and dispatch the event
@@ -389,7 +663,7 @@ function wrap(elements, wrapper) {
} // Set attributes
function setAttributes(element, attributes) {
- if (!is.element(element) || is.empty(attributes)) {
+ if (!is$1.element(element) || is$1.empty(attributes)) {
return;
} // Assume null and undefined attributes should be left out,
// Setting them would otherwise convert them to "null" and "undefined"
@@ -399,7 +673,7 @@ function setAttributes(element, attributes) {
var _ref2 = _slicedToArray(_ref, 2),
value = _ref2[1];
- return !is.nullOrUndefined(value);
+ return !is$1.nullOrUndefined(value);
}).forEach(function (_ref3) {
var _ref4 = _slicedToArray(_ref3, 2),
key = _ref4[0],
@@ -413,12 +687,12 @@ function createElement(type, attributes, text) {
// Create a new <element>
var element = document.createElement(type); // Set all passed attributes
- if (is.object(attributes)) {
+ if (is$1.object(attributes)) {
setAttributes(element, attributes);
} // Add text node
- if (is.string(text)) {
+ if (is$1.string(text)) {
element.innerText = text;
} // Return built element
@@ -427,7 +701,7 @@ function createElement(type, attributes, text) {
} // Inaert an element after another
function insertAfter(element, target) {
- if (!is.element(element) || !is.element(target)) {
+ if (!is$1.element(element) || !is$1.element(target)) {
return;
}
@@ -435,7 +709,7 @@ function insertAfter(element, target) {
} // Insert a DocumentFragment
function insertElement(type, parent, attributes, text) {
- if (!is.element(parent)) {
+ if (!is$1.element(parent)) {
return;
}
@@ -443,12 +717,12 @@ function insertElement(type, parent, attributes, text) {
} // Remove element(s)
function removeElement(element) {
- if (is.nodeList(element) || is.array(element)) {
+ if (is$1.nodeList(element) || is$1.array(element)) {
Array.from(element).forEach(removeElement);
return;
}
- if (!is.element(element) || !is.element(element.parentNode)) {
+ if (!is$1.element(element) || !is$1.element(element.parentNode)) {
return;
}
@@ -456,7 +730,7 @@ function removeElement(element) {
} // Remove all child elements
function emptyElement(element) {
- if (!is.element(element)) {
+ if (!is$1.element(element)) {
return;
}
@@ -469,7 +743,7 @@ function emptyElement(element) {
} // Replace element
function replaceElement(newChild, oldChild) {
- if (!is.element(oldChild) || !is.element(oldChild.parentNode) || !is.element(newChild)) {
+ if (!is$1.element(oldChild) || !is$1.element(oldChild.parentNode) || !is$1.element(newChild)) {
return null;
}
@@ -482,7 +756,7 @@ function getAttributesFromSelector(sel, existingAttributes) {
// '.test' to { class: 'test' }
// '#test' to { id: 'test' }
// '[data-test="test"]' to { 'data-test': 'test' }
- if (!is.string(sel) || is.empty(sel)) {
+ if (!is$1.string(sel) || is$1.empty(sel)) {
return {};
}
@@ -503,7 +777,7 @@ function getAttributesFromSelector(sel, existingAttributes) {
switch (start) {
case '.':
// Add to existing classname
- if (is.object(existing) && is.string(existing.class)) {
+ if (is$1.object(existing) && is$1.string(existing.class)) {
existing.class += " ".concat(className);
}
@@ -528,13 +802,13 @@ function getAttributesFromSelector(sel, existingAttributes) {
} // Toggle hidden
function toggleHidden(element, hidden) {
- if (!is.element(element)) {
+ if (!is$1.element(element)) {
return;
}
var hide = hidden;
- if (!is.boolean(hide)) {
+ if (!is$1.boolean(hide)) {
hide = !element.hidden;
}
@@ -546,13 +820,13 @@ function toggleHidden(element, hidden) {
} // Mirror Element.classList.toggle, with IE compatibility for "force" argument
function toggleClass(element, className, force) {
- if (is.nodeList(element)) {
+ if (is$1.nodeList(element)) {
return Array.from(element).map(function (e) {
return toggleClass(e, className, force);
});
}
- if (is.element(element)) {
+ if (is$1.element(element)) {
var method = 'toggle';
if (typeof force !== 'undefined') {
@@ -567,10 +841,10 @@ function toggleClass(element, className, force) {
} // Has class name
function hasClass(element, className) {
- return is.element(element) && element.classList.contains(className);
+ return is$1.element(element) && element.classList.contains(className);
} // Element matches selector
-function matches(element, selector) {
+function matches$1(element, selector) {
function match() {
return Array.from(document.querySelectorAll(selector)).includes(this);
@@ -592,7 +866,7 @@ function trapFocus() {
var element = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
var toggle = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
- if (!is.element(element)) {
+ if (!is$1.element(element)) {
return;
}
@@ -627,7 +901,7 @@ function setFocus() {
var element = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
var tabFocus = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
- if (!is.element(element)) {
+ if (!is$1.element(element)) {
return;
} // Set regular focus
@@ -653,7 +927,7 @@ var transitionEndEvent = function () {
var type = Object.keys(events).find(function (event) {
return element.style[event] !== undefined;
});
- return is.string(type) ? events[type] : false;
+ return is$1.string(type) ? events[type] : false;
}(); // Force repaint of element
function repaint(element) {
@@ -714,7 +988,7 @@ var support = {
// https://developer.apple.com/documentation/webkitjs/adding_picture_in_picture_to_your_safari_media_controls
- if (is.function(createElement('video').webkitSetPresentationMode)) {
+ if (is$1.function(createElement('video').webkitSetPresentationMode)) {
return true;
} // Chrome
// https://developers.google.com/web/updates/2018/10/watch-video-using-picture-in-picture
@@ -728,7 +1002,7 @@ var support = {
}(),
// Airplay support
// Safari only currently
- airplay: is.function(window.WebKitPlaybackTargetAvailabilityEvent),
+ airplay: is$1.function(window.WebKitPlaybackTargetAvailabilityEvent),
// Inline playback support
// https://webkit.org/blog/6784/new-video-policies-for-ios/
playsinline: 'playsInline' in document.createElement('video'),
@@ -736,7 +1010,7 @@ var support = {
// Credits: http://diveintohtml5.info/everything.html
// Related: http://www.leanbackplayer.com/test/h5mt.html
mime: function mime(input) {
- if (is.empty(input)) {
+ if (is$1.empty(input)) {
return false;
}
@@ -793,7 +1067,7 @@ var html5 = {
return sources.filter(function (source) {
var type = source.getAttribute('type');
- if (is.empty(type)) {
+ if (is$1.empty(type)) {
return true;
}
@@ -890,7 +1164,7 @@ var html5 = {
// ==========================================================================
function dedupe(array) {
- if (!is.array(array)) {
+ if (!is$1.array(array)) {
return array;
}
@@ -900,7 +1174,7 @@ function dedupe(array) {
} // Get the closest value in an array
function closest(array, value) {
- if (!is.array(array) || !array.length) {
+ if (!is$1.array(array) || !array.length) {
return null;
}
@@ -932,12 +1206,12 @@ function extend() {
var source = sources.shift();
- if (!is.object(source)) {
+ if (!is$1.object(source)) {
return target;
}
Object.keys(source).forEach(function (key) {
- if (is.object(source[key])) {
+ if (is$1.object(source[key])) {
if (!Object.keys(target).includes(key)) {
Object.assign(target, _defineProperty({}, key, {}));
}
@@ -961,7 +1235,7 @@ function format(input) {
args[_key - 1] = arguments[_key];
}
- if (is.empty(input)) {
+ if (is$1.empty(input)) {
return input;
}
@@ -1040,13 +1314,13 @@ var i18n = {
var key = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
- if (is.empty(key) || is.empty(config)) {
+ if (is$1.empty(key) || is$1.empty(config)) {
return '';
}
var string = getDeep(config.i18n, key);
- if (is.empty(string)) {
+ if (is$1.empty(string)) {
if (Object.keys(resources).includes(key)) {
return resources[key];
}
@@ -1089,12 +1363,12 @@ function () {
var store = window.localStorage.getItem(this.key);
- if (is.empty(store)) {
+ if (is$1.empty(store)) {
return null;
}
var json = JSON.parse(store);
- return is.string(key) && key.length ? json[key] : json;
+ return is$1.string(key) && key.length ? json[key] : json;
}
}, {
key: "set",
@@ -1105,14 +1379,14 @@ function () {
} // Can only store objectst
- if (!is.object(object)) {
+ if (!is$1.object(object)) {
return;
} // Get current storage
var storage = this.get(); // Default to empty object
- if (is.empty(storage)) {
+ if (is$1.empty(storage)) {
storage = {};
} // Update the working copy of the values
@@ -1185,12 +1459,12 @@ function fetch(url) {
// ==========================================================================
function loadSprite(url, id) {
- if (!is.string(url)) {
+ if (!is$1.string(url)) {
return;
}
var prefix = 'cache';
- var hasId = is.string(id);
+ var hasId = is$1.string(id);
var isCached = false;
var exists = function exists() {
@@ -1232,7 +1506,7 @@ function loadSprite(url, id) {
fetch(url).then(function (result) {
- if (is.empty(result)) {
+ if (is$1.empty(result)) {
return;
}
@@ -1265,7 +1539,7 @@ function formatTime() {
var inverted = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
// Bail if the value isn't a number
- if (!is.number(time)) {
+ if (!is$1.number(time)) {
return formatTime(null, displayHours, inverted);
} // Format time component to add leading zero
@@ -1331,7 +1605,7 @@ var controls = {
duration: getElement.call(this, this.config.selectors.display.duration)
}; // Seek tooltip
- if (is.element(this.elements.progress)) {
+ if (is$1.element(this.elements.progress)) {
this.elements.display.seekTooltip = this.elements.progress.querySelector(".".concat(this.config.classNames.tooltip));
}
@@ -1382,7 +1656,7 @@ var controls = {
},
// Create a badge
createBadge: function createBadge(text) {
- if (is.empty(text)) {
+ if (is$1.empty(text)) {
return null;
}
@@ -1468,11 +1742,11 @@ var controls = {
break;
default:
- if (is.empty(props.label)) {
+ if (is$1.empty(props.label)) {
props.label = type;
}
- if (is.empty(props.icon)) {
+ if (is$1.empty(props.icon)) {
props.icon = buttonType;
}
@@ -1505,7 +1779,7 @@ var controls = {
setAttributes(button, attributes); // We have multiple play buttons
if (type === 'play') {
- if (!is.array(this.elements.buttons[type])) {
+ if (!is$1.array(this.elements.buttons[type])) {
this.elements.buttons[type] = [];
}
@@ -1535,7 +1809,9 @@ var controls = {
}, attributes));
this.elements.inputs[type] = input; // Set the fill for webkit now
- controls.updateRangeFill.call(this, input);
+ controls.updateRangeFill.call(this, input); // Improve support on touch devices
+
+ RangeTouch.setup(input);
return input;
},
// Create a <progress>
@@ -1593,7 +1869,7 @@ var controls = {
return;
}
- var isRadioButton = matches(menuItem, '[role="menuitemradio"]'); // Show the respective menu
+ var isRadioButton = matches$1(menuItem, '[role="menuitemradio"]'); // Show the respective menu
if (!isRadioButton && [32, 39].includes(event.which)) {
controls.showMenuPanel.call(_this, type, true);
@@ -1604,13 +1880,13 @@ var controls = {
if (event.which === 40 || isRadioButton && event.which === 39) {
target = menuItem.nextElementSibling;
- if (!is.element(target)) {
+ if (!is$1.element(target)) {
target = menuItem.parentNode.firstElementChild;
}
} else {
target = menuItem.previousElementSibling;
- if (!is.element(target)) {
+ if (!is$1.element(target)) {
target = menuItem.parentNode.lastElementChild;
}
}
@@ -1653,7 +1929,7 @@ var controls = {
flex.innerHTML = title;
- if (is.element(badge)) {
+ if (is$1.element(badge)) {
flex.appendChild(badge);
}
@@ -1668,7 +1944,7 @@ var controls = {
// Ensure exclusivity
if (checked) {
Array.from(menuItem.parentNode.children).filter(function (node) {
- return matches(node, '[role="menuitemradio"]');
+ return matches$1(node, '[role="menuitemradio"]');
}).forEach(function (node) {
return node.setAttribute('aria-checked', 'false');
});
@@ -1678,7 +1954,7 @@ var controls = {
}
});
this.listeners.bind(menuItem, 'click keyup', function (event) {
- if (is.keyboardEvent(event) && event.which !== 32) {
+ if (is$1.keyboardEvent(event) && event.which !== 32) {
return;
}
@@ -1703,7 +1979,7 @@ var controls = {
break;
}
- controls.showMenuPanel.call(_this2, 'home', is.keyboardEvent(event));
+ controls.showMenuPanel.call(_this2, 'home', is$1.keyboardEvent(event));
}, type, false);
controls.bindMenuItemShortcuts.call(this, menuItem, type);
list.appendChild(menuItem);
@@ -1714,7 +1990,7 @@ var controls = {
var inverted = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
// Bail if the value isn't a number
- if (!is.number(time)) {
+ if (!is$1.number(time)) {
return time;
} // Always display hours if duration is over an hour
@@ -1729,7 +2005,7 @@ var controls = {
var inverted = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
// Bail if there's no element to display or the value isn't a number
- if (!is.element(target) || !is.number(time)) {
+ if (!is$1.element(target) || !is$1.number(time)) {
return;
} // eslint-disable-next-line no-param-reassign
@@ -1743,12 +2019,12 @@ var controls = {
} // Update range
- if (is.element(this.elements.inputs.volume)) {
+ if (is$1.element(this.elements.inputs.volume)) {
controls.setRange.call(this, this.elements.inputs.volume, this.muted ? 0 : this.volume);
} // Update mute state
- if (is.element(this.elements.buttons.mute)) {
+ if (is$1.element(this.elements.buttons.mute)) {
this.elements.buttons.mute.pressed = this.muted || this.volume === 0;
}
},
@@ -1756,7 +2032,7 @@ var controls = {
setRange: function setRange(target) {
var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
- if (!is.element(target)) {
+ if (!is$1.element(target)) {
return;
} // eslint-disable-next-line
@@ -1769,22 +2045,22 @@ var controls = {
updateProgress: function updateProgress(event) {
var _this3 = this;
- if (!this.supported.ui || !is.event(event)) {
+ if (!this.supported.ui || !is$1.event(event)) {
return;
}
var value = 0;
var setProgress = function setProgress(target, input) {
- var value = is.number(input) ? input : 0;
- var progress = is.element(target) ? target : _this3.elements.display.buffer; // Update value and label
+ var value = is$1.number(input) ? input : 0;
+ var progress = is$1.element(target) ? target : _this3.elements.display.buffer; // Update value and label
- if (is.element(progress)) {
+ if (is$1.element(progress)) {
progress.value = value; // Update text label inside
var label = progress.getElementsByTagName('span')[0];
- if (is.element(label)) {
+ if (is$1.element(label)) {
label.childNodes[0].nodeValue = value;
}
}
@@ -1818,20 +2094,20 @@ var controls = {
// Webkit polyfill for lower fill range
updateRangeFill: function updateRangeFill(target) {
// Get range from event if event passed
- var range = is.event(target) ? target.target : target; // Needs to be a valid <input type='range'>
+ var range = is$1.event(target) ? target.target : target; // Needs to be a valid <input type='range'>
- if (!is.element(range) || range.getAttribute('type') !== 'range') {
+ if (!is$1.element(range) || range.getAttribute('type') !== 'range') {
return;
} // Set aria values for https://github.com/sampotts/plyr/issues/905
- if (matches(range, this.config.selectors.inputs.seek)) {
+ if (matches$1(range, this.config.selectors.inputs.seek)) {
range.setAttribute('aria-valuenow', this.currentTime);
var currentTime = controls.formatTime(this.currentTime);
var duration = controls.formatTime(this.duration);
var format$$1 = i18n.get('seekLabel', this.config);
range.setAttribute('aria-valuetext', format$$1.replace('{currentTime}', currentTime).replace('{duration}', duration));
- } else if (matches(range, this.config.selectors.inputs.volume)) {
+ } else if (matches$1(range, this.config.selectors.inputs.volume)) {
var percent = range.value * 100;
range.setAttribute('aria-valuenow', percent);
range.setAttribute('aria-valuetext', "".concat(percent.toFixed(1), "%"));
@@ -1852,7 +2128,7 @@ var controls = {
var _this4 = this;
// Bail if setting not true
- if (!this.config.tooltips.seek || !is.element(this.elements.inputs.seek) || !is.element(this.elements.display.seekTooltip) || this.duration === 0) {
+ if (!this.config.tooltips.seek || !is$1.element(this.elements.inputs.seek) || !is$1.element(this.elements.display.seekTooltip) || this.duration === 0) {
return;
} // Calculate percentage
@@ -1872,7 +2148,7 @@ var controls = {
} // Determine percentage, if already visible
- if (is.event(event)) {
+ if (is$1.event(event)) {
percent = 100 / clientRect.width * (event.pageX - clientRect.left);
} else if (hasClass(this.elements.display.seekTooltip, visible)) {
percent = parseFloat(this.elements.display.seekTooltip.style.left, 10);
@@ -1893,14 +2169,14 @@ var controls = {
this.elements.display.seekTooltip.style.left = "".concat(percent, "%"); // Show/hide the tooltip
// If the event is a moues in/out and percentage is inside bounds
- if (is.event(event) && ['mouseenter', 'mouseleave'].includes(event.type)) {
+ if (is$1.event(event) && ['mouseenter', 'mouseleave'].includes(event.type)) {
toggle(event.type === 'mouseenter');
}
},
// Handle time change event
timeUpdate: function timeUpdate(event) {
// Only invert if only one time element is displayed and used for both duration and currentTime
- var invert = !is.element(this.elements.display.duration) && this.config.invertTime; // Duration
+ var invert = !is$1.element(this.elements.display.duration) && this.config.invertTime; // Duration
controls.updateTimeDisplay.call(this, this.elements.display.currentTime, invert ? this.duration - this.currentTime : this.currentTime, invert); // Ignore updates while seeking
@@ -1929,12 +2205,12 @@ var controls = {
} // Update ARIA values
- if (is.element(this.elements.inputs.seek)) {
+ if (is$1.element(this.elements.inputs.seek)) {
this.elements.inputs.seek.setAttribute('aria-valuemax', this.duration);
} // If there's a spot to display duration
- var hasDuration = is.element(this.elements.display.duration); // If there's only one time display, display duration there
+ var hasDuration = is$1.element(this.elements.display.duration); // If there's only one time display, display duration there
if (!hasDuration && this.config.displayDuration && this.paused) {
controls.updateTimeDisplay.call(this, this.elements.display.currentTime, this.duration);
@@ -1961,14 +2237,14 @@ var controls = {
if (setting === 'captions') {
value = this.currentTrack;
} else {
- value = !is.empty(input) ? input : this[setting]; // Get default
+ value = !is$1.empty(input) ? input : this[setting]; // Get default
- if (is.empty(value)) {
+ if (is$1.empty(value)) {
value = this.config[setting].default;
} // Unsupported value
- if (!is.empty(this.options[setting]) && !this.options[setting].includes(value)) {
+ if (!is$1.empty(this.options[setting]) && !this.options[setting].includes(value)) {
this.debug.warn("Unsupported value of '".concat(value, "' for ").concat(setting));
return;
} // Disabled value
@@ -1981,12 +2257,12 @@ var controls = {
} // Get the list if we need to
- if (!is.element(list)) {
+ if (!is$1.element(list)) {
list = pane && pane.querySelector('[role="menu"]');
} // If there's no list it means it's not been rendered...
- if (!is.element(list)) {
+ if (!is$1.element(list)) {
return;
} // Update the label
@@ -1996,7 +2272,7 @@ var controls = {
var target = list && list.querySelector("[value=\"".concat(value, "\"]"));
- if (is.element(target)) {
+ if (is$1.element(target)) {
target.checked = true;
}
},
@@ -2007,7 +2283,7 @@ var controls = {
return value === 1 ? i18n.get('normal', this.config) : "".concat(value, "&times;");
case 'quality':
- if (is.number(value)) {
+ if (is$1.number(value)) {
var label = i18n.get("qualityLabel.".concat(value), this.config);
if (!label.length) {
@@ -2031,21 +2307,21 @@ var controls = {
var _this5 = this;
// Menu required
- if (!is.element(this.elements.settings.panels.quality)) {
+ if (!is$1.element(this.elements.settings.panels.quality)) {
return;
}
var type = 'quality';
var list = this.elements.settings.panels.quality.querySelector('[role="menu"]'); // Set options if passed and filter based on uniqueness and config
- if (is.array(options)) {
+ if (is$1.array(options)) {
this.options.quality = dedupe(options).filter(function (quality) {
return _this5.config.quality.options.includes(quality);
});
} // Toggle the pane and tab
- var toggle = !is.empty(this.options.quality) && this.options.quality.length > 1;
+ var toggle = !is$1.empty(this.options.quality) && this.options.quality.length > 1;
controls.toggleMenuButton.call(this, type, toggle); // Empty the menu
emptyElement(list); // Check if we need to toggle the parent
@@ -2125,7 +2401,7 @@ var controls = {
var _this6 = this;
// Menu required
- if (!is.element(this.elements.settings.panels.captions)) {
+ if (!is$1.element(this.elements.settings.panels.captions)) {
return;
} // TODO: Captions or language? Currently it's mixed
@@ -2173,14 +2449,14 @@ var controls = {
var _this7 = this;
// Menu required
- if (!is.element(this.elements.settings.panels.speed)) {
+ if (!is$1.element(this.elements.settings.panels.speed)) {
return;
}
var type = 'speed';
var list = this.elements.settings.panels.speed.querySelector('[role="menu"]'); // Set the speed options
- if (is.array(options)) {
+ if (is$1.array(options)) {
this.options.speed = options;
} else if (this.isHTML5 || this.isVimeo) {
this.options.speed = [0.5, 0.75, 1, 1.25, 1.5, 1.75, 2];
@@ -2191,7 +2467,7 @@ var controls = {
return _this7.config.speed.options.includes(speed);
}); // Toggle the pane and tab
- var toggle = !is.empty(this.options.speed) && this.options.speed.length > 1;
+ var toggle = !is$1.empty(this.options.speed) && this.options.speed.length > 1;
controls.toggleMenuButton.call(this, type, toggle); // Empty the menu
emptyElement(list); // Check if we need to toggle the parent
@@ -2216,7 +2492,7 @@ var controls = {
// Check if we need to hide/show the settings menu
checkMenu: function checkMenu() {
var buttons = this.elements.settings.buttons;
- var visible = !is.empty(buttons) && Object.values(buttons).some(function (button) {
+ var visible = !is$1.empty(buttons) && Object.values(buttons).some(function (button) {
return !button.hidden;
});
toggleHidden(this.elements.settings.menu, !visible);
@@ -2231,7 +2507,7 @@ var controls = {
var target = pane;
- if (!is.element(target)) {
+ if (!is$1.element(target)) {
target = Object.values(this.elements.settings.panels).find(function (pane) {
return !pane.hidden;
});
@@ -2245,7 +2521,7 @@ var controls = {
var popup = this.elements.settings.popup;
var button = this.elements.buttons.settings; // Menu and button are required
- if (!is.element(popup) || !is.element(button)) {
+ if (!is$1.element(popup) || !is$1.element(button)) {
return;
} // True toggle by default
@@ -2253,11 +2529,11 @@ var controls = {
var hidden = popup.hidden;
var show = hidden;
- if (is.boolean(input)) {
+ if (is$1.boolean(input)) {
show = input;
- } else if (is.keyboardEvent(input) && input.which === 27) {
+ } else if (is$1.keyboardEvent(input) && input.which === 27) {
show = false;
- } else if (is.event(input)) {
+ } else if (is$1.event(input)) {
var isMenuItem = popup.contains(input.target); // If the click was inside the menu or if the click
// wasn't the button or menu item and we're trying to
// show the menu (a doc click shouldn't show the menu)
@@ -2274,11 +2550,11 @@ var controls = {
toggleClass(this.elements.container, this.config.classNames.menu.open, show); // Focus the first item if key interaction
- if (show && is.keyboardEvent(input)) {
+ if (show && is$1.keyboardEvent(input)) {
controls.focusFirstMenuItem.call(this, null, true);
} else if (!show && !hidden) {
// If closing, re-focus the button
- setFocus.call(this, button, is.keyboardEvent(input));
+ setFocus.call(this, button, is$1.keyboardEvent(input));
}
},
// Get the natural size of a menu panel
@@ -2307,7 +2583,7 @@ var controls = {
var tabFocus = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var target = document.getElementById("plyr-settings-".concat(this.id, "-").concat(type)); // Nothing to show, bail
- if (!is.element(target)) {
+ if (!is$1.element(target)) {
return;
} // Hide all other panels
@@ -2355,7 +2631,7 @@ var controls = {
setDownloadLink: function setDownloadLink() {
var button = this.elements.buttons.download; // Bail if no button
- if (!is.element(button)) {
+ if (!is$1.element(button)) {
return;
} // Set download link
@@ -2456,7 +2732,7 @@ var controls = {
} // Settings button / menu
- if (this.config.controls.includes('settings') && !is.empty(this.config.settings)) {
+ if (this.config.controls.includes('settings') && !is$1.empty(this.config.settings)) {
var control = createElement('div', {
class: 'plyr__menu',
hidden: ''
@@ -2578,7 +2854,7 @@ var controls = {
};
var download = this.config.urls.download;
- if (!is.url(download) && this.isEmbed) {
+ if (!is$1.url(download) && this.isEmbed) {
extend(_attributes, {
icon: "logo-".concat(this.provider),
label: this.provider
@@ -2633,7 +2909,7 @@ var controls = {
};
var update = true; // If function, run it and use output
- if (is.function(this.config.controls)) {
+ if (is$1.function(this.config.controls)) {
this.config.controls = this.config.controls.call(this, props);
} // Convert falsy controls to empty array (primarily for empty strings)
@@ -2642,7 +2918,7 @@ var controls = {
this.config.controls = [];
}
- if (is.element(this.config.controls) || is.string(this.config.controls)) {
+ if (is$1.element(this.config.controls) || is$1.string(this.config.controls)) {
// HTMLElement or Non-empty string passed as the option
container = this.config.controls;
} else {
@@ -2674,9 +2950,9 @@ var controls = {
if (update) {
- if (is.string(this.config.controls)) {
+ if (is$1.string(this.config.controls)) {
container = replace(container);
- } else if (is.element(container)) {
+ } else if (is$1.element(container)) {
container.innerHTML = replace(container.innerHTML);
}
} // Controls container
@@ -2684,25 +2960,25 @@ var controls = {
var target; // Inject to custom location
- if (is.string(this.config.selectors.controls.container)) {
+ if (is$1.string(this.config.selectors.controls.container)) {
target = document.querySelector(this.config.selectors.controls.container);
} // Inject into the container by default
- if (!is.element(target)) {
+ if (!is$1.element(target)) {
target = this.elements.container;
} // Inject controls HTML (needs to be before captions, hence "afterbegin")
- var insertMethod = is.element(container) ? 'insertAdjacentElement' : 'insertAdjacentHTML';
+ var insertMethod = is$1.element(container) ? 'insertAdjacentElement' : 'insertAdjacentHTML';
target[insertMethod]('afterbegin', container); // Find the elements if need be
- if (!is.element(this.elements.controls)) {
+ if (!is$1.element(this.elements.controls)) {
controls.findElements.call(this);
} // Add pressed property to buttons
- if (!is.empty(this.elements.buttons)) {
+ if (!is$1.empty(this.elements.buttons)) {
var addProperty = function addProperty(button) {
var className = _this10.config.classNames.controlPressed;
Object.defineProperty(button, 'pressed', {
@@ -2719,7 +2995,7 @@ var controls = {
Object.values(this.elements.buttons).filter(Boolean).forEach(function (button) {
- if (is.array(button) || is.nodeList(button)) {
+ if (is$1.array(button) || is$1.nodeList(button)) {
Array.from(button).filter(Boolean).forEach(addProperty);
} else {
addProperty(button);
@@ -2773,7 +3049,7 @@ function parseUrl(input) {
function buildUrlParams(input) {
var params = new URLSearchParams();
- if (is.object(input)) {
+ if (is$1.object(input)) {
Object.entries(input).forEach(function (_ref) {
var _ref2 = _slicedToArray(_ref, 2),
key = _ref2[0],
@@ -2797,7 +3073,7 @@ var captions = {
if (!this.isVideo || this.isYouTube || this.isHTML5 && !support.textTracks) {
// Clear menu and hide
- if (is.array(this.config.controls) && this.config.controls.includes('settings') && this.config.settings.includes('captions')) {
+ if (is$1.array(this.config.controls) && this.config.controls.includes('settings') && this.config.settings.includes('captions')) {
controls.setCaptionsMenu.call(this);
}
@@ -2805,7 +3081,7 @@ var captions = {
} // Inject the container
- if (!is.element(this.elements.captions)) {
+ if (!is$1.element(this.elements.captions)) {
this.elements.captions = createElement('div', getAttributesFromSelector(this.config.selectors.captions));
insertAfter(this.elements.captions, this.elements.wrapper);
} // Fix IE captions if CORS is used
@@ -2848,7 +3124,7 @@ var captions = {
var active = this.storage.get('captions');
- if (!is.boolean(active)) {
+ if (!is$1.boolean(active)) {
active = this.config.captions.active;
}
@@ -2908,7 +3184,7 @@ var captions = {
} // Enable or disable captions based on track length
- toggleClass(this.elements.container, this.config.classNames.captions.enabled, !is.empty(tracks)); // Update available languages in list
+ toggleClass(this.elements.container, this.config.classNames.captions.enabled, !is$1.empty(tracks)); // Update available languages in list
if ((this.config.controls || []).includes('settings') && this.config.settings.includes('captions')) {
controls.setCaptionsMenu.call(this);
@@ -2929,7 +3205,7 @@ var captions = {
var activeClass = this.config.classNames.captions.active; // Get the next state
// If the method is called without parameter, toggle based on current value
- var active = is.nullOrUndefined(input) ? !toggled : input; // Update state and trigger event
+ var active = is$1.nullOrUndefined(input) ? !toggled : input; // Update state and trigger event
if (active !== toggled) {
// When passive, don't override user preferences
@@ -2976,7 +3252,7 @@ var captions = {
return;
}
- if (!is.number(index)) {
+ if (!is$1.number(index)) {
this.debug.warn('Invalid caption argument', index);
return;
}
@@ -3027,7 +3303,7 @@ var captions = {
setLanguage: function setLanguage(input) {
var passive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
- if (!is.string(input)) {
+ if (!is$1.string(input)) {
this.debug.warn('Invalid language argument', input);
return;
} // Normalize
@@ -3089,16 +3365,16 @@ var captions = {
getLabel: function getLabel(track) {
var currentTrack = track;
- if (!is.track(currentTrack) && support.textTracks && this.captions.toggled) {
+ if (!is$1.track(currentTrack) && support.textTracks && this.captions.toggled) {
currentTrack = captions.getCurrentTrack.call(this);
}
- if (is.track(currentTrack)) {
- if (!is.empty(currentTrack.label)) {
+ if (is$1.track(currentTrack)) {
+ if (!is$1.empty(currentTrack.label)) {
return currentTrack.label;
}
- if (!is.empty(currentTrack.language)) {
+ if (!is$1.empty(currentTrack.language)) {
return track.language.toUpperCase();
}
@@ -3115,13 +3391,13 @@ var captions = {
return;
}
- if (!is.element(this.elements.captions)) {
+ if (!is$1.element(this.elements.captions)) {
this.debug.warn('No captions element to render to');
return;
} // Only accept array or empty input
- if (!is.nullOrUndefined(input) && !Array.isArray(input)) {
+ if (!is$1.nullOrUndefined(input) && !Array.isArray(input)) {
this.debug.warn('updateCues: Invalid input', input);
return;
}
@@ -3156,7 +3432,7 @@ var captions = {
// ==========================================================================
// Plyr default config
// ==========================================================================
-var defaults = {
+var defaults$1 = {
// Disable
enabled: true,
// Custom media title
@@ -3588,7 +3864,7 @@ function onChange() {
var button = this.player.elements.buttons.fullscreen;
- if (is.element(button)) {
+ if (is$1.element(button)) {
button.pressed = this.active;
} // Trigger an event
@@ -3630,7 +3906,7 @@ function toggleFallback() {
} // Check if the property already exists
- var hasProperty = is.string(viewport.content) && viewport.content.includes(property);
+ var hasProperty = is$1.string(viewport.content) && viewport.content.includes(property);
if (toggle) {
this.cleanupViewport = !hasProperty;
@@ -3683,7 +3959,7 @@ function () {
on.call(this.player, this.player.elements.container, 'dblclick', function (event) {
// Ignore double click in controls
- if (is.element(_this2.player.elements.controls) && _this2.player.elements.controls.contains(event.target)) {
+ if (is$1.element(_this2.player.elements.controls) && _this2.player.elements.controls.contains(event.target)) {
return;
}
@@ -3732,7 +4008,7 @@ function () {
toggleFallback.call(this, true);
} else if (!this.prefix) {
this.target.requestFullscreen();
- } else if (!is.empty(this.prefix)) {
+ } else if (!is$1.empty(this.prefix)) {
this.target["".concat(this.prefix, "Request").concat(this.property)]();
}
} // Bail from fullscreen
@@ -3752,7 +4028,7 @@ function () {
toggleFallback.call(this, false);
} else if (!this.prefix) {
(document.cancelFullScreen || document.exitFullscreen).call(document);
- } else if (!is.empty(this.prefix)) {
+ } else if (!is$1.empty(this.prefix)) {
var action = this.prefix === 'moz' ? 'Cancel' : 'Exit';
document["".concat(this.prefix).concat(action).concat(this.property)]();
}
@@ -3811,7 +4087,7 @@ function () {
key: "prefix",
get: function get() {
// No prefix
- if (is.function(document.exitFullscreen)) {
+ if (is$1.function(document.exitFullscreen)) {
return '';
} // Check for fullscreen support by vendor prefix
@@ -3819,7 +4095,7 @@ function () {
var value = '';
var prefixes = ['webkit', 'moz', 'ms'];
prefixes.some(function (pre) {
- if (is.function(document["".concat(pre, "ExitFullscreen")]) || is.function(document["".concat(pre, "CancelFullScreen")])) {
+ if (is$1.function(document["".concat(pre, "ExitFullscreen")]) || is$1.function(document["".concat(pre, "CancelFullScreen")])) {
value = pre;
return true;
}
@@ -3895,7 +4171,7 @@ var ui = {
} // Inject custom controls if not present
- if (!is.element(this.elements.controls)) {
+ if (!is$1.element(this.elements.controls)) {
// Inject custom controls
controls.inject.call(this); // Re-attach control listeners
@@ -3957,7 +4233,7 @@ var ui = {
// Find the current text
var label = i18n.get('play', this.config); // If there's a media title set, use that for the label
- if (is.string(this.config.title) && !is.empty(this.config.title)) {
+ if (is$1.string(this.config.title) && !is$1.empty(this.config.title)) {
label += ", ".concat(this.config.title);
} // If there's a play button, set label
@@ -3970,12 +4246,12 @@ var ui = {
if (this.isEmbed) {
var iframe = getElement.call(this, 'iframe');
- if (!is.element(iframe)) {
+ if (!is$1.element(iframe)) {
return;
} // Default to media type
- var title = !is.empty(this.config.title) ? this.config.title : 'video';
+ var title = !is$1.empty(this.config.title) ? this.config.title : 'video';
var format = i18n.get('frameTitle', this.config);
iframe.setAttribute('title', format.replace('{title}', title));
}
@@ -4038,7 +4314,7 @@ var ui = {
target.pressed = _this3.playing;
}); // Only update controls on non timeupdate events
- if (is.event(event) && event.type === 'timeupdate') {
+ if (is$1.event(event) && event.type === 'timeupdate') {
return;
} // Toggle controls
@@ -4083,11 +4359,11 @@ var ui = {
function setAspectRatio(input) {
var ratio = input;
- if (!is.string(ratio) && !is.nullOrUndefined(this.embed)) {
+ if (!is$1.string(ratio) && !is$1.nullOrUndefined(this.embed)) {
ratio = this.embed.ratio;
}
- if (!is.string(ratio)) {
+ if (!is$1.string(ratio)) {
ratio = this.config.ratio;
}
@@ -4143,7 +4419,7 @@ function () {
// Firefox doesn't get the keycode for whatever reason
- if (!is.number(code)) {
+ if (!is$1.number(code)) {
return;
} // Seek by the number keys
@@ -4161,15 +4437,15 @@ function () {
// and any that accept key input http://webaim.org/techniques/keyboard/
var focused = document.activeElement;
- if (is.element(focused)) {
+ if (is$1.element(focused)) {
var editable = player.config.selectors.editable;
var seek = elements.inputs.seek;
- if (focused !== seek && matches(focused, editable)) {
+ if (focused !== seek && matches$1(focused, editable)) {
return;
}
- if (event.which === 32 && matches(focused, 'button, [role^="menuitem"]')) {
+ if (event.which === 32 && matches$1(focused, 'button, [role^="menuitem"]')) {
return;
}
} // Which keycodes should we prevent default
@@ -4523,7 +4799,7 @@ 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.element(wrapper)) {
+ if (!is$1.element(wrapper)) {
return;
} // On click play, pause or restart
@@ -4604,7 +4880,7 @@ function () {
value: function proxy(event, defaultHandler, customHandlerKey) {
var player = this.player;
var customHandler = player.config.listeners[customHandlerKey];
- var hasCustomHandler = is.function(customHandler);
+ var hasCustomHandler = is$1.function(customHandler);
var returned = true; // Execute custom handler
if (hasCustomHandler) {
@@ -4612,7 +4888,7 @@ function () {
} // Only call default handler if not prevented in custom handler
- if (returned && is.function(defaultHandler)) {
+ if (returned && is$1.function(defaultHandler)) {
defaultHandler.call(player, event);
}
} // Trigger custom and default handlers
@@ -4625,7 +4901,7 @@ 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.function(customHandler);
+ var hasCustomHandler = is$1.function(customHandler);
on.call(player, element, type, function (event) {
return _this2.proxy(event, defaultHandler, customHandlerKey);
}, passive && !hasCustomHandler);
@@ -4725,7 +5001,7 @@ function () {
var code = event.keyCode ? event.keyCode : event.which;
var attribute = 'play-on-seeked';
- if (is.keyboardEvent(event) && code !== 39 && code !== 37) {
+ if (is$1.keyboardEvent(event) && code !== 39 && code !== 37) {
return;
} // Record seek time so we can prevent hiding controls for a few seconds after seek
@@ -4762,7 +5038,7 @@ function () {
var seekTo = seek.getAttribute('seek-value');
- if (is.empty(seekTo)) {
+ if (is$1.empty(seekTo)) {
seekTo = seek.value;
}
@@ -4816,7 +5092,7 @@ function () {
// Only if one time element is used for both currentTime and duration
- if (player.config.toggleInvert && !is.element(elements.display.duration)) {
+ if (player.config.toggleInvert && !is$1.element(elements.display.duration)) {
this.bind(elements.display.currentTime, 'click', function () {
// Do nothing if we're at the start
if (player.currentTime === 0) {
@@ -5202,11 +5478,11 @@ function loadScript(url) {
}
function parseId(url) {
- if (is.empty(url)) {
+ if (is$1.empty(url)) {
return null;
}
- if (is.number(Number(url))) {
+ if (is$1.number(Number(url))) {
return url;
}
@@ -5235,7 +5511,7 @@ var vimeo = {
setAspectRatio.call(this); // Load the API if not already
- if (!is.object(window.Vimeo)) {
+ if (!is$1.object(window.Vimeo)) {
loadScript(this.config.urls.vimeo.sdk).then(function () {
vimeo.ready.call(_this);
}).catch(function (error) {
@@ -5262,7 +5538,7 @@ var vimeo = {
var source = player.media.getAttribute('src'); // Get from <div> if needed
- if (is.empty(source)) {
+ if (is$1.empty(source)) {
source = player.media.getAttribute(player.config.attributes.embed.id);
}
@@ -5285,7 +5561,7 @@ var vimeo = {
player.media = replaceElement(wrapper, player.media); // Get poster image
fetch(format(player.config.urls.vimeo.api, id), 'json').then(function (response) {
- if (is.empty(response)) {
+ if (is$1.empty(response)) {
return;
} // Get the URL for thumbnail
@@ -5394,7 +5670,7 @@ var vimeo = {
return muted;
},
set: function set(input) {
- var toggle = is.boolean(input) ? input : false;
+ var toggle = is$1.boolean(input) ? input : false;
player.embed.setVolume(toggle ? 0 : player.config.volume).then(function () {
muted = toggle;
triggerEvent.call(player, player.media, 'volumechange');
@@ -5408,7 +5684,7 @@ var vimeo = {
return loop;
},
set: function set(input) {
- var toggle = is.boolean(input) ? input : player.config.loop.active;
+ var toggle = is$1.boolean(input) ? input : player.config.loop.active;
player.embed.setLoop(toggle).then(function () {
loop = toggle;
});
@@ -5484,7 +5760,7 @@ var vimeo = {
}
});
- if (is.element(player.embed.element) && player.supported.ui) {
+ if (is$1.element(player.embed.element) && player.supported.ui) {
var frame = player.embed.element; // Fix keyboard focus issues
// https://github.com/sampotts/plyr/issues/317
@@ -5542,7 +5818,7 @@ var vimeo = {
// ==========================================================================
function parseId$1(url) {
- if (is.empty(url)) {
+ if (is$1.empty(url)) {
return null;
}
@@ -5571,7 +5847,7 @@ var youtube = {
setAspectRatio.call(this); // Setup API
- if (is.object(window.YT) && is.function(window.YT.Player)) {
+ if (is$1.object(window.YT) && is$1.function(window.YT.Player)) {
youtube.ready.call(this);
} else {
// Load the API
@@ -5600,11 +5876,11 @@ var youtube = {
// Try via undocumented API method first
// This method disappears now and then though...
// https://github.com/sampotts/plyr/issues/709
- if (is.function(this.embed.getVideoData)) {
+ if (is$1.function(this.embed.getVideoData)) {
var _this$embed$getVideoD = this.embed.getVideoData(),
title = _this$embed$getVideoD.title;
- if (is.empty(title)) {
+ if (is$1.empty(title)) {
this.config.title = title;
ui.setTitle.call(this);
return;
@@ -5614,10 +5890,10 @@ var youtube = {
var key = this.config.keys.google;
- if (is.string(key) && !is.empty(key)) {
+ 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.object(result)) {
+ if (is$1.object(result)) {
_this2.config.title = result.items[0].snippet.title;
ui.setTitle.call(_this2);
}
@@ -5630,14 +5906,14 @@ var youtube = {
var currentId = player.media.getAttribute('id');
- if (!is.empty(currentId) && currentId.startsWith('youtube-')) {
+ if (!is$1.empty(currentId) && currentId.startsWith('youtube-')) {
return;
} // Get the source URL or ID
var source = player.media.getAttribute('src'); // Get from <div> if needed
- if (is.empty(source)) {
+ if (is$1.empty(source)) {
source = player.media.getAttribute(this.config.attributes.embed.id);
} // Replace the <iframe> with a <div> due to YouTube API issues
@@ -5725,7 +6001,7 @@ var youtube = {
},
onReady: function onReady(event) {
// Bail if onReady has already been called. See issue #1108
- if (is.function(player.media.play)) {
+ if (is$1.function(player.media.play)) {
return;
} // Get the instance
@@ -5797,7 +6073,7 @@ var youtube = {
return muted;
},
set: function set(input) {
- var toggle = is.boolean(input) ? input : muted;
+ var toggle = is$1.boolean(input) ? input : muted;
muted = toggle;
instance[toggle ? 'mute' : 'unMute']();
triggerEvent.call(player, player.media, 'volumechange');
@@ -6029,7 +6305,7 @@ function () {
if (this.enabled) {
// Check if the Google IMA3 SDK is loaded or load it ourselves
- if (!is.object(window.google) || !is.object(window.google.ima)) {
+ if (!is$1.object(window.google) || !is$1.object(window.google.ima)) {
loadScript(this.player.config.urls.googleIMA.sdk).then(function () {
_this2.ready();
}).catch(function () {
@@ -6204,12 +6480,12 @@ function () {
var _this7 = this;
// Add advertisement cue's within the time line if available
- if (!is.empty(this.cuePoints)) {
+ if (!is$1.empty(this.cuePoints)) {
this.cuePoints.forEach(function (cuePoint) {
if (cuePoint !== 0 && cuePoint !== -1 && cuePoint < _this7.player.duration) {
var seekElement = _this7.player.elements.progress;
- if (is.element(seekElement)) {
+ if (is$1.element(seekElement)) {
var cuePercentage = 100 / _this7.player.duration * cuePoint;
var cue = createElement('span', {
class: _this7.player.config.classNames.cues
@@ -6366,7 +6642,7 @@ function () {
this.player.on('seeked', function () {
var seekedTime = _this9.player.currentTime;
- if (is.empty(_this9.cuePoints)) {
+ if (is$1.empty(_this9.cuePoints)) {
return;
}
@@ -6514,9 +6790,9 @@ function () {
var handlers = this.events[event];
- if (is.array(handlers)) {
+ if (is$1.array(handlers)) {
handlers.forEach(function (handler) {
- if (is.function(handler)) {
+ if (is$1.function(handler)) {
handler.apply(_this12, args);
}
});
@@ -6532,7 +6808,7 @@ function () {
}, {
key: "on",
value: function on$$1(event, callback) {
- if (!is.array(this.events[event])) {
+ if (!is$1.array(this.events[event])) {
this.events[event] = [];
}
@@ -6568,7 +6844,7 @@ function () {
}, {
key: "clearSafetyTimer",
value: function clearSafetyTimer(from) {
- if (!is.nullOrUndefined(this.safetyTimer)) {
+ if (!is$1.nullOrUndefined(this.safetyTimer)) {
this.player.debug.log("Safety timer cleared from: ".concat(from));
clearTimeout(this.safetyTimer);
this.safetyTimer = null;
@@ -6578,14 +6854,14 @@ function () {
key: "enabled",
get: function get() {
var config = this.config;
- return this.player.isHTML5 && this.player.isVideo && config.enabled && (!is.empty(config.publisherId) || is.url(config.tagUrl));
+ return this.player.isHTML5 && this.player.isVideo && config.enabled && (!is$1.empty(config.publisherId) || is$1.url(config.tagUrl));
}
}, {
key: "tagUrl",
get: function get() {
var config = this.config;
- if (is.url(config.tagUrl)) {
+ if (is$1.url(config.tagUrl)) {
return config.tagUrl;
}
@@ -6613,7 +6889,7 @@ var parseVtt = function parseVtt(vttDataString) {
var result = {};
var lines = frame.split(/\r\n|\n|\r/);
lines.forEach(function (line) {
- if (!is.number(result.startTime)) {
+ if (!is$1.number(result.startTime)) {
// The line with start and end times on it is the first line of interest
var matchTimes = line.match(/([0-9]{2}):([0-9]{2}):([0-9]{2}).([0-9]{2,3})( ?--> ?)([0-9]{2}):([0-9]{2}):([0-9]{2}).([0-9]{2,3})/); // Note that this currently ignores caption formatting directives that are optionally on the end of this line - fine for non-captions VTT
@@ -6621,7 +6897,7 @@ var parseVtt = function parseVtt(vttDataString) {
result.startTime = Number(matchTimes[1]) * 60 * 60 + Number(matchTimes[2]) * 60 + Number(matchTimes[3]) + Number("0.".concat(matchTimes[4]));
result.endTime = Number(matchTimes[6]) * 60 * 60 + Number(matchTimes[7]) * 60 + Number(matchTimes[8]) + Number("0.".concat(matchTimes[9]));
}
- } else if (!is.empty(line.trim()) && is.empty(result.text)) {
+ } else if (!is$1.empty(line.trim()) && is$1.empty(result.text)) {
// If we already have the startTime, then we're definitely up to the text line(s)
var lineSplit = line.trim().split('#xywh=');
@@ -6718,12 +6994,12 @@ function () {
return new Promise(function (resolve) {
var src = _this2.player.config.previewThumbnails.src;
- if (is.empty(src)) {
+ if (is$1.empty(src)) {
throw new Error('Missing previewThumbnails.src config attribute');
} // If string, convert into single-element list
- var urls = is.string(src) ? [src] : src; // Loop through each src URL. Download and process the VTT file, storing the resulting data in this.thumbnails
+ var urls = is$1.string(src) ? [src] : src; // Loop through each src URL. Download and process the VTT file, storing the resulting data in this.thumbnails
var promises = urls.map(function (u) {
return _this2.getThumbnail(u);
@@ -6782,7 +7058,7 @@ function () {
return;
}
- if (!is.event(event) || !['touchmove', 'mousemove'].includes(event.type)) {
+ if (!is$1.event(event) || !['touchmove', 'mousemove'].includes(event.type)) {
return;
} // Wait until media has a duration
@@ -7276,11 +7552,11 @@ var source = {
insertElements: function insertElements(type, attributes) {
var _this = this;
- if (is.string(attributes)) {
+ if (is$1.string(attributes)) {
insertElement(type, this.media, {
src: attributes
});
- } else if (is.array(attributes)) {
+ } else if (is$1.array(attributes)) {
attributes.forEach(function (attribute) {
insertElement(type, _this.media, attribute);
});
@@ -7306,7 +7582,7 @@ var source = {
removeElement(_this2.media);
_this2.media = null; // Reset class name
- if (is.element(_this2.elements.container)) {
+ if (is$1.element(_this2.elements.container)) {
_this2.elements.container.removeAttribute('class');
} // Set the type and provider
@@ -7336,7 +7612,7 @@ var source = {
_this2.elements.container.appendChild(_this2.media); // Autoplay the new source?
- if (is.boolean(input.autoplay)) {
+ if (is$1.boolean(input.autoplay)) {
_this2.config.autoplay = input.autoplay;
} // Set attributes for audio and video
@@ -7350,7 +7626,7 @@ var source = {
_this2.media.setAttribute('autoplay', '');
}
- if (!is.empty(input.poster)) {
+ if (!is$1.empty(input.poster)) {
_this2.poster = input.poster;
}
@@ -7430,18 +7706,18 @@ function () {
this.media = target; // String selector passed
- if (is.string(this.media)) {
+ if (is$1.string(this.media)) {
this.media = document.querySelectorAll(this.media);
} // jQuery, NodeList or Array passed, use first element
- if (window.jQuery && this.media instanceof jQuery || is.nodeList(this.media) || is.array(this.media)) {
+ if (window.jQuery && this.media instanceof jQuery || is$1.nodeList(this.media) || is$1.array(this.media)) {
// eslint-disable-next-line
this.media = this.media[0];
} // Set config
- this.config = extend({}, defaults, Plyr.defaults, options || {}, function () {
+ this.config = extend({}, defaults$1, Plyr.defaults, options || {}, function () {
try {
return JSON.parse(_this.media.getAttribute('data-plyr-config'));
} catch (e) {
@@ -7485,7 +7761,7 @@ function () {
this.debug.log('Config', this.config);
this.debug.log('Support', support); // We need an element to setup
- if (is.nullOrUndefined(this.media) || !is.element(this.media)) {
+ if (is$1.nullOrUndefined(this.media) || !is$1.element(this.media)) {
this.debug.error('Setup failed: no suitable element passed');
return;
} // Bail if the element is initialized
@@ -7525,7 +7801,7 @@ function () {
// Find the frame
iframe = this.media.querySelector('iframe'); // <iframe> type
- if (is.element(iframe)) {
+ if (is$1.element(iframe)) {
// Detect provider
url = parseUrl(iframe.getAttribute('src'));
this.provider = getProviderByUrl(url.toString()); // Rework elements
@@ -7563,7 +7839,7 @@ function () {
} // Unsupported or missing provider
- if (is.empty(this.provider) || !Object.keys(providers).includes(this.provider)) {
+ if (is$1.empty(this.provider) || !Object.keys(providers).includes(this.provider)) {
this.debug.error('Setup failed: Invalid provider');
return;
} // Audio will come later for external providers
@@ -7620,7 +7896,7 @@ function () {
this.media.plyr = this; // Wrap media
- if (!is.element(this.elements.container)) {
+ if (!is$1.element(this.elements.container)) {
this.elements.container = createElement('div', {
tabindex: 0
});
@@ -7684,7 +7960,7 @@ function () {
value: function play() {
var _this2 = this;
- if (!is.function(this.media.play)) {
+ if (!is$1.function(this.media.play)) {
return null;
} // Intecept play with ads
@@ -7707,7 +7983,7 @@ function () {
}, {
key: "pause",
value: function pause() {
- if (!this.playing || !is.function(this.media.pause)) {
+ if (!this.playing || !is$1.function(this.media.pause)) {
return;
}
@@ -7726,7 +8002,7 @@ function () {
*/
value: function togglePlay(input) {
// Toggle based on current state if nothing passed
- var toggle = is.boolean(input) ? input : !this.playing;
+ var toggle = is$1.boolean(input) ? input : !this.playing;
if (toggle) {
this.play();
@@ -7744,7 +8020,7 @@ function () {
if (this.isHTML5) {
this.pause();
this.restart();
- } else if (is.function(this.media.stop)) {
+ } else if (is$1.function(this.media.stop)) {
this.media.stop();
}
}
@@ -7765,7 +8041,7 @@ function () {
}, {
key: "rewind",
value: function rewind(seekTime) {
- this.currentTime = this.currentTime - (is.number(seekTime) ? seekTime : this.config.seekTime);
+ this.currentTime = this.currentTime - (is$1.number(seekTime) ? seekTime : this.config.seekTime);
}
/**
* Fast forward
@@ -7775,7 +8051,7 @@ function () {
}, {
key: "forward",
value: function forward(seekTime) {
- this.currentTime = this.currentTime + (is.number(seekTime) ? seekTime : this.config.seekTime);
+ this.currentTime = this.currentTime + (is$1.number(seekTime) ? seekTime : this.config.seekTime);
}
/**
* Seek to a time
@@ -7791,7 +8067,7 @@ function () {
*/
value: function increaseVolume(step) {
var volume = this.media.muted ? 0 : this.volume;
- this.volume = volume + (is.number(step) ? step : 0);
+ this.volume = volume + (is$1.number(step) ? step : 0);
}
/**
* Decrease volume
@@ -7853,7 +8129,7 @@ function () {
var hiding = toggleClass(this.elements.container, this.config.classNames.hideControls, force); // Close menu
- if (hiding && this.config.controls.includes('settings') && !is.empty(this.config.settings)) {
+ if (hiding && this.config.controls.includes('settings') && !is$1.empty(this.config.settings)) {
controls.toggleMenu.call(this, false);
} // Trigger event on change
@@ -7941,7 +8217,7 @@ function () {
} // Callback
- if (is.function(callback)) {
+ if (is$1.function(callback)) {
callback();
}
} else {
@@ -7952,7 +8228,7 @@ function () {
triggerEvent.call(_this3, _this3.elements.original, 'destroyed', true); // Callback
- if (is.function(callback)) {
+ if (is$1.function(callback)) {
callback.call(_this3.elements.original);
} // Reset state
@@ -7981,7 +8257,7 @@ function () {
clearInterval(this.timers.buffering);
clearInterval(this.timers.playing); // Destroy YouTube API
- if (this.embed !== null && is.function(this.embed.destroy)) {
+ if (this.embed !== null && is$1.function(this.embed.destroy)) {
this.embed.destroy();
} // Clean up
@@ -8086,7 +8362,7 @@ function () {
} // Validate input
- var inputIsValid = is.number(input) && input > 0; // Set
+ var inputIsValid = is$1.number(input) && input > 0; // Set
this.media.currentTime = inputIsValid ? Math.min(input, this.duration) : 0; // Logging
@@ -8108,7 +8384,7 @@ function () {
get: function get() {
var buffered = this.media.buffered; // YouTube / Vimeo return a float between 0-1
- if (is.number(buffered)) {
+ if (is$1.number(buffered)) {
return buffered;
} // HTML5
// TODO: Handle buffered chunks of the media
@@ -8141,7 +8417,7 @@ function () {
var fauxDuration = parseFloat(this.config.duration); // Media duration can be NaN or Infinity before the media has loaded
var realDuration = (this.media || {}).duration;
- var duration = !is.number(realDuration) || realDuration === Infinity ? 0 : realDuration; // If config duration is funky, use regular duration
+ var duration = !is$1.number(realDuration) || realDuration === Infinity ? 0 : realDuration; // If config duration is funky, use regular duration
return fauxDuration || duration;
}
@@ -8157,17 +8433,17 @@ function () {
var max = 1;
var min = 0;
- if (is.string(volume)) {
+ if (is$1.string(volume)) {
volume = Number(volume);
} // Load volume from storage if no value specified
- if (!is.number(volume)) {
+ if (!is$1.number(volume)) {
volume = this.storage.get('volume');
} // Use config if all else fails
- if (!is.number(volume)) {
+ if (!is$1.number(volume)) {
volume = this.config.volume;
} // Maximum is volumeMax
@@ -8186,7 +8462,7 @@ function () {
this.media.volume = volume; // If muted, and we're increasing volume manually, reset muted state
- if (!is.empty(value) && this.muted && volume > 0) {
+ if (!is$1.empty(value) && this.muted && volume > 0) {
this.muted = false;
}
}
@@ -8202,12 +8478,12 @@ function () {
set: function set(mute) {
var toggle = mute; // Load muted state from storage
- if (!is.boolean(toggle)) {
+ if (!is$1.boolean(toggle)) {
toggle = this.storage.get('muted');
} // Use config if all else fails
- if (!is.boolean(toggle)) {
+ if (!is$1.boolean(toggle)) {
toggle = this.config.muted;
} // Update config
@@ -8252,15 +8528,15 @@ function () {
set: function set(input) {
var speed = null;
- if (is.number(input)) {
+ if (is$1.number(input)) {
speed = input;
}
- if (!is.number(speed)) {
+ if (!is$1.number(speed)) {
speed = this.storage.get('speed');
}
- if (!is.number(speed)) {
+ if (!is$1.number(speed)) {
speed = this.config.speed.selected;
} // Set min/max
@@ -8306,7 +8582,7 @@ function () {
return;
}
- var quality = [!is.empty(input) && Number(input), this.storage.get('quality'), config.selected, config.default].find(is.number);
+ var quality = [!is$1.empty(input) && Number(input), this.storage.get('quality'), config.selected, config.default].find(is$1.number);
var updateStorage = true;
if (!options.includes(quality)) {
@@ -8344,7 +8620,7 @@ function () {
}, {
key: "loop",
set: function set(input) {
- var toggle = is.boolean(input) ? input : this.config.loop.active;
+ var toggle = is$1.boolean(input) ? input : this.config.loop.active;
this.config.loop.active = toggle;
this.media.loop = toggle; // Set default to be a true toggle
@@ -8417,7 +8693,7 @@ function () {
key: "download",
get: function get() {
var download = this.config.urls.download;
- return is.url(download) ? download : this.source;
+ return is$1.url(download) ? download : this.source;
}
/**
* Set the poster image for a video
@@ -8453,7 +8729,7 @@ function () {
}, {
key: "autoplay",
set: function set(input) {
- var toggle = is.boolean(input) ? input : this.config.autoplay;
+ var toggle = is$1.boolean(input) ? input : this.config.autoplay;
this.config.autoplay = toggle;
}
/**
@@ -8511,15 +8787,15 @@ function () {
} // Toggle based on current state if not passed
- var toggle = is.boolean(input) ? input : !this.pip; // Toggle based on current state
+ var toggle = is$1.boolean(input) ? input : !this.pip; // Toggle based on current state
// Safari
- if (is.function(this.media.webkitSetPresentationMode)) {
+ if (is$1.function(this.media.webkitSetPresentationMode)) {
this.media.webkitSetPresentationMode(toggle ? pip.active : pip.inactive);
} // Chrome
- if (is.function(this.media.requestPictureInPicture)) {
+ if (is$1.function(this.media.requestPictureInPicture)) {
if (!this.pip && toggle) {
this.media.requestPictureInPicture();
} else if (this.pip && !toggle) {
@@ -8537,7 +8813,7 @@ function () {
} // Safari
- if (!is.empty(this.media.webkitPresentationMode)) {
+ if (!is$1.empty(this.media.webkitPresentationMode)) {
return this.media.webkitPresentationMode === pip.active;
} // Chrome
@@ -8572,15 +8848,15 @@ function () {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var targets = null;
- if (is.string(selector)) {
+ if (is$1.string(selector)) {
targets = Array.from(document.querySelectorAll(selector));
- } else if (is.nodeList(selector)) {
+ } else if (is$1.nodeList(selector)) {
targets = Array.from(selector);
- } else if (is.array(selector)) {
- targets = selector.filter(is.element);
+ } else if (is$1.array(selector)) {
+ targets = selector.filter(is$1.element);
}
- if (is.empty(targets)) {
+ if (is$1.empty(targets)) {
return null;
}
@@ -8593,6 +8869,6 @@ function () {
return Plyr;
}();
-Plyr.defaults = cloneDeep(defaults);
+Plyr.defaults = cloneDeep(defaults$1);
export default Plyr;