Ads only on HTML5 and .is cleanup
This commit is contained in:
parent
20f2ddc11d
commit
e04b90c9c0
224
dist/plyr.js
vendored
224
dist/plyr.js
vendored
@ -11,60 +11,92 @@ typeof navigator === "object" && (function (global, factory) {
|
||||
var getConstructor = function getConstructor(input) {
|
||||
return input !== null && typeof input !== 'undefined' ? input.constructor : null;
|
||||
};
|
||||
|
||||
var instanceOf = function instanceOf(input, constructor) {
|
||||
return Boolean(input && constructor && input instanceof constructor);
|
||||
};
|
||||
var isNullOrUndefined = function isNullOrUndefined(input) {
|
||||
return input === null || typeof input === 'undefined';
|
||||
};
|
||||
var isObject = function isObject(input) {
|
||||
return getConstructor(input) === Object;
|
||||
};
|
||||
var isNumber = function isNumber(input) {
|
||||
return getConstructor(input) === Number && !Number.isNaN(input);
|
||||
};
|
||||
var isString = function isString(input) {
|
||||
return getConstructor(input) === String;
|
||||
};
|
||||
var isBoolean = function isBoolean(input) {
|
||||
return getConstructor(input) === Boolean;
|
||||
};
|
||||
var isFunction = function isFunction(input) {
|
||||
return getConstructor(input) === Function;
|
||||
};
|
||||
var isArray = function isArray(input) {
|
||||
return Array.isArray(input);
|
||||
};
|
||||
var isWeakMap = function isWeakMap(input) {
|
||||
return instanceOf(input, WeakMap);
|
||||
};
|
||||
var isNodeList = function isNodeList(input) {
|
||||
return instanceOf(input, NodeList);
|
||||
};
|
||||
var isElement = function isElement(input) {
|
||||
return instanceOf(input, Element);
|
||||
};
|
||||
var isTextNode = function isTextNode(input) {
|
||||
return getConstructor(input) === Text;
|
||||
};
|
||||
var isEvent = function isEvent(input) {
|
||||
return instanceOf(input, Event);
|
||||
};
|
||||
var isCue = function isCue(input) {
|
||||
return instanceOf(input, window.TextTrackCue) || instanceOf(input, window.VTTCue);
|
||||
};
|
||||
var isTrack = function isTrack(input) {
|
||||
return instanceOf(input, TextTrack) || !isNullOrUndefined(input) && isString(input.kind);
|
||||
};
|
||||
|
||||
var isEmpty = function isEmpty(input) {
|
||||
return isNullOrUndefined(input) || (isString(input) || isArray(input) || isNodeList(input)) && !input.length || isObject(input) && !Object.keys(input).length;
|
||||
};
|
||||
|
||||
var isUrl = function isUrl(input) {
|
||||
// Accept a URL object
|
||||
if (instanceOf(input, window.URL)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Add the protocol if required
|
||||
var string = input;
|
||||
if (!input.startsWith('http://') || !input.startsWith('https://')) {
|
||||
string = 'http://' + input;
|
||||
}
|
||||
|
||||
try {
|
||||
return !isEmpty(new URL(string).hostname);
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
var is = {
|
||||
object: function object(input) {
|
||||
return getConstructor(input) === Object;
|
||||
},
|
||||
number: function number(input) {
|
||||
return getConstructor(input) === Number && !Number.isNaN(input);
|
||||
},
|
||||
string: function string(input) {
|
||||
return getConstructor(input) === String;
|
||||
},
|
||||
boolean: function boolean(input) {
|
||||
return getConstructor(input) === Boolean;
|
||||
},
|
||||
function: function _function(input) {
|
||||
return getConstructor(input) === Function;
|
||||
},
|
||||
array: function array(input) {
|
||||
return !is.nullOrUndefined(input) && Array.isArray(input);
|
||||
},
|
||||
weakMap: function weakMap(input) {
|
||||
return instanceOf(input, WeakMap);
|
||||
},
|
||||
nodeList: function nodeList(input) {
|
||||
return instanceOf(input, NodeList);
|
||||
},
|
||||
element: function element(input) {
|
||||
return instanceOf(input, Element);
|
||||
},
|
||||
textNode: function textNode(input) {
|
||||
return getConstructor(input) === Text;
|
||||
},
|
||||
event: function event(input) {
|
||||
return instanceOf(input, Event);
|
||||
},
|
||||
cue: function cue(input) {
|
||||
return instanceOf(input, window.TextTrackCue) || instanceOf(input, window.VTTCue);
|
||||
},
|
||||
track: function track(input) {
|
||||
return instanceOf(input, TextTrack) || !is.nullOrUndefined(input) && is.string(input.kind);
|
||||
},
|
||||
url: function url(input) {
|
||||
return !is.nullOrUndefined(input) && /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-/]))?/.test(input);
|
||||
},
|
||||
nullOrUndefined: function nullOrUndefined(input) {
|
||||
return input === null || typeof input === 'undefined';
|
||||
},
|
||||
empty: function empty(input) {
|
||||
return is.nullOrUndefined(input) || (is.string(input) || is.array(input) || is.nodeList(input)) && !input.length || is.object(input) && !Object.keys(input).length;
|
||||
}
|
||||
nullOrUndefined: isNullOrUndefined,
|
||||
object: isObject,
|
||||
number: isNumber,
|
||||
string: isString,
|
||||
boolean: isBoolean,
|
||||
function: isFunction,
|
||||
array: isArray,
|
||||
weakMap: isWeakMap,
|
||||
nodeList: isNodeList,
|
||||
element: isElement,
|
||||
textNode: isTextNode,
|
||||
event: isEvent,
|
||||
cue: isCue,
|
||||
track: isTrack,
|
||||
url: isUrl,
|
||||
empty: isEmpty
|
||||
};
|
||||
|
||||
// ==========================================================================
|
||||
@ -769,22 +801,17 @@ typeof navigator === "object" && (function (global, factory) {
|
||||
|
||||
// Quality
|
||||
Object.defineProperty(player.media, 'quality', {
|
||||
get: function get$$1() {
|
||||
get: function get() {
|
||||
// Get sources
|
||||
var sources = html5.getSources.call(player);
|
||||
|
||||
var _sources$filter = sources.filter(function (source) {
|
||||
var source = sources.find(function (source) {
|
||||
return source.getAttribute('src') === player.source;
|
||||
}),
|
||||
_sources$filter2 = slicedToArray(_sources$filter, 1),
|
||||
source = _sources$filter2[0];
|
||||
});
|
||||
|
||||
// Return size, if match is found
|
||||
|
||||
|
||||
return source && Number(source.getAttribute('size'));
|
||||
},
|
||||
set: function set$$1(input) {
|
||||
set: function set(input) {
|
||||
// Get sources
|
||||
var sources = html5.getSources.call(player);
|
||||
|
||||
@ -799,25 +826,30 @@ typeof navigator === "object" && (function (global, factory) {
|
||||
}
|
||||
|
||||
// Get current state
|
||||
var currentTime = player.currentTime,
|
||||
playing = player.playing;
|
||||
var _player$media = player.media,
|
||||
currentTime = _player$media.currentTime,
|
||||
paused = _player$media.paused,
|
||||
preload = _player$media.preload,
|
||||
readyState = _player$media.readyState;
|
||||
|
||||
// Set new source
|
||||
|
||||
player.media.src = source.getAttribute('src');
|
||||
|
||||
// Restore time
|
||||
var onLoadedMetaData = function onLoadedMetaData() {
|
||||
player.currentTime = currentTime;
|
||||
};
|
||||
player.once('loadedmetadata', onLoadedMetaData);
|
||||
// Prevent loading if preload="none" and the current source isn't loaded (#1044)
|
||||
if (preload !== 'none' || readyState) {
|
||||
// Restore time
|
||||
player.once('loadedmetadata', function () {
|
||||
player.currentTime = currentTime;
|
||||
|
||||
// Load new source
|
||||
player.media.load();
|
||||
// Resume playing
|
||||
if (!paused) {
|
||||
player.play();
|
||||
}
|
||||
});
|
||||
|
||||
// Resume playing
|
||||
if (playing) {
|
||||
player.play();
|
||||
// Load new source
|
||||
player.media.load();
|
||||
}
|
||||
|
||||
// Trigger change event
|
||||
@ -4777,33 +4809,28 @@ typeof navigator === "object" && (function (global, factory) {
|
||||
// Detect "natural" scroll - suppored on OS X Safari only
|
||||
// Other browsers on OS X will be inverted until support improves
|
||||
var inverted = event.webkitDirectionInvertedFromDevice;
|
||||
var step = 1 / 50;
|
||||
var direction = 0;
|
||||
|
||||
// Scroll down (or up on natural) to decrease
|
||||
if (event.deltaY < 0 || event.deltaX > 0) {
|
||||
if (inverted) {
|
||||
_this4.player.decreaseVolume(step);
|
||||
direction = -1;
|
||||
} else {
|
||||
_this4.player.increaseVolume(step);
|
||||
direction = 1;
|
||||
}
|
||||
}
|
||||
// Get delta from event. Invert if `inverted` is true
|
||||
|
||||
// Scroll up (or down on natural) to increase
|
||||
if (event.deltaY > 0 || event.deltaX < 0) {
|
||||
if (inverted) {
|
||||
_this4.player.increaseVolume(step);
|
||||
direction = 1;
|
||||
} else {
|
||||
_this4.player.decreaseVolume(step);
|
||||
direction = -1;
|
||||
}
|
||||
}
|
||||
var _map = [event.deltaX, -event.deltaY].map(function (value) {
|
||||
return inverted ? -value : value;
|
||||
}),
|
||||
_map2 = slicedToArray(_map, 2),
|
||||
x = _map2[0],
|
||||
y = _map2[1];
|
||||
|
||||
// Using the biggest delta, normalize to 1 or -1 (or 0 if no delta)
|
||||
|
||||
|
||||
var direction = Math.sign(Math.abs(x) > Math.abs(y) ? x : y);
|
||||
|
||||
// Change the volume by 2%
|
||||
_this4.player.increaseVolume(direction / 50);
|
||||
|
||||
// Don't break page scrolling at max and min
|
||||
if (direction === 1 && _this4.player.media.volume < 1 || direction === -1 && _this4.player.media.volume > 0) {
|
||||
var volume = _this4.player.media.volume;
|
||||
|
||||
if (direction === 1 && volume < 1 || direction === -1 && volume > 0) {
|
||||
event.preventDefault();
|
||||
}
|
||||
}, 'volume', false);
|
||||
@ -5822,8 +5849,8 @@ typeof navigator === "object" && (function (global, factory) {
|
||||
return Number(instance.getCurrentTime());
|
||||
},
|
||||
set: function set(time) {
|
||||
// If paused, mute audio preventively (YouTube starts playing on seek if the video hasn't been played yet).
|
||||
if (player.paused) {
|
||||
// If paused and never played, mute audio preventively (YouTube starts playing on seek if the video hasn't been played yet).
|
||||
if (player.paused && !player.embed.hasPlayed) {
|
||||
player.embed.mute();
|
||||
}
|
||||
|
||||
@ -6742,7 +6769,7 @@ typeof navigator === "object" && (function (global, factory) {
|
||||
}, {
|
||||
key: 'enabled',
|
||||
get: function get$$1() {
|
||||
return this.player.isVideo && this.player.config.ads.enabled && !is.empty(this.publisherId);
|
||||
return this.player.isHTML5 && this.player.isVideo && this.player.config.ads.enabled && !is.empty(this.publisherId);
|
||||
}
|
||||
}, {
|
||||
key: 'tagUrl',
|
||||
@ -7299,7 +7326,7 @@ typeof navigator === "object" && (function (global, factory) {
|
||||
*/
|
||||
value: function increaseVolume(step) {
|
||||
var volume = this.media.muted ? 0 : this.volume;
|
||||
this.volume = volume + (is.number(step) ? step : 1);
|
||||
this.volume = volume + (is.number(step) ? step : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -7310,8 +7337,7 @@ typeof navigator === "object" && (function (global, factory) {
|
||||
}, {
|
||||
key: 'decreaseVolume',
|
||||
value: function decreaseVolume(step) {
|
||||
var volume = this.media.muted ? 0 : this.volume;
|
||||
this.volume = volume - (is.number(step) ? step : 1);
|
||||
this.increaseVolume(-step);
|
||||
}
|
||||
|
||||
/**
|
||||
|
2
dist/plyr.js.map
vendored
2
dist/plyr.js.map
vendored
File diff suppressed because one or more lines are too long
2
dist/plyr.min.js
vendored
2
dist/plyr.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/plyr.min.js.map
vendored
2
dist/plyr.min.js.map
vendored
File diff suppressed because one or more lines are too long
218
dist/plyr.polyfilled.js
vendored
218
dist/plyr.polyfilled.js
vendored
@ -5397,60 +5397,92 @@ typeof navigator === "object" && (function (global, factory) {
|
||||
var getConstructor = function getConstructor(input) {
|
||||
return input !== null && typeof input !== 'undefined' ? input.constructor : null;
|
||||
};
|
||||
|
||||
var instanceOf = function instanceOf(input, constructor) {
|
||||
return Boolean(input && constructor && input instanceof constructor);
|
||||
};
|
||||
var isNullOrUndefined = function isNullOrUndefined(input) {
|
||||
return input === null || typeof input === 'undefined';
|
||||
};
|
||||
var isObject = function isObject(input) {
|
||||
return getConstructor(input) === Object;
|
||||
};
|
||||
var isNumber = function isNumber(input) {
|
||||
return getConstructor(input) === Number && !Number.isNaN(input);
|
||||
};
|
||||
var isString = function isString(input) {
|
||||
return getConstructor(input) === String;
|
||||
};
|
||||
var isBoolean = function isBoolean(input) {
|
||||
return getConstructor(input) === Boolean;
|
||||
};
|
||||
var isFunction = function isFunction(input) {
|
||||
return getConstructor(input) === Function;
|
||||
};
|
||||
var isArray = function isArray(input) {
|
||||
return Array.isArray(input);
|
||||
};
|
||||
var isWeakMap = function isWeakMap(input) {
|
||||
return instanceOf(input, WeakMap);
|
||||
};
|
||||
var isNodeList = function isNodeList(input) {
|
||||
return instanceOf(input, NodeList);
|
||||
};
|
||||
var isElement = function isElement(input) {
|
||||
return instanceOf(input, Element);
|
||||
};
|
||||
var isTextNode = function isTextNode(input) {
|
||||
return getConstructor(input) === Text;
|
||||
};
|
||||
var isEvent = function isEvent(input) {
|
||||
return instanceOf(input, Event);
|
||||
};
|
||||
var isCue = function isCue(input) {
|
||||
return instanceOf(input, window.TextTrackCue) || instanceOf(input, window.VTTCue);
|
||||
};
|
||||
var isTrack = function isTrack(input) {
|
||||
return instanceOf(input, TextTrack) || !isNullOrUndefined(input) && isString(input.kind);
|
||||
};
|
||||
|
||||
var isEmpty = function isEmpty(input) {
|
||||
return isNullOrUndefined(input) || (isString(input) || isArray(input) || isNodeList(input)) && !input.length || isObject(input) && !Object.keys(input).length;
|
||||
};
|
||||
|
||||
var isUrl = function isUrl(input) {
|
||||
// Accept a URL object
|
||||
if (instanceOf(input, window.URL)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Add the protocol if required
|
||||
var string = input;
|
||||
if (!input.startsWith('http://') || !input.startsWith('https://')) {
|
||||
string = 'http://' + input;
|
||||
}
|
||||
|
||||
try {
|
||||
return !isEmpty(new URL(string).hostname);
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
var is$1 = {
|
||||
object: function object(input) {
|
||||
return getConstructor(input) === Object;
|
||||
},
|
||||
number: function number(input) {
|
||||
return getConstructor(input) === Number && !Number.isNaN(input);
|
||||
},
|
||||
string: function string(input) {
|
||||
return getConstructor(input) === String;
|
||||
},
|
||||
boolean: function boolean(input) {
|
||||
return getConstructor(input) === Boolean;
|
||||
},
|
||||
function: function _function(input) {
|
||||
return getConstructor(input) === Function;
|
||||
},
|
||||
array: function array(input) {
|
||||
return !is$1.nullOrUndefined(input) && Array.isArray(input);
|
||||
},
|
||||
weakMap: function weakMap(input) {
|
||||
return instanceOf(input, WeakMap);
|
||||
},
|
||||
nodeList: function nodeList(input) {
|
||||
return instanceOf(input, NodeList);
|
||||
},
|
||||
element: function element(input) {
|
||||
return instanceOf(input, Element);
|
||||
},
|
||||
textNode: function textNode(input) {
|
||||
return getConstructor(input) === Text;
|
||||
},
|
||||
event: function event(input) {
|
||||
return instanceOf(input, Event);
|
||||
},
|
||||
cue: function cue(input) {
|
||||
return instanceOf(input, window.TextTrackCue) || instanceOf(input, window.VTTCue);
|
||||
},
|
||||
track: function track(input) {
|
||||
return instanceOf(input, TextTrack) || !is$1.nullOrUndefined(input) && is$1.string(input.kind);
|
||||
},
|
||||
url: function url(input) {
|
||||
return !is$1.nullOrUndefined(input) && /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-/]))?/.test(input);
|
||||
},
|
||||
nullOrUndefined: function nullOrUndefined(input) {
|
||||
return input === null || typeof input === 'undefined';
|
||||
},
|
||||
empty: function empty(input) {
|
||||
return is$1.nullOrUndefined(input) || (is$1.string(input) || is$1.array(input) || is$1.nodeList(input)) && !input.length || is$1.object(input) && !Object.keys(input).length;
|
||||
}
|
||||
nullOrUndefined: isNullOrUndefined,
|
||||
object: isObject,
|
||||
number: isNumber,
|
||||
string: isString,
|
||||
boolean: isBoolean,
|
||||
function: isFunction,
|
||||
array: isArray,
|
||||
weakMap: isWeakMap,
|
||||
nodeList: isNodeList,
|
||||
element: isElement,
|
||||
textNode: isTextNode,
|
||||
event: isEvent,
|
||||
cue: isCue,
|
||||
track: isTrack,
|
||||
url: isUrl,
|
||||
empty: isEmpty
|
||||
};
|
||||
|
||||
// ==========================================================================
|
||||
@ -6158,16 +6190,11 @@ typeof navigator === "object" && (function (global, factory) {
|
||||
get: function get() {
|
||||
// Get sources
|
||||
var sources = html5.getSources.call(player);
|
||||
|
||||
var _sources$filter = sources.filter(function (source) {
|
||||
var source = sources.find(function (source) {
|
||||
return source.getAttribute('src') === player.source;
|
||||
}),
|
||||
_sources$filter2 = slicedToArray(_sources$filter, 1),
|
||||
source = _sources$filter2[0];
|
||||
});
|
||||
|
||||
// Return size, if match is found
|
||||
|
||||
|
||||
return source && Number(source.getAttribute('size'));
|
||||
},
|
||||
set: function set(input) {
|
||||
@ -6185,25 +6212,30 @@ typeof navigator === "object" && (function (global, factory) {
|
||||
}
|
||||
|
||||
// Get current state
|
||||
var currentTime = player.currentTime,
|
||||
playing = player.playing;
|
||||
var _player$media = player.media,
|
||||
currentTime = _player$media.currentTime,
|
||||
paused = _player$media.paused,
|
||||
preload = _player$media.preload,
|
||||
readyState = _player$media.readyState;
|
||||
|
||||
// Set new source
|
||||
|
||||
player.media.src = source.getAttribute('src');
|
||||
|
||||
// Restore time
|
||||
var onLoadedMetaData = function onLoadedMetaData() {
|
||||
player.currentTime = currentTime;
|
||||
};
|
||||
player.once('loadedmetadata', onLoadedMetaData);
|
||||
// Prevent loading if preload="none" and the current source isn't loaded (#1044)
|
||||
if (preload !== 'none' || readyState) {
|
||||
// Restore time
|
||||
player.once('loadedmetadata', function () {
|
||||
player.currentTime = currentTime;
|
||||
|
||||
// Load new source
|
||||
player.media.load();
|
||||
// Resume playing
|
||||
if (!paused) {
|
||||
player.play();
|
||||
}
|
||||
});
|
||||
|
||||
// Resume playing
|
||||
if (playing) {
|
||||
player.play();
|
||||
// Load new source
|
||||
player.media.load();
|
||||
}
|
||||
|
||||
// Trigger change event
|
||||
@ -10163,33 +10195,28 @@ typeof navigator === "object" && (function (global, factory) {
|
||||
// Detect "natural" scroll - suppored on OS X Safari only
|
||||
// Other browsers on OS X will be inverted until support improves
|
||||
var inverted = event.webkitDirectionInvertedFromDevice;
|
||||
var step = 1 / 50;
|
||||
var direction = 0;
|
||||
|
||||
// Scroll down (or up on natural) to decrease
|
||||
if (event.deltaY < 0 || event.deltaX > 0) {
|
||||
if (inverted) {
|
||||
_this4.player.decreaseVolume(step);
|
||||
direction = -1;
|
||||
} else {
|
||||
_this4.player.increaseVolume(step);
|
||||
direction = 1;
|
||||
}
|
||||
}
|
||||
// Get delta from event. Invert if `inverted` is true
|
||||
|
||||
// Scroll up (or down on natural) to increase
|
||||
if (event.deltaY > 0 || event.deltaX < 0) {
|
||||
if (inverted) {
|
||||
_this4.player.increaseVolume(step);
|
||||
direction = 1;
|
||||
} else {
|
||||
_this4.player.decreaseVolume(step);
|
||||
direction = -1;
|
||||
}
|
||||
}
|
||||
var _map = [event.deltaX, -event.deltaY].map(function (value) {
|
||||
return inverted ? -value : value;
|
||||
}),
|
||||
_map2 = slicedToArray(_map, 2),
|
||||
x = _map2[0],
|
||||
y = _map2[1];
|
||||
|
||||
// Using the biggest delta, normalize to 1 or -1 (or 0 if no delta)
|
||||
|
||||
|
||||
var direction = Math.sign(Math.abs(x) > Math.abs(y) ? x : y);
|
||||
|
||||
// Change the volume by 2%
|
||||
_this4.player.increaseVolume(direction / 50);
|
||||
|
||||
// Don't break page scrolling at max and min
|
||||
if (direction === 1 && _this4.player.media.volume < 1 || direction === -1 && _this4.player.media.volume > 0) {
|
||||
var volume = _this4.player.media.volume;
|
||||
|
||||
if (direction === 1 && volume < 1 || direction === -1 && volume > 0) {
|
||||
event.preventDefault();
|
||||
}
|
||||
}, 'volume', false);
|
||||
@ -11202,8 +11229,8 @@ typeof navigator === "object" && (function (global, factory) {
|
||||
return Number(instance.getCurrentTime());
|
||||
},
|
||||
set: function set(time) {
|
||||
// If paused, mute audio preventively (YouTube starts playing on seek if the video hasn't been played yet).
|
||||
if (player.paused) {
|
||||
// If paused and never played, mute audio preventively (YouTube starts playing on seek if the video hasn't been played yet).
|
||||
if (player.paused && !player.embed.hasPlayed) {
|
||||
player.embed.mute();
|
||||
}
|
||||
|
||||
@ -12679,7 +12706,7 @@ typeof navigator === "object" && (function (global, factory) {
|
||||
*/
|
||||
value: function increaseVolume(step) {
|
||||
var volume = this.media.muted ? 0 : this.volume;
|
||||
this.volume = volume + (is$1.number(step) ? step : 1);
|
||||
this.volume = volume + (is$1.number(step) ? step : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -12690,8 +12717,7 @@ typeof navigator === "object" && (function (global, factory) {
|
||||
}, {
|
||||
key: 'decreaseVolume',
|
||||
value: function decreaseVolume(step) {
|
||||
var volume = this.media.muted ? 0 : this.volume;
|
||||
this.volume = volume - (is$1.number(step) ? step : 1);
|
||||
this.increaseVolume(-step);
|
||||
}
|
||||
|
||||
/**
|
||||
|
2
dist/plyr.polyfilled.js.map
vendored
2
dist/plyr.polyfilled.js.map
vendored
File diff suppressed because one or more lines are too long
2
dist/plyr.polyfilled.min.js
vendored
2
dist/plyr.polyfilled.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/plyr.polyfilled.min.js.map
vendored
2
dist/plyr.polyfilled.min.js.map
vendored
File diff suppressed because one or more lines are too long
@ -49,7 +49,9 @@ class Ads {
|
||||
}
|
||||
|
||||
get enabled() {
|
||||
return this.player.isVideo && this.player.config.ads.enabled && !is.empty(this.publisherId);
|
||||
return (
|
||||
this.player.isHTML5 && this.player.isVideo && this.player.config.ads.enabled && !is.empty(this.publisherId)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3,65 +3,61 @@
|
||||
// ==========================================================================
|
||||
|
||||
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 isWeakMap = input => instanceOf(input, WeakMap);
|
||||
const isNodeList = input => instanceOf(input, NodeList);
|
||||
const isElement = input => instanceOf(input, Element);
|
||||
const isTextNode = input => getConstructor(input) === Text;
|
||||
const isEvent = input => instanceOf(input, Event);
|
||||
const isCue = input => instanceOf(input, window.TextTrackCue) || instanceOf(input, window.VTTCue);
|
||||
const isTrack = input => instanceOf(input, TextTrack) || (!isNullOrUndefined(input) && isString(input.kind));
|
||||
|
||||
const is = {
|
||||
object(input) {
|
||||
return getConstructor(input) === Object;
|
||||
},
|
||||
number(input) {
|
||||
return getConstructor(input) === Number && !Number.isNaN(input);
|
||||
},
|
||||
string(input) {
|
||||
return getConstructor(input) === String;
|
||||
},
|
||||
boolean(input) {
|
||||
return getConstructor(input) === Boolean;
|
||||
},
|
||||
function(input) {
|
||||
return getConstructor(input) === Function;
|
||||
},
|
||||
array(input) {
|
||||
return !is.nullOrUndefined(input) && Array.isArray(input);
|
||||
},
|
||||
weakMap(input) {
|
||||
return instanceOf(input, WeakMap);
|
||||
},
|
||||
nodeList(input) {
|
||||
return instanceOf(input, NodeList);
|
||||
},
|
||||
element(input) {
|
||||
return instanceOf(input, Element);
|
||||
},
|
||||
textNode(input) {
|
||||
return getConstructor(input) === Text;
|
||||
},
|
||||
event(input) {
|
||||
return instanceOf(input, Event);
|
||||
},
|
||||
cue(input) {
|
||||
return instanceOf(input, window.TextTrackCue) || instanceOf(input, window.VTTCue);
|
||||
},
|
||||
track(input) {
|
||||
return instanceOf(input, TextTrack) || (!is.nullOrUndefined(input) && is.string(input.kind));
|
||||
},
|
||||
url(input) {
|
||||
return (
|
||||
!is.nullOrUndefined(input) &&
|
||||
/(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-/]))?/.test(input)
|
||||
);
|
||||
},
|
||||
nullOrUndefined(input) {
|
||||
return input === null || typeof input === 'undefined';
|
||||
},
|
||||
empty(input) {
|
||||
return (
|
||||
is.nullOrUndefined(input) ||
|
||||
((is.string(input) || is.array(input) || is.nodeList(input)) && !input.length) ||
|
||||
(is.object(input) && !Object.keys(input).length)
|
||||
);
|
||||
},
|
||||
const isEmpty = input =>
|
||||
isNullOrUndefined(input) ||
|
||||
((isString(input) || isArray(input) || isNodeList(input)) && !input.length) ||
|
||||
(isObject(input) && !Object.keys(input).length);
|
||||
|
||||
const isUrl = input => {
|
||||
// Accept a URL object
|
||||
if (instanceOf(input, window.URL)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Add the protocol if required
|
||||
let string = input;
|
||||
if (!input.startsWith('http://') || !input.startsWith('https://')) {
|
||||
string = `http://${input}`;
|
||||
}
|
||||
|
||||
try {
|
||||
return !isEmpty(new URL(string).hostname);
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
export default is;
|
||||
export default {
|
||||
nullOrUndefined: isNullOrUndefined,
|
||||
object: isObject,
|
||||
number: isNumber,
|
||||
string: isString,
|
||||
boolean: isBoolean,
|
||||
function: isFunction,
|
||||
array: isArray,
|
||||
weakMap: isWeakMap,
|
||||
nodeList: isNodeList,
|
||||
element: isElement,
|
||||
textNode: isTextNode,
|
||||
event: isEvent,
|
||||
cue: isCue,
|
||||
track: isTrack,
|
||||
url: isUrl,
|
||||
empty: isEmpty,
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user