Skip to content

Commit

Permalink
Merge pull request #39 from jonnitto/dependabot/npm_and_yarn/plyr-3.5.8
Browse files Browse the repository at this point in the history
⬆️ Bump plyr from 3.5.7 to 3.5.8
  • Loading branch information
jonnitto authored Feb 11, 2020
2 parents 2d72093 + 397e6a0 commit e2cdb63
Show file tree
Hide file tree
Showing 38 changed files with 628 additions and 489 deletions.
5 changes: 5 additions & 0 deletions Resources/Private/Assets/Scripts/config/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,11 @@ const defaults = {
title: false,
speed: true,
transparent: false,
// These settings require a pro or premium account to work
sidedock: false,
controls: false,
// Custom settings from Plyr
referrerPolicy: null, // https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/referrerPolicy
},

// YouTube plugin
Expand Down
11 changes: 3 additions & 8 deletions Resources/Private/Assets/Scripts/controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import captions from './captions';
import html5 from './html5';
import support from './support';
import { repaint, transitionEndEvent } from './utils/animation';
import { dedupe, fillRange } from './utils/arrays';
import { dedupe } from './utils/arrays';
import browser from './utils/browser';
import {
createElement,
Expand Down Expand Up @@ -1053,13 +1053,8 @@ const controls = {
const type = 'speed';
const list = this.elements.settings.panels.speed.querySelector('[role="menu"]');

// Determine options to display
// Vimeo and YouTube limit to 0.5x-2x
if (this.isVimeo || this.isYouTube) {
this.options.speed = fillRange(0.5, 2, 0.25).filter(s => this.config.speed.options.includes(s));
} else {
this.options.speed = this.config.speed.options;
}
// Filter out invalid speeds
this.options.speed = this.options.speed.filter(o => o >= this.minimumSpeed && o <= this.maximumSpeed);

// Toggle the pane and tab
const toggle = !is.empty(this.options.speed) && this.options.speed.length > 1;
Expand Down
6 changes: 4 additions & 2 deletions Resources/Private/Assets/Scripts/html5.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,16 @@ const html5 = {
.filter(Boolean);
},

extend() {
setup() {
if (!this.isHTML5) {
return;
}

const player = this;

// Set speed options from config
player.options.speed = player.config.speed.options;

// Set aspect ratio if fixed
if (!is.empty(this.config.ratio)) {
setAspectRatio.call(player);
Expand Down Expand Up @@ -93,7 +96,6 @@ const html5 = {
if (preload !== 'none' || readyState) {
// Restore time
player.once('loadedmetadata', () => {

player.speed = playbackRate;
player.currentTime = currentTime;

Expand Down
2 changes: 1 addition & 1 deletion Resources/Private/Assets/Scripts/media.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const media = {
}

if (this.isHTML5) {
html5.extend.call(this);
html5.setup.call(this);
} else if (this.isYouTube) {
youtube.setup.call(this);
} else if (this.isVimeo) {
Expand Down
24 changes: 22 additions & 2 deletions Resources/Private/Assets/Scripts/plugins/preview-thumbnails.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class PreviewThumbnails {
}

load() {
// Togglethe regular seek tooltip
// Toggle the regular seek tooltip
if (this.player.elements.display.seekTooltip) {
this.player.elements.display.seekTooltip.hidden = this.enabled;
}
Expand Down Expand Up @@ -328,6 +328,15 @@ class PreviewThumbnails {
this.player.elements.wrapper.appendChild(this.elements.scrubbing.container);
}

destroy() {
if (this.elements.thumb.container) {
this.elements.thumb.container.remove();
}
if (this.elements.scrubbing.container) {
this.elements.scrubbing.container.remove();
}
}

showImageAtCurrentTime() {
if (this.mouseDown) {
this.setScrubbingContainerSize();
Expand Down Expand Up @@ -561,6 +570,11 @@ class PreviewThumbnails {
return height;
}

// If css is used this needs to return the css height for sprites to work (see setImageSizeAndOffset)
if (this.sizeSpecifiedInCSS) {
return this.elements.thumb.imageContainer.clientHeight;
}

return Math.floor(this.player.media.clientWidth / this.thumbAspectRatio / 4);
}

Expand Down Expand Up @@ -601,7 +615,7 @@ class PreviewThumbnails {
}

determineContainerAutoSizing() {
if (this.elements.thumb.imageContainer.clientHeight > 20) {
if (this.elements.thumb.imageContainer.clientHeight > 20 || this.elements.thumb.imageContainer.clientWidth > 20) {
// This will prevent auto sizing in this.setThumbContainerSizeAndPos()
this.sizeSpecifiedInCSS = true;
}
Expand All @@ -613,6 +627,12 @@ class PreviewThumbnails {
const thumbWidth = Math.floor(this.thumbContainerHeight * this.thumbAspectRatio);
this.elements.thumb.imageContainer.style.height = `${this.thumbContainerHeight}px`;
this.elements.thumb.imageContainer.style.width = `${thumbWidth}px`;
} else if (this.elements.thumb.imageContainer.clientHeight > 20 && this.elements.thumb.imageContainer.clientWidth < 20) {
const thumbWidth = Math.floor(this.elements.thumb.imageContainer.clientHeight * this.thumbAspectRatio);
this.elements.thumb.imageContainer.style.width = `${thumbWidth}px`;
} else if (this.elements.thumb.imageContainer.clientHeight < 20 && this.elements.thumb.imageContainer.clientWidth > 20) {
const thumbHeight = Math.floor(this.elements.thumb.imageContainer.clientWidth / this.thumbAspectRatio);
this.elements.thumb.imageContainer.style.height = `${thumbHeight}px`;
}

this.setThumbContainerPos();
Expand Down
32 changes: 20 additions & 12 deletions Resources/Private/Assets/Scripts/plugins/vimeo.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,28 @@ function assurePlaybackState(play) {

const vimeo = {
setup() {
const player = this;

// Add embed class for responsive
toggleClass(this.elements.wrapper, this.config.classNames.embed, true);
toggleClass(player.elements.wrapper, player.config.classNames.embed, true);

// Set speed options from config
player.options.speed = player.config.speed.options;

// Set intial ratio
setAspectRatio.call(this);
setAspectRatio.call(player);

// Load the SDK if not already
if (!is.object(window.Vimeo)) {
loadScript(this.config.urls.vimeo.sdk)
loadScript(player.config.urls.vimeo.sdk)
.then(() => {
vimeo.ready.call(this);
vimeo.ready.call(player);
})
.catch(error => {
this.debug.warn('Vimeo SDK (player.js) failed to load', error);
player.debug.warn('Vimeo SDK (player.js) failed to load', error);
});
} else {
vimeo.ready.call(this);
vimeo.ready.call(player);
}
},

Expand Down Expand Up @@ -99,6 +104,11 @@ const vimeo = {
iframe.setAttribute('allowtransparency', '');
iframe.setAttribute('allow', 'autoplay');

// Set the referrer policy if required
if (!is.empty(config.referrerPolicy)) {
iframe.setAttribute('referrerPolicy', config.referrerPolicy);
}

// Get poster, if already set
const { poster } = player;
// Inject the package
Expand Down Expand Up @@ -191,12 +201,10 @@ const vimeo = {
return speed;
},
set(input) {
player.embed
.setPlaybackRate(input)
.then(() => {
speed = input;
triggerEvent.call(player, player.media, 'ratechange');
});
player.embed.setPlaybackRate(input).then(() => {
speed = input;
triggerEvent.call(player, player.media, 'ratechange');
});
},
});

Expand Down
4 changes: 3 additions & 1 deletion Resources/Private/Assets/Scripts/plugins/youtube.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,9 @@ const youtube = {
});

// Get available speeds
player.options.speed = instance.getAvailablePlaybackRates();
const speeds = instance.getAvailablePlaybackRates();
// Filter based on config
player.options.speed = speeds.filter(s => player.config.speed.options.includes(s));

// Set the tabindex to avoid focus entering iframe
if (player.supported.ui) {
Expand Down
2 changes: 1 addition & 1 deletion Resources/Private/Assets/Scripts/plyr.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ==========================================================================
// Plyr
// plyr.js v3.5.7
// plyr.js v3.5.8
// https://github.com/sampotts/plyr
// License: The MIT License (MIT)
// ==========================================================================
Expand Down
2 changes: 1 addition & 1 deletion Resources/Private/Assets/Scripts/plyr.polyfilled.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ==========================================================================
// Plyr Polyfilled Build
// plyr.js v3.5.7
// plyr.js v3.5.8
// https://github.com/sampotts/plyr
// License: The MIT License (MIT)
// ==========================================================================
Expand Down
18 changes: 15 additions & 3 deletions Resources/Private/Assets/Scripts/source.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import { providers } from './config/types';
import html5 from './html5';
import media from './media';
import PreviewThumbnails from './plugins/preview-thumbnails';
import support from './support';
import ui from './ui';
import { createElement, insertElement, removeElement } from './utils/elements';
Expand Down Expand Up @@ -130,9 +131,20 @@ const source = {
this.media.load();
}

// Reload thumbnails
if (this.previewThumbnails) {
this.previewThumbnails.load();
// Update previewThumbnails config & reload plugin
if (!is.empty(input.previewThumbnails)) {
Object.assign(this.config.previewThumbnails, input.previewThumbnails);

// Cleanup previewThumbnails plugin if it was loaded
if (this.previewThumbnails && this.previewThumbnails.loaded) {
this.previewThumbnails.destroy();
this.previewThumbnails = null;
}

// Create new instance if it is still enabled
if (this.config.previewThumbnails.enabled) {
this.previewThumbnails = new PreviewThumbnails(this);
}
}

// Update the fullscreen support
Expand Down
8 changes: 0 additions & 8 deletions Resources/Private/Assets/Scripts/utils/arrays.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,3 @@ export function closest(array, value) {

return array.reduce((prev, curr) => (Math.abs(curr - value) < Math.abs(prev - value) ? curr : prev));
}

export function fillRange(start, end, step = 1) {
const len = Math.floor((end - start) / step) + 1;

return Array(len)
.fill()
.map((_, idx) => start + idx * step);
}
1 change: 1 addition & 0 deletions Resources/Private/Assets/Styles/base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
align-items: center;
direction: ltr;
display: flex;
flex-direction: column;
font-family: $plyr-font-family;
font-variant-numeric: tabular-nums; // Force monosace-esque number widths
font-weight: $plyr-font-weight-regular;
Expand Down
7 changes: 0 additions & 7 deletions Resources/Private/Assets/Styles/components/audio.scss

This file was deleted.

56 changes: 0 additions & 56 deletions Resources/Private/Assets/Styles/components/control.scss
Original file line number Diff line number Diff line change
Expand Up @@ -50,59 +50,3 @@ a.plyr__control {
.plyr__control.plyr__control--pressed .label--not-pressed {
display: none;
}

// Audio control
.plyr--audio .plyr__control {
&.plyr__tab-focus,
&:hover,
&[aria-expanded='true'] {
background: $plyr-audio-control-bg-hover;
color: $plyr-audio-control-color-hover;
}
}

// Video control
.plyr--video .plyr__control {
// Hover and tab focus
&.plyr__tab-focus,
&:hover,
&[aria-expanded='true'] {
background: $plyr-video-control-bg-hover;
color: $plyr-video-control-color-hover;
}
}

// Large play button (video only)
.plyr__control--overlaid {
background: rgba($plyr-video-control-bg-hover, 0.8);
border: 0;
border-radius: 100%;
color: $plyr-video-control-color;
display: none;
left: 50%;
padding: ceil($plyr-control-spacing * 1.5);
position: absolute;
top: 50%;
transform: translate(-50%, -50%);
z-index: 2;

// Offset icon to make the play button look right
svg {
left: 2px;
position: relative;
}

&:hover,
&:focus {
background: $plyr-video-control-bg-hover;
}
}

.plyr--playing .plyr__control--overlaid {
opacity: 0;
visibility: hidden;
}

.plyr--full-ui.plyr--video .plyr__control--overlaid {
display: block;
}
34 changes: 0 additions & 34 deletions Resources/Private/Assets/Styles/components/controls.scss
Original file line number Diff line number Diff line change
Expand Up @@ -49,40 +49,6 @@
}
}

// Audio controls
.plyr--audio .plyr__controls {
background: $plyr-audio-controls-bg;
border-radius: inherit;
color: $plyr-audio-control-color;
padding: $plyr-control-spacing;
}

// Video controls
.plyr--video .plyr__controls {
background: linear-gradient(rgba($plyr-video-controls-bg, 0), rgba($plyr-video-controls-bg, 0.7));
border-bottom-left-radius: inherit;
border-bottom-right-radius: inherit;
bottom: 0;
color: $plyr-video-control-color;
left: 0;
padding: ($plyr-control-spacing * 2) ($plyr-control-spacing / 2) ($plyr-control-spacing / 2);
position: absolute;
right: 0;
transition: opacity 0.4s ease-in-out, transform 0.4s ease-in-out;
z-index: 3;

@media (min-width: $plyr-bp-sm) {
padding: ($plyr-control-spacing * 3.5) $plyr-control-spacing $plyr-control-spacing;
}
}

// Hide video controls
.plyr--video.plyr--hide-controls .plyr__controls {
opacity: 0;
pointer-events: none;
transform: translateY(100%);
}

// Some options are hidden by default
.plyr [data-plyr='captions'],
.plyr [data-plyr='pip'],
Expand Down
Loading

0 comments on commit e2cdb63

Please sign in to comment.