Remove line breaks in arrays
This commit is contained in:
parent
99ac8d4c52
commit
6bff6b317d
@ -48,10 +48,7 @@ const captions = {
|
|||||||
const src = track.getAttribute('src');
|
const src = track.getAttribute('src');
|
||||||
const url = parseUrl(src);
|
const url = parseUrl(src);
|
||||||
|
|
||||||
if (url !== null && url.hostname !== window.location.href.hostname && [
|
if (url !== null && url.hostname !== window.location.href.hostname && ['http:', 'https:'].includes(url.protocol)) {
|
||||||
'http:',
|
|
||||||
'https:',
|
|
||||||
].includes(url.protocol)) {
|
|
||||||
fetch(src, 'blob')
|
fetch(src, 'blob')
|
||||||
.then(blob => {
|
.then(blob => {
|
||||||
track.setAttribute('src', window.URL.createObjectURL(blob));
|
track.setAttribute('src', window.URL.createObjectURL(blob));
|
||||||
@ -202,10 +199,9 @@ const captions = {
|
|||||||
const tracks = Array.from((this.media || {}).textTracks || []);
|
const tracks = Array.from((this.media || {}).textTracks || []);
|
||||||
// For HTML5, use cache instead of current tracks when it exists (if captions.update is false)
|
// For HTML5, use cache instead of current tracks when it exists (if captions.update is false)
|
||||||
// Filter out removed tracks and tracks that aren't captions/subtitles (for example metadata)
|
// Filter out removed tracks and tracks that aren't captions/subtitles (for example metadata)
|
||||||
return tracks.filter(track => !this.isHTML5 || update || this.captions.meta.has(track)).filter(track => [
|
return tracks
|
||||||
'captions',
|
.filter(track => !this.isHTML5 || update || this.captions.meta.has(track))
|
||||||
'subtitles',
|
.filter(track => ['captions', 'subtitles'].includes(track.kind));
|
||||||
].includes(track.kind));
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// Get the current track for the current language
|
// Get the current track for the current language
|
||||||
|
@ -89,15 +89,7 @@ const defaults = {
|
|||||||
// Speed default and options to display
|
// Speed default and options to display
|
||||||
speed: {
|
speed: {
|
||||||
selected: 1,
|
selected: 1,
|
||||||
options: [
|
options: [0.5, 0.75, 1, 1.25, 1.5, 1.75, 2],
|
||||||
0.5,
|
|
||||||
0.75,
|
|
||||||
1,
|
|
||||||
1.25,
|
|
||||||
1.5,
|
|
||||||
1.75,
|
|
||||||
2,
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// Keyboard shortcut settings
|
// Keyboard shortcut settings
|
||||||
@ -151,11 +143,7 @@ const defaults = {
|
|||||||
'airplay',
|
'airplay',
|
||||||
'fullscreen',
|
'fullscreen',
|
||||||
],
|
],
|
||||||
settings: [
|
settings: ['captions', 'quality', 'speed'],
|
||||||
'captions',
|
|
||||||
'quality',
|
|
||||||
'speed',
|
|
||||||
],
|
|
||||||
|
|
||||||
// Localisation
|
// Localisation
|
||||||
i18n: {
|
i18n: {
|
||||||
|
38
src/js/controls.js
vendored
38
src/js/controls.js
vendored
@ -580,10 +580,7 @@ const controls = {
|
|||||||
|
|
||||||
// Show/hide the tooltip
|
// Show/hide the tooltip
|
||||||
// If the event is a moues in/out and percentage is inside bounds
|
// If the event is a moues in/out and percentage is inside bounds
|
||||||
if (is.event(event) && [
|
if (is.event(event) && ['mouseenter', 'mouseleave'].includes(event.type)) {
|
||||||
'mouseenter',
|
|
||||||
'mouseleave',
|
|
||||||
].includes(event.type)) {
|
|
||||||
toggle(event.type === 'mouseenter');
|
toggle(event.type === 'mouseenter');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -888,15 +885,7 @@ const controls = {
|
|||||||
if (is.array(options)) {
|
if (is.array(options)) {
|
||||||
this.options.speed = options;
|
this.options.speed = options;
|
||||||
} else if (this.isHTML5 || this.isVimeo) {
|
} else if (this.isHTML5 || this.isVimeo) {
|
||||||
this.options.speed = [
|
this.options.speed = [0.5, 0.75, 1, 1.25, 1.5, 1.75, 2];
|
||||||
0.5,
|
|
||||||
0.75,
|
|
||||||
1,
|
|
||||||
1.25,
|
|
||||||
1.5,
|
|
||||||
1.75,
|
|
||||||
2,
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set options if passed and filter based on config
|
// Set options if passed and filter based on config
|
||||||
@ -1054,10 +1043,7 @@ const controls = {
|
|||||||
// Restore auto height/width
|
// Restore auto height/width
|
||||||
const restore = e => {
|
const restore = e => {
|
||||||
// We're only bothered about height and width on the container
|
// We're only bothered about height and width on the container
|
||||||
if (e.target !== container || ![
|
if (e.target !== container || !['width', 'height'].includes(e.propertyName)) {
|
||||||
'width',
|
|
||||||
'height',
|
|
||||||
].includes(e.propertyName)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1404,10 +1390,7 @@ const controls = {
|
|||||||
const replace = input => {
|
const replace = input => {
|
||||||
let result = input;
|
let result = input;
|
||||||
|
|
||||||
Object.entries(props).forEach(([
|
Object.entries(props).forEach(([key, value]) => {
|
||||||
key,
|
|
||||||
value,
|
|
||||||
]) => {
|
|
||||||
result = replaceAll(result, `{${key}}`, value);
|
result = replaceAll(result, `{${key}}`, value);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1455,16 +1438,9 @@ const controls = {
|
|||||||
|
|
||||||
// Setup tooltips
|
// Setup tooltips
|
||||||
if (this.config.tooltips.controls) {
|
if (this.config.tooltips.controls) {
|
||||||
const labels = getElements.call(
|
const { classNames, selectors } = this.config;
|
||||||
this,
|
const selector = `${selectors.controls.wrapper} ${selectors.labels} .${classNames.hidden}`;
|
||||||
[
|
const labels = getElements.call(this, selector);
|
||||||
this.config.selectors.controls.wrapper,
|
|
||||||
' ',
|
|
||||||
this.config.selectors.labels,
|
|
||||||
' .',
|
|
||||||
this.config.classNames.hidden,
|
|
||||||
].join(''),
|
|
||||||
);
|
|
||||||
|
|
||||||
Array.from(labels).forEach(label => {
|
Array.from(labels).forEach(label => {
|
||||||
toggleClass(label, this.config.classNames.hidden, false);
|
toggleClass(label, this.config.classNames.hidden, false);
|
||||||
|
@ -96,11 +96,7 @@ class Fullscreen {
|
|||||||
|
|
||||||
// Check for fullscreen support by vendor prefix
|
// Check for fullscreen support by vendor prefix
|
||||||
let value = '';
|
let value = '';
|
||||||
const prefixes = [
|
const prefixes = ['webkit', 'moz', 'ms'];
|
||||||
'webkit',
|
|
||||||
'moz',
|
|
||||||
'ms',
|
|
||||||
];
|
|
||||||
|
|
||||||
prefixes.some(pre => {
|
prefixes.some(pre => {
|
||||||
if (is.function(document[`${pre}ExitFullscreen`]) || is.function(document[`${pre}CancelFullScreen`])) {
|
if (is.function(document[`${pre}ExitFullscreen`]) || is.function(document[`${pre}CancelFullScreen`])) {
|
||||||
|
@ -23,10 +23,7 @@ const i18n = {
|
|||||||
'{title}': config.title,
|
'{title}': config.title,
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.entries(replace).forEach(([
|
Object.entries(replace).forEach(([key, value]) => {
|
||||||
key,
|
|
||||||
value,
|
|
||||||
]) => {
|
|
||||||
string = replaceAll(string, key, value);
|
string = replaceAll(string, key, value);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -46,29 +46,7 @@ class Listeners {
|
|||||||
// Reset on keyup
|
// Reset on keyup
|
||||||
if (pressed) {
|
if (pressed) {
|
||||||
// Which keycodes should we prevent default
|
// Which keycodes should we prevent default
|
||||||
const preventDefault = [
|
const preventDefault = [32, 37, 38, 39, 40, 48, 49, 50, 51, 52, 53, 54, 56, 57, 67, 70, 73, 75, 76, 77, 79];
|
||||||
48,
|
|
||||||
49,
|
|
||||||
50,
|
|
||||||
51,
|
|
||||||
52,
|
|
||||||
53,
|
|
||||||
54,
|
|
||||||
56,
|
|
||||||
57,
|
|
||||||
32,
|
|
||||||
75,
|
|
||||||
38,
|
|
||||||
40,
|
|
||||||
77,
|
|
||||||
39,
|
|
||||||
37,
|
|
||||||
70,
|
|
||||||
67,
|
|
||||||
73,
|
|
||||||
76,
|
|
||||||
79,
|
|
||||||
];
|
|
||||||
|
|
||||||
// Check focused element
|
// Check focused element
|
||||||
// and if the focused element is not editable (e.g. text input)
|
// and if the focused element is not editable (e.g. text input)
|
||||||
@ -249,11 +227,7 @@ class Listeners {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Show, then hide after a timeout unless another control event occurs
|
// Show, then hide after a timeout unless another control event occurs
|
||||||
const show = [
|
const show = ['touchstart', 'touchmove', 'mousemove'].includes(event.type);
|
||||||
'touchstart',
|
|
||||||
'touchmove',
|
|
||||||
'mousemove',
|
|
||||||
].includes(event.type);
|
|
||||||
|
|
||||||
let delay = 0;
|
let delay = 0;
|
||||||
|
|
||||||
@ -407,10 +381,8 @@ class Listeners {
|
|||||||
|
|
||||||
// Proxy events to container
|
// Proxy events to container
|
||||||
// Bubble up key events for Edge
|
// Bubble up key events for Edge
|
||||||
on.call(this.player, this.player.media, this.player.config.events.concat([
|
const proxyEvents = this.player.config.events.concat(['keyup', 'keydown']).join(' ');
|
||||||
'keyup',
|
on.call(this.player, this.player.media, proxyEvents, event => {
|
||||||
'keydown',
|
|
||||||
]).join(' '), event => {
|
|
||||||
let {detail = {}} = event;
|
let {detail = {}} = event;
|
||||||
|
|
||||||
// Get error details from media
|
// Get error details from media
|
||||||
@ -572,11 +544,7 @@ class Listeners {
|
|||||||
const play = seek.hasAttribute('play-on-seeked');
|
const play = seek.hasAttribute('play-on-seeked');
|
||||||
|
|
||||||
// Done seeking
|
// Done seeking
|
||||||
const done = [
|
const done = ['mouseup', 'touchend', 'keyup'].includes(event.type);
|
||||||
'mouseup',
|
|
||||||
'touchend',
|
|
||||||
'keyup',
|
|
||||||
].includes(event.type);
|
|
||||||
|
|
||||||
// If we're done seeking and it was playing, resume playback
|
// If we're done seeking and it was playing, resume playback
|
||||||
if (play && done) {
|
if (play && done) {
|
||||||
@ -651,10 +619,7 @@ class Listeners {
|
|||||||
|
|
||||||
// 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)
|
||||||
bind(this.player.elements.controls, 'mousedown mouseup touchstart touchend touchcancel', event => {
|
bind(this.player.elements.controls, 'mousedown mouseup touchstart touchend touchcancel', event => {
|
||||||
this.player.elements.controls.pressed = [
|
this.player.elements.controls.pressed = ['mousedown', 'touchstart'].includes(event.type);
|
||||||
'mousedown',
|
|
||||||
'touchstart',
|
|
||||||
].includes(event.type);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Focus in/out on controls
|
// Focus in/out on controls
|
||||||
|
@ -70,8 +70,8 @@ const vimeo = {
|
|||||||
// Set aspect ratio
|
// Set aspect ratio
|
||||||
// For Vimeo we have an extra 300% height <div> to hide the standard controls and UI
|
// For Vimeo we have an extra 300% height <div> to hide the standard controls and UI
|
||||||
setAspectRatio(input) {
|
setAspectRatio(input) {
|
||||||
const ratio = is.string(input) ? input.split(':') : this.config.ratio.split(':');
|
const [x, y] = (is.string(input) ? input : this.config.ratio).split(':');
|
||||||
const padding = 100 / ratio[0] * ratio[1];
|
const padding = 100 / x * y;
|
||||||
this.elements.wrapper.style.paddingBottom = `${padding}%`;
|
this.elements.wrapper.style.paddingBottom = `${padding}%`;
|
||||||
|
|
||||||
if (this.supported.ui) {
|
if (this.supported.ui) {
|
||||||
@ -294,10 +294,7 @@ const vimeo = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Set aspect ratio based on video size
|
// Set aspect ratio based on video size
|
||||||
Promise.all([
|
Promise.all([player.embed.getVideoWidth(), player.embed.getVideoHeight()]).then(dimensions => {
|
||||||
player.embed.getVideoWidth(),
|
|
||||||
player.embed.getVideoHeight(),
|
|
||||||
]).then(dimensions => {
|
|
||||||
const ratio = getAspectRatio(dimensions[0], dimensions[1]);
|
const ratio = getAspectRatio(dimensions[0], dimensions[1]);
|
||||||
vimeo.setAspectRatio.call(this, ratio);
|
vimeo.setAspectRatio.call(this, ratio);
|
||||||
});
|
});
|
||||||
|
@ -408,10 +408,7 @@ const youtube = {
|
|||||||
// Reset timer
|
// Reset timer
|
||||||
clearInterval(player.timers.playing);
|
clearInterval(player.timers.playing);
|
||||||
|
|
||||||
const seeked = player.media.seeking && [
|
const seeked = player.media.seeking && [1, 2].includes(event.data);
|
||||||
1,
|
|
||||||
2,
|
|
||||||
].includes(event.data);
|
|
||||||
|
|
||||||
if (seeked) {
|
if (seeked) {
|
||||||
// Unset seeking and fire seeked event
|
// Unset seeking and fire seeked event
|
||||||
|
@ -172,10 +172,7 @@ class Plyr {
|
|||||||
|
|
||||||
// Get attributes from URL and set config
|
// Get attributes from URL and set config
|
||||||
if (url.searchParams.length) {
|
if (url.searchParams.length) {
|
||||||
const truthy = [
|
const truthy = ['1', 'true'];
|
||||||
'1',
|
|
||||||
'true',
|
|
||||||
];
|
|
||||||
|
|
||||||
if (truthy.includes(url.searchParams.get('autoplay'))) {
|
if (truthy.includes(url.searchParams.get('autoplay'))) {
|
||||||
this.config.autoplay = true;
|
this.config.autoplay = true;
|
||||||
@ -682,12 +679,7 @@ class Plyr {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let quality = ([
|
let quality = [!is.empty(input) && Number(input), this.storage.get('quality'), config.selected, config.default].find(is.number);
|
||||||
!is.empty(input) && Number(input),
|
|
||||||
this.storage.get('quality'),
|
|
||||||
config.selected,
|
|
||||||
config.default,
|
|
||||||
]).find(is.number);
|
|
||||||
|
|
||||||
if (!options.includes(quality)) {
|
if (!options.includes(quality)) {
|
||||||
const value = closest(options, quality);
|
const value = closest(options, quality);
|
||||||
|
@ -212,10 +212,7 @@ const ui = {
|
|||||||
|
|
||||||
// Check if media is loading
|
// Check if media is loading
|
||||||
checkLoading(event) {
|
checkLoading(event) {
|
||||||
this.loading = [
|
this.loading = ['stalled', 'waiting'].includes(event.type);
|
||||||
'stalled',
|
|
||||||
'waiting',
|
|
||||||
].includes(event.type);
|
|
||||||
|
|
||||||
// Clear timer
|
// Clear timer
|
||||||
clearTimeout(this.timers.loading);
|
clearTimeout(this.timers.loading);
|
||||||
|
@ -42,10 +42,7 @@ export function setAttributes(element, attributes) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.entries(attributes).forEach(([
|
Object.entries(attributes).forEach(([key, value]) => {
|
||||||
key,
|
|
||||||
value,
|
|
||||||
]) => {
|
|
||||||
element.setAttribute(key, value);
|
element.setAttribute(key, value);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -30,10 +30,7 @@ export function buildUrlParams(input) {
|
|||||||
const params = new URLSearchParams();
|
const params = new URLSearchParams();
|
||||||
|
|
||||||
if (is.object(input)) {
|
if (is.object(input)) {
|
||||||
Object.entries(input).forEach(([
|
Object.entries(input).forEach(([key, value]) => {
|
||||||
key,
|
|
||||||
value,
|
|
||||||
]) => {
|
|
||||||
params.set(key, value);
|
params.set(key, value);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user