Update plyr module
This commit is contained in:
parent
a2723d76cd
commit
cd876f65e3
File diff suppressed because one or more lines are too long
@ -2,7 +2,7 @@ typeof navigator === "object" && (function (global, factory) {
|
|||||||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
||||||
typeof define === 'function' && define.amd ? define('Plyr', factory) :
|
typeof define === 'function' && define.amd ? define('Plyr', factory) :
|
||||||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Plyr = factory());
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Plyr = factory());
|
||||||
}(this, (function () { 'use strict';
|
})(this, (function () { 'use strict';
|
||||||
|
|
||||||
function _defineProperty$1(obj, key, value) {
|
function _defineProperty$1(obj, key, value) {
|
||||||
if (key in obj) {
|
if (key in obj) {
|
||||||
@ -298,7 +298,7 @@ typeof navigator === "object" && (function (global, factory) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
return !isEmpty(new URL(string).hostname);
|
return !isEmpty(new URL(string).hostname);
|
||||||
} catch (e) {
|
} catch (_) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -346,7 +346,7 @@ typeof navigator === "object" && (function (global, factory) {
|
|||||||
element.offsetHeight; // eslint-disable-next-line no-param-reassign
|
element.offsetHeight; // eslint-disable-next-line no-param-reassign
|
||||||
|
|
||||||
element.hidden = false;
|
element.hidden = false;
|
||||||
} catch (e) {// Do nothing
|
} catch (_) {// Do nothing
|
||||||
}
|
}
|
||||||
}, delay);
|
}, delay);
|
||||||
}
|
}
|
||||||
@ -727,7 +727,7 @@ typeof navigator === "object" && (function (global, factory) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
return Boolean(type && this.media.canPlayType(type).replace(/no/, ''));
|
return Boolean(type && this.media.canPlayType(type).replace(/no/, ''));
|
||||||
} catch (e) {
|
} catch (_) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -768,7 +768,7 @@ typeof navigator === "object" && (function (global, factory) {
|
|||||||
});
|
});
|
||||||
window.addEventListener('test', null, options);
|
window.addEventListener('test', null, options);
|
||||||
window.removeEventListener('test', null, options);
|
window.removeEventListener('test', null, options);
|
||||||
} catch (e) {// Do nothing
|
} catch (_) {// Do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
return supported;
|
return supported;
|
||||||
@ -1081,7 +1081,7 @@ typeof navigator === "object" && (function (global, factory) {
|
|||||||
set(input) {
|
set(input) {
|
||||||
if (player.quality === input) {
|
if (player.quality === input) {
|
||||||
return;
|
return;
|
||||||
} // If we're using an an external handler...
|
} // If we're using an external handler...
|
||||||
|
|
||||||
|
|
||||||
if (player.config.quality.forced && is.function(player.config.quality.onChange)) {
|
if (player.config.quality.forced && is.function(player.config.quality.onChange)) {
|
||||||
@ -1289,7 +1289,10 @@ typeof navigator === "object" && (function (global, factory) {
|
|||||||
|
|
||||||
extend(storage, object); // Update storage
|
extend(storage, object); // Update storage
|
||||||
|
|
||||||
window.localStorage.setItem(this.key, JSON.stringify(storage));
|
try {
|
||||||
|
window.localStorage.setItem(this.key, JSON.stringify(storage));
|
||||||
|
} catch (_) {// Do nothing
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.enabled = player.config.storage.enabled;
|
this.enabled = player.config.storage.enabled;
|
||||||
@ -1309,7 +1312,7 @@ typeof navigator === "object" && (function (global, factory) {
|
|||||||
window.localStorage.setItem(test, test);
|
window.localStorage.setItem(test, test);
|
||||||
window.localStorage.removeItem(test);
|
window.localStorage.removeItem(test);
|
||||||
return true;
|
return true;
|
||||||
} catch (e) {
|
} catch (_) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1333,7 +1336,7 @@ typeof navigator === "object" && (function (global, factory) {
|
|||||||
if (responseType === 'text') {
|
if (responseType === 'text') {
|
||||||
try {
|
try {
|
||||||
resolve(JSON.parse(request.responseText));
|
resolve(JSON.parse(request.responseText));
|
||||||
} catch (e) {
|
} catch (_) {
|
||||||
resolve(request.responseText);
|
resolve(request.responseText);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1347,8 +1350,8 @@ typeof navigator === "object" && (function (global, factory) {
|
|||||||
|
|
||||||
request.responseType = responseType;
|
request.responseType = responseType;
|
||||||
request.send();
|
request.send();
|
||||||
} catch (e) {
|
} catch (error) {
|
||||||
reject(e);
|
reject(error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1407,9 +1410,12 @@ typeof navigator === "object" && (function (global, factory) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (useStorage) {
|
if (useStorage) {
|
||||||
window.localStorage.setItem(`${prefix}-${id}`, JSON.stringify({
|
try {
|
||||||
content: result
|
window.localStorage.setItem(`${prefix}-${id}`, JSON.stringify({
|
||||||
}));
|
content: result
|
||||||
|
}));
|
||||||
|
} catch (_) {// Do nothing
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
update(container, result);
|
update(container, result);
|
||||||
@ -1453,7 +1459,8 @@ typeof navigator === "object" && (function (global, factory) {
|
|||||||
// Get icon URL
|
// Get icon URL
|
||||||
getIconUrl() {
|
getIconUrl() {
|
||||||
const url = new URL(this.config.iconUrl, window.location);
|
const url = new URL(this.config.iconUrl, window.location);
|
||||||
const cors = url.host !== window.location.host || browser.isIE && !window.svg4everybody;
|
const host = window.location.host ? window.location.host : window.top.location.host;
|
||||||
|
const cors = url.host !== host || browser.isIE && !window.svg4everybody;
|
||||||
return {
|
return {
|
||||||
url: this.config.iconUrl,
|
url: this.config.iconUrl,
|
||||||
cors
|
cors
|
||||||
@ -2941,7 +2948,7 @@ typeof navigator === "object" && (function (global, factory) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
return new URL(url);
|
return new URL(url);
|
||||||
} catch (e) {
|
} catch (_) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} // Convert object to URLSearchParams
|
} // Convert object to URLSearchParams
|
||||||
@ -3079,7 +3086,10 @@ typeof navigator === "object" && (function (global, factory) {
|
|||||||
} // Enable or disable captions based on track length
|
} // 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
|
if (this.elements) {
|
||||||
|
toggleClass(this.elements.container, this.config.classNames.captions.enabled, !is.empty(tracks));
|
||||||
|
} // Update available languages in list
|
||||||
|
|
||||||
|
|
||||||
if (is.array(this.config.controls) && this.config.controls.includes('settings') && this.config.settings.includes('captions')) {
|
if (is.array(this.config.controls) && this.config.controls.includes('settings') && this.config.settings.includes('captions')) {
|
||||||
controls.setCaptionsMenu.call(this);
|
controls.setCaptionsMenu.call(this);
|
||||||
@ -3362,7 +3372,7 @@ typeof navigator === "object" && (function (global, factory) {
|
|||||||
// Sprite (for icons)
|
// Sprite (for icons)
|
||||||
loadSprite: true,
|
loadSprite: true,
|
||||||
iconPrefix: 'plyr',
|
iconPrefix: 'plyr',
|
||||||
iconUrl: 'https://cdn.plyr.io/3.6.8/plyr.svg',
|
iconUrl: 'https://cdn.plyr.io/3.6.12/plyr.svg',
|
||||||
// Blank video (used to prevent errors on source change)
|
// Blank video (used to prevent errors on source change)
|
||||||
blankVideo: 'https://cdn.plyr.io/static/blank.mp4',
|
blankVideo: 'https://cdn.plyr.io/static/blank.mp4',
|
||||||
// Quality default
|
// Quality default
|
||||||
@ -3628,7 +3638,8 @@ typeof navigator === "object" && (function (global, factory) {
|
|||||||
attributes: {
|
attributes: {
|
||||||
embed: {
|
embed: {
|
||||||
provider: 'data-plyr-provider',
|
provider: 'data-plyr-provider',
|
||||||
id: 'data-plyr-embed-id'
|
id: 'data-plyr-embed-id',
|
||||||
|
hash: 'data-plyr-embed-hash'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// Advertisements plugin
|
// Advertisements plugin
|
||||||
@ -3989,7 +4000,7 @@ typeof navigator === "object" && (function (global, factory) {
|
|||||||
return hasClass(this.target, this.player.config.classNames.fullscreen.fallback);
|
return hasClass(this.target, this.player.config.classNames.fullscreen.fallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
const element = !this.prefix ? document.fullscreenElement : document[`${this.prefix}${this.property}Element`];
|
const element = !this.prefix ? this.target.getRootNode().fullscreenElement : this.target.getRootNode()[`${this.prefix}${this.property}Element`];
|
||||||
return element && element.shadowRoot ? element === this.target.getRootNode().host : element === this.target;
|
return element && element.shadowRoot ? element === this.target.getRootNode().host : element === this.target;
|
||||||
} // Get target element
|
} // Get target element
|
||||||
|
|
||||||
@ -4081,7 +4092,9 @@ typeof navigator === "object" && (function (global, factory) {
|
|||||||
|
|
||||||
controls.updateVolume.call(this); // Reset time display
|
controls.updateVolume.call(this); // Reset time display
|
||||||
|
|
||||||
controls.timeUpdate.call(this); // Update the UI
|
controls.timeUpdate.call(this); // Reset duration display
|
||||||
|
|
||||||
|
controls.durationUpdate.call(this); // Update the UI
|
||||||
|
|
||||||
ui.checkPlaying.call(this); // Check for picture-in-picture support
|
ui.checkPlaying.call(this); // Check for picture-in-picture support
|
||||||
|
|
||||||
@ -4160,14 +4173,14 @@ typeof navigator === "object" && (function (global, factory) {
|
|||||||
this.elements.poster.removeAttribute('hidden'); // Wait until ui is ready
|
this.elements.poster.removeAttribute('hidden'); // Wait until ui is ready
|
||||||
|
|
||||||
return ready.call(this) // Load image
|
return ready.call(this) // Load image
|
||||||
.then(() => loadImage(poster)).catch(err => {
|
.then(() => loadImage(poster)).catch(error => {
|
||||||
// Hide poster on error unless it's been set by another call
|
// Hide poster on error unless it's been set by another call
|
||||||
if (poster === this.poster) {
|
if (poster === this.poster) {
|
||||||
ui.togglePoster.call(this, false);
|
ui.togglePoster.call(this, false);
|
||||||
} // Rethrow
|
} // Rethrow
|
||||||
|
|
||||||
|
|
||||||
throw err;
|
throw error;
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
// Prevent race conditions
|
// Prevent race conditions
|
||||||
if (poster !== this.poster) {
|
if (poster !== this.poster) {
|
||||||
@ -4796,7 +4809,9 @@ typeof navigator === "object" && (function (global, factory) {
|
|||||||
if (elements.fullscreen) {
|
if (elements.fullscreen) {
|
||||||
Array.from(elements.fullscreen.children).filter(c => !c.contains(elements.container)).forEach(child => {
|
Array.from(elements.fullscreen.children).filter(c => !c.contains(elements.container)).forEach(child => {
|
||||||
this.bind(child, 'mouseenter mouseleave', event => {
|
this.bind(child, 'mouseenter mouseleave', event => {
|
||||||
elements.controls.hover = !player.touch && event.type === 'mouseenter';
|
if (elements.controls) {
|
||||||
|
elements.controls.hover = !player.touch && event.type === 'mouseenter';
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} // Update controls.pressed state (used for ui.toggleControls to avoid hiding when interacting)
|
} // Update controls.pressed state (used for ui.toggleControls to avoid hiding when interacting)
|
||||||
@ -5335,6 +5350,20 @@ typeof navigator === "object" && (function (global, factory) {
|
|||||||
|
|
||||||
const regex = /^.*(vimeo.com\/|video\/)(\d+).*/;
|
const regex = /^.*(vimeo.com\/|video\/)(\d+).*/;
|
||||||
return url.match(regex) ? RegExp.$2 : url;
|
return url.match(regex) ? RegExp.$2 : url;
|
||||||
|
} // Try to extract a hash for private videos from the URL
|
||||||
|
|
||||||
|
|
||||||
|
function parseHash(url) {
|
||||||
|
/* This regex matches a hexadecimal hash if given in any of these forms:
|
||||||
|
* - [https://player.]vimeo.com/video/{id}/{hash}[?params]
|
||||||
|
* - [https://player.]vimeo.com/video/{id}?h={hash}[¶ms]
|
||||||
|
* - [https://player.]vimeo.com/video/{id}?[params]&h={hash}
|
||||||
|
* - video/{id}/{hash}
|
||||||
|
* If matched, the hash is available in the named group `hash`
|
||||||
|
*/
|
||||||
|
const regex = /^.*(?:vimeo.com\/|video\/)(?:\d+)(?:\?.*&*h=|\/)+(?<hash>[\d,a-f]+)/;
|
||||||
|
const found = url.match(regex);
|
||||||
|
return found ? found.groups.hash : null;
|
||||||
} // Set playback state and trigger change (only on actual change)
|
} // Set playback state and trigger change (only on actual change)
|
||||||
|
|
||||||
|
|
||||||
@ -5378,7 +5407,22 @@ typeof navigator === "object" && (function (global, factory) {
|
|||||||
premium,
|
premium,
|
||||||
referrerPolicy,
|
referrerPolicy,
|
||||||
...frameParams
|
...frameParams
|
||||||
} = config; // If the owner has a pro or premium account then we can hide controls etc
|
} = config; // Get the source URL or ID
|
||||||
|
|
||||||
|
let source = player.media.getAttribute('src');
|
||||||
|
let hash = ''; // Get from <div> if needed
|
||||||
|
|
||||||
|
if (is.empty(source)) {
|
||||||
|
source = player.media.getAttribute(player.config.attributes.embed.id); // hash can also be set as attribute on the <div>
|
||||||
|
|
||||||
|
hash = player.media.getAttribute(player.config.attributes.embed.hash);
|
||||||
|
} else {
|
||||||
|
hash = parseHash(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
const hashParam = hash ? {
|
||||||
|
h: hash
|
||||||
|
} : {}; // If the owner has a pro or premium account then we can hide controls etc
|
||||||
|
|
||||||
if (premium) {
|
if (premium) {
|
||||||
Object.assign(frameParams, {
|
Object.assign(frameParams, {
|
||||||
@ -5394,15 +5438,10 @@ typeof navigator === "object" && (function (global, factory) {
|
|||||||
muted: player.muted,
|
muted: player.muted,
|
||||||
gesture: 'media',
|
gesture: 'media',
|
||||||
playsinline: !this.config.fullscreen.iosNative,
|
playsinline: !this.config.fullscreen.iosNative,
|
||||||
|
// hash has to be added to iframe-URL
|
||||||
|
...hashParam,
|
||||||
...frameParams
|
...frameParams
|
||||||
}); // Get the source URL or ID
|
});
|
||||||
|
|
||||||
let source = player.media.getAttribute('src'); // Get from <div> if needed
|
|
||||||
|
|
||||||
if (is.empty(source)) {
|
|
||||||
source = player.media.getAttribute(player.config.attributes.embed.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
const id = parseId$1(source); // Build an iframe
|
const id = parseId$1(source); // Build an iframe
|
||||||
|
|
||||||
const iframe = createElement('iframe');
|
const iframe = createElement('iframe');
|
||||||
@ -6261,8 +6300,8 @@ typeof navigator === "object" && (function (global, factory) {
|
|||||||
|
|
||||||
request.setAdWillPlayMuted(!this.player.muted);
|
request.setAdWillPlayMuted(!this.player.muted);
|
||||||
this.loader.requestAds(request);
|
this.loader.requestAds(request);
|
||||||
} catch (e) {
|
} catch (error) {
|
||||||
this.onAdError(e);
|
this.onAdError(error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -6773,13 +6812,13 @@ typeof navigator === "object" && (function (global, factory) {
|
|||||||
});
|
});
|
||||||
} // VTT urls
|
} // VTT urls
|
||||||
else {
|
else {
|
||||||
// If string, convert into single-element list
|
// If string, convert into single-element list
|
||||||
const urls = is.string(src) ? [src] : src; // Loop through each src URL. Download and process the VTT file, storing the resulting data in this.thumbnails
|
const urls = is.string(src) ? [src] : src; // Loop through each src URL. Download and process the VTT file, storing the resulting data in this.thumbnails
|
||||||
|
|
||||||
const promises = urls.map(u => this.getThumbnail(u)); // Resolve
|
const promises = urls.map(u => this.getThumbnail(u)); // Resolve
|
||||||
|
|
||||||
Promise.all(promises).then(sortAndResolve);
|
Promise.all(promises).then(sortAndResolve);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -7689,7 +7728,7 @@ typeof navigator === "object" && (function (global, factory) {
|
|||||||
this.config = extend({}, defaults, Plyr.defaults, options || {}, (() => {
|
this.config = extend({}, defaults, Plyr.defaults, options || {}, (() => {
|
||||||
try {
|
try {
|
||||||
return JSON.parse(this.media.getAttribute('data-plyr-config'));
|
return JSON.parse(this.media.getAttribute('data-plyr-config'));
|
||||||
} catch (e) {
|
} catch (_) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
})()); // Elements cache
|
})()); // Elements cache
|
||||||
@ -8196,7 +8235,9 @@ typeof navigator === "object" && (function (global, factory) {
|
|||||||
this.config.speed.selected = speed; // Set media speed
|
this.config.speed.selected = speed; // Set media speed
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.media.playbackRate = speed;
|
if (this.media) {
|
||||||
|
this.media.playbackRate = speed;
|
||||||
|
}
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -8481,6 +8522,7 @@ typeof navigator === "object" && (function (global, factory) {
|
|||||||
|
|
||||||
set currentTrack(input) {
|
set currentTrack(input) {
|
||||||
captions.set.call(this, input, false);
|
captions.set.call(this, input, false);
|
||||||
|
captions.setup();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Get the current caption track index (-1 if disabled)
|
* Get the current caption track index (-1 if disabled)
|
||||||
@ -8560,6 +8602,23 @@ typeof navigator === "object" && (function (global, factory) {
|
|||||||
|
|
||||||
return this.media === document.pictureInPictureElement;
|
return this.media === document.pictureInPictureElement;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Sets the preview thubmnails for the current source
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
setPreviewThumbnails(thumbnailSource) {
|
||||||
|
if (this.previewThumbnails && this.previewThumbnails.loaded) {
|
||||||
|
this.previewThumbnails.destroy();
|
||||||
|
this.previewThumbnails = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object.assign(this.config.previewThumbnails, thumbnailSource); // Create new instance if it is still enabled
|
||||||
|
|
||||||
|
if (this.config.previewThumbnails.enabled) {
|
||||||
|
this.previewThumbnails = new PreviewThumbnails(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Trigger the airplay dialog
|
* Trigger the airplay dialog
|
||||||
* TODO: update player with state, support, enabled
|
* TODO: update player with state, support, enabled
|
||||||
@ -8616,4 +8675,4 @@ typeof navigator === "object" && (function (global, factory) {
|
|||||||
|
|
||||||
return Plyr;
|
return Plyr;
|
||||||
|
|
||||||
})));
|
}));
|
||||||
|
3
youtube/static/modules/plyr/plyr.min.js
vendored
3
youtube/static/modules/plyr/plyr.min.js
vendored
File diff suppressed because one or more lines are too long
@ -58,7 +58,7 @@
|
|||||||
{% if settings.use_video_player == 2 %}
|
{% if settings.use_video_player == 2 %}
|
||||||
<!-- plyr -->
|
<!-- plyr -->
|
||||||
<script src="/youtube.com/static/modules/plyr/plyr.min.js"
|
<script src="/youtube.com/static/modules/plyr/plyr.min.js"
|
||||||
integrity="sha512-0JWbXvmMLCb9fsWBlcStfEdREgVEpfT0lSgJ5JemQXZJUE5W33gnLmUqxyww7xT8ESgA+YtAtBbn8O3tgYnSQg=="
|
integrity="sha512-LxQ9i36iGcbP3sgBvQQgt1nDE72qX7Vtj5+dRDKDTQ+cQVxaMRabWY2dEs8ccL4Zp5JoDd66FAPhzk8n2Wkfdw=="
|
||||||
crossorigin="anonymous"></script>
|
crossorigin="anonymous"></script>
|
||||||
<script src="/youtube.com/static/js/plyr-start.js"></script>
|
<script src="/youtube.com/static/js/plyr-start.js"></script>
|
||||||
<!-- /plyr -->
|
<!-- /plyr -->
|
||||||
|
@ -245,7 +245,7 @@
|
|||||||
{% if settings.use_video_player == 2 %}
|
{% if settings.use_video_player == 2 %}
|
||||||
<!-- plyr -->
|
<!-- plyr -->
|
||||||
<script src="/youtube.com/static/modules/plyr/plyr.min.js"
|
<script src="/youtube.com/static/modules/plyr/plyr.min.js"
|
||||||
integrity="sha512-0JWbXvmMLCb9fsWBlcStfEdREgVEpfT0lSgJ5JemQXZJUE5W33gnLmUqxyww7xT8ESgA+YtAtBbn8O3tgYnSQg=="
|
integrity="sha512-LxQ9i36iGcbP3sgBvQQgt1nDE72qX7Vtj5+dRDKDTQ+cQVxaMRabWY2dEs8ccL4Zp5JoDd66FAPhzk8n2Wkfdw=="
|
||||||
crossorigin="anonymous"></script>
|
crossorigin="anonymous"></script>
|
||||||
<script src="/youtube.com/static/js/plyr-start.js"></script>
|
<script src="/youtube.com/static/js/plyr-start.js"></script>
|
||||||
<!-- /plyr -->
|
<!-- /plyr -->
|
||||||
|
Loading…
x
Reference in New Issue
Block a user