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