Compare commits
28 Commits
Author | SHA1 | Date | |
---|---|---|---|
d9f9dc770b | |||
dca2ff8cfd | |||
cf8e9341f2 | |||
5d1d247491 | |||
fbf4d27cd4 | |||
e0b70d53cd | |||
9f7725cec1 | |||
720cddff21 | |||
1c33098c42 | |||
b256c102e8 | |||
a3716fc491 | |||
14e276a11d | |||
fc85a63af4 | |||
f016a367b5 | |||
d41a90f0dd | |||
9d751f4265 | |||
ff2c224254 | |||
1135b1acac | |||
30ffb30a97 | |||
d1a10386c0 | |||
4d6ac4ade1 | |||
c2bfe489ea | |||
882952bba6 | |||
784f36921b | |||
b7dbdc133e | |||
6caa2f3fed | |||
3a01837561 | |||
ba4bdb335a |
15
CHANGELOG.md
15
CHANGELOG.md
@ -1,3 +1,18 @@
|
||||
### v3.6.9
|
||||
|
||||
- Fix: SASS issue with division (thanks @ROL4ND909 and @le0pard)
|
||||
- Fix: Captions when switching sources (thanks @zexingguo)
|
||||
- Fix: Icons loading within iframes (thanks @ajgagnon)
|
||||
- Chore: Update TypeScript types (thanks @Jackie1210 and @AntLevin)
|
||||
- Fix: iOS fullscreen centering (thanks @hemratna)
|
||||
- Feat: Added getter and setter for preview thumbnails (thanks @Benny739)
|
||||
- Fix: Change fullscreen element to player rootnode (thanks @Walter van den Houten)
|
||||
- Fix: Fixed errors when Plyr instance is destroyed before constructor setTimeout() functions execute (thanks @emilis-ideait)
|
||||
- Fix: Invalid CSS selector syntax (thanks @BjornBrandewallNaviga)
|
||||
- Fix: Video height issues
|
||||
- Feat: Improve support for Vimeo private videos (thanks @Frosch)
|
||||
- Fix: YouTube duration issues (thanks @liesahead)
|
||||
|
||||
### v3.6.8
|
||||
|
||||
- Typings: add FullscreenOptions.container to typing files (thanks @MeguminSama!)
|
||||
|
42
README.md
42
README.md
@ -134,13 +134,13 @@ See [initialising](#initialising) for more information on advanced setups.
|
||||
You can use our CDN (provided by [Fastly](https://www.fastly.com/)) for the JavaScript. There's 2 versions; one with and one without [polyfills](#polyfills). My recommendation would be to manage polyfills seperately as part of your application but to make life easier you can use the polyfilled build.
|
||||
|
||||
```html
|
||||
<script src="https://cdn.plyr.io/3.6.8/plyr.js"></script>
|
||||
<script src="https://cdn.plyr.io/3.6.9/plyr.js"></script>
|
||||
```
|
||||
|
||||
...or...
|
||||
|
||||
```html
|
||||
<script src="https://cdn.plyr.io/3.6.8/plyr.polyfilled.js"></script>
|
||||
<script src="https://cdn.plyr.io/3.6.9/plyr.polyfilled.js"></script>
|
||||
```
|
||||
|
||||
## CSS
|
||||
@ -154,13 +154,13 @@ Include the `plyr.css` stylsheet into your `<head>`.
|
||||
If you want to use our CDN (provided by [Fastly](https://www.fastly.com/)) for the default CSS, you can use the following:
|
||||
|
||||
```html
|
||||
<link rel="stylesheet" href="https://cdn.plyr.io/3.6.8/plyr.css" />
|
||||
<link rel="stylesheet" href="https://cdn.plyr.io/3.6.9/plyr.css" />
|
||||
```
|
||||
|
||||
## SVG Sprite
|
||||
|
||||
The SVG sprite is loaded automatically from our CDN (provided by [Fastly](https://www.fastly.com/)). To change this, see the [options](#options) below. For
|
||||
reference, the CDN hosted SVG sprite can be found at `https://cdn.plyr.io/3.6.8/plyr.svg`.
|
||||
reference, the CDN hosted SVG sprite can be found at `https://cdn.plyr.io/3.6.9/plyr.svg`.
|
||||
|
||||
# Ads
|
||||
|
||||
@ -184,43 +184,43 @@ Here's a list of the properties and what they are used for:
|
||||
|
||||
| Name | Description | Default / Fallback |
|
||||
| ---------------------------------------------- | ------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
|
||||
| `--plyr-color-main` | The primary UI color. |  `#00b3ff` |
|
||||
| `--plyr-color-main` | The primary UI color. |  `#00b3ff` |
|
||||
| `--plyr-video-background` | The background color of video and poster wrappers for using alpha channel videos and poster images. | `rgba(0, 0, 0, 1)` |
|
||||
| `--plyr-tab-focus-color` | The color used for the dotted outline when an element is `:focus-visible` (equivalent) keyboard focus. | `--plyr-color-main` |
|
||||
| `--plyr-badge-background` | The background color for badges in the menu. |  `#4a5464` |
|
||||
| `--plyr-badge-text-color` | The text color for badges. |  `#ffffff` |
|
||||
| `--plyr-badge-background` | The background color for badges in the menu. |  `#4a5464` |
|
||||
| `--plyr-badge-text-color` | The text color for badges. |  `#ffffff` |
|
||||
| `--plyr-badge-border-radius` | The border radius used for badges. | `2px` |
|
||||
| `--plyr-tab-focus-color` | The color used to highlight tab (keyboard) focus. | `--plyr-color-main` |
|
||||
| `--plyr-captions-background` | The color for the background of captions. | `rgba(0, 0, 0, 0.8)` |
|
||||
| `--plyr-captions-text-color` | The color used for the captions text. |  `#ffffff` |
|
||||
| `--plyr-captions-text-color` | The color used for the captions text. |  `#ffffff` |
|
||||
| `--plyr-control-icon-size` | The size of the icons used in the controls. | `18px` |
|
||||
| `--plyr-control-spacing` | The space between controls (sometimes used in a multiple - e.g. `10px / 2 = 5px`). | `10px` |
|
||||
| `--plyr-control-padding` | The padding inside controls. | `--plyr-control-spacing * 0.7` (`7px`) |
|
||||
| `--plyr-control-radius` | The border radius used on controls. | `3px` |
|
||||
| `--plyr-control-toggle-checked-background` | The background color used for checked menu items. | `--plyr-color-main` |
|
||||
| `--plyr-video-controls-background` | The background for the video controls. | `linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.75))` |
|
||||
| `--plyr-video-control-color` | The text/icon color for video controls. |  `#ffffff` |
|
||||
| `--plyr-video-control-color-hover` | The text/icon color used when video controls are `:hover`, `:focus` and `:focus-visible` (equivalent). |  `#ffffff` |
|
||||
| `--plyr-video-control-color` | The text/icon color for video controls. |  `#ffffff` |
|
||||
| `--plyr-video-control-color-hover` | The text/icon color used when video controls are `:hover`, `:focus` and `:focus-visible` (equivalent). |  `#ffffff` |
|
||||
| `--plyr-video-control-background-hover` | The background color used when video controls are `:hover`, `:focus` and `:focus-visible` (equivalent). | `--plyr-color-main` |
|
||||
| `--plyr-audio-controls-background` | The background for the audio controls. |  `#ffffff` |
|
||||
| `--plyr-audio-control-color` | The text/icon color for audio controls. |  `#4a5464` |
|
||||
| `--plyr-audio-control-color-hover` | The text/icon color used when audio controls are `:hover`, `:focus` and `:focus-visible` (equivalent). |  `#ffffff` |
|
||||
| `--plyr-audio-controls-background` | The background for the audio controls. |  `#ffffff` |
|
||||
| `--plyr-audio-control-color` | The text/icon color for audio controls. |  `#4a5464` |
|
||||
| `--plyr-audio-control-color-hover` | The text/icon color used when audio controls are `:hover`, `:focus` and `:focus-visible` (equivalent). |  `#ffffff` |
|
||||
| `--plyr-audio-control-background-hover` | The background color used when video controls are `:hover`, `:focus` and `:focus-visible` (equivalent). | `--plyr-color-main` |
|
||||
| `--plyr-menu-background` | The background color for menus. | `rgba(255, 255, 255, 0.9)` |
|
||||
| `--plyr-menu-color` | The text/icon color for menu items. |  `#4a5464` |
|
||||
| `--plyr-menu-color` | The text/icon color for menu items. |  `#4a5464` |
|
||||
| `--plyr-menu-shadow` | The shadow used on menus. | `0 1px 2px rgba(0, 0, 0, 0.15)` |
|
||||
| `--plyr-menu-radius` | The border radius on the menu. | `4px` |
|
||||
| `--plyr-menu-arrow-size` | The size of the arrow on the bottom of the menu. | `6px` |
|
||||
| `--plyr-menu-item-arrow-color` | The color of the arrows in the menu. |  `#728197` |
|
||||
| `--plyr-menu-item-arrow-color` | The color of the arrows in the menu. |  `#728197` |
|
||||
| `--plyr-menu-item-arrow-size` | The size of the arrows in the menu. | `4px` |
|
||||
| `--plyr-menu-border-color` | The border color for the bottom of the back button in the top of the sub menu pages. |  `#dcdfe5` |
|
||||
| `--plyr-menu-border-shadow-color` | The shadow below the border of the back button in the top of the sub menu pages. |  `#ffffff` |
|
||||
| `--plyr-menu-border-color` | The border color for the bottom of the back button in the top of the sub menu pages. |  `#dcdfe5` |
|
||||
| `--plyr-menu-border-shadow-color` | The shadow below the border of the back button in the top of the sub menu pages. |  `#ffffff` |
|
||||
| `--plyr-progress-loading-size` | The size of the stripes in the loading state in the scrubber. | `25px` |
|
||||
| `--plyr-progress-loading-background` | The background color on the loading state in the scrubber. | `rgba(35, 40, 47, 0.6)` |
|
||||
| `--plyr-video-progress-buffered-background` | The fill color for the buffer indication in the scrubber for video. | `rgba(255, 255, 255, 0.25)` |
|
||||
| `--plyr-audio-progress-buffered-background` | The fill color for the buffer indication in the scrubber for audio. | `rgba(193, 200, 209, 0.6)` |
|
||||
| `--plyr-range-thumb-height` | The height of the scrubber handle/thumb. | `13px` |
|
||||
| `--plyr-range-thumb-background` | The background of the scrubber handle/thumb. |  `#ffffff` |
|
||||
| `--plyr-range-thumb-background` | The background of the scrubber handle/thumb. |  `#ffffff` |
|
||||
| `--plyr-range-thumb-shadow` | The shadow of the scrubber handle/thumb. | `0 1px 1px rgba(215, 26, 18, 0.15), 0 0 0 1px rgba(215, 26, 18, 0.2)` |
|
||||
| `--plyr-range-thumb-active-shadow-width` | The width of the shadow when the scrubber handle/thumb is `:active` (pressed). | `3px` |
|
||||
| `--plyr-range-track-height` | The height of the scrubber/progress track. | `5px` |
|
||||
@ -230,7 +230,7 @@ Here's a list of the properties and what they are used for:
|
||||
| `--plyr-audio-range-track-background` | The background of the scrubber/progress. | `--plyr-video-progress-buffered-background` |
|
||||
| `--plyr-audio-range-thumb-active-shadow-color` | The color of the shadow when the audio scrubber handle/thumb is `:active` (pressed). | `rgba(215, 26, 18, 0.1)` |
|
||||
| `--plyr-tooltip-background` | The background color for tooltips. | `rgba(255, 255, 255, 0.9)` |
|
||||
| `--plyr-tooltip-color` | The text color for tooltips. |  `#4a5464` |
|
||||
| `--plyr-tooltip-color` | The text color for tooltips. |  `#4a5464` |
|
||||
| `--plyr-tooltip-padding` | The padding for tooltips. | `calc(var(--plyr-control-spacing) / 2))` |
|
||||
| `--plyr-tooltip-arrow-size` | The size of the arrow under tooltips. | `4px` |
|
||||
| `--plyr-tooltip-radius` | The border radius on tooltips. | `3px` |
|
||||
@ -467,6 +467,7 @@ player.fullscreen.enter(); // Enter fullscreen
|
||||
| `fullscreen.exit()` | - | Exit fullscreen. |
|
||||
| `fullscreen.toggle()` | - | Toggle fullscreen. |
|
||||
| `airplay()` | - | Trigger the airplay dialog on supported devices. |
|
||||
| `setPreviewThumbnails(source: PreviewThumbnailsOptions)` | - | Sets the preview thubmnails for the current source. |
|
||||
| `toggleControls(toggle)` | Boolean | Toggle the controls (video only). Takes optional truthy value to force it on/off. |
|
||||
| `on(event, function)` | String, Function | Add an event listener for the specified event. |
|
||||
| `once(event, function)` | String, Function | Add an event listener for the specified event once. |
|
||||
@ -513,6 +514,7 @@ player.fullscreen.active; // false;
|
||||
| `loop` | ✓ | ✓ | Gets or sets the current loop state of the player. The setter accepts a boolean. |
|
||||
| `source` | ✓ | ✓ | Gets or sets the current source for the player. The setter accepts an object. See [source setter](#the-source-setter) below for examples. |
|
||||
| `poster` | ✓ | ✓ | Gets or sets the current poster image for the player. The setter accepts a string; the URL for the updated poster image. |
|
||||
| `previewThumbnails` | ✓ | ✓ | Gets or sets the current preview Thubmnail source for the player. The setter accepts a string |
|
||||
| `autoplay` | ✓ | ✓ | Gets or sets the autoplay state of the player. The setter accepts a boolean. |
|
||||
| `currentTrack` | ✓ | ✓ | Gets or sets the caption track by index. `-1` means the track is missing or captions is not active |
|
||||
| `language` | ✓ | ✓ | Gets or sets the preferred captions language for the player. The setter accepts an ISO two-letter language code. Support for the languages is dependent on the captions you include. If your captions don't have any language data, or if you have multiple tracks with the same language, you may want to use `currentTrack` instead. |
|
||||
@ -791,7 +793,7 @@ Some awesome folks have made plugins for CMSs and Components for JavaScript fram
|
||||
| Neos | Jon Uhlmann ([@jonnitto](https://github.com/jonnitto)) | [https://packagist.org/packages/jonnitto/plyr](https://packagist.org/packages/jonnitto/plyr) |
|
||||
| Kirby | Dominik Pschenitschni ([@dpschen](https://github.com/dpschen)) | [https://github.com/dpschen/kirby-plyrtag](https://github.com/dpschen/kirby-plyrtag) |
|
||||
| REDAXO | FriendsOfRedaxo / skerbis ([@skerbis](https://friendsofredaxo.github.io)) | [https://github.com/FriendsOfREDAXO/plyr](https://github.com/FriendsOfREDAXO/plyr) |
|
||||
| svelte-plyr | Ben Woodward / benwoodward ([@benwoodward](https://github.com/benwoodward)) | [https://github.com/benwoodward](https://github.com/benwoodward) |
|
||||
| svelte-plyr | Ben Woodward / benwoodward ([@benwoodward](https://github.com/benwoodward)) | [https://github.com/benwoodward/svelte-plyr](https://github.com/benwoodward/svelte-plyr) |
|
||||
|
||||
# Issues
|
||||
|
||||
|
@ -2,6 +2,8 @@
|
||||
// Icons
|
||||
// ==========================================================================
|
||||
|
||||
@use 'sass:math';
|
||||
|
||||
// Base size icon styles
|
||||
.icon {
|
||||
fill: currentColor;
|
||||
@ -19,5 +21,5 @@ label svg {
|
||||
|
||||
a .icon,
|
||||
.btn .icon {
|
||||
margin-right: ($spacing-base / 2);
|
||||
margin-right: math.div($spacing-base, 4);
|
||||
}
|
||||
|
@ -2,6 +2,8 @@
|
||||
// Examples
|
||||
// ==========================================================================
|
||||
|
||||
@use 'sass:math';
|
||||
|
||||
// Example players
|
||||
.plyr {
|
||||
border-radius: $border-radius-large;
|
||||
@ -31,6 +33,6 @@
|
||||
color: $color-gray-500;
|
||||
|
||||
.icon {
|
||||
margin-right: ceil($spacing-base / 6);
|
||||
margin-right: math.div($spacing-base, 6);
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,8 @@
|
||||
// Core
|
||||
// ==========================================================================
|
||||
|
||||
@use 'sass:math';
|
||||
|
||||
html,
|
||||
body {
|
||||
display: flex;
|
||||
@ -46,7 +48,7 @@ aside {
|
||||
|
||||
.icon {
|
||||
fill: $color-twitter;
|
||||
margin-right: ($spacing-base / 2);
|
||||
margin-right: math.div($spacing-base, 2);
|
||||
}
|
||||
|
||||
p {
|
||||
|
@ -2,6 +2,8 @@
|
||||
// Mixins
|
||||
// ==========================================================================
|
||||
|
||||
@use 'sass:math';
|
||||
|
||||
// Convert a <button> into an <a>
|
||||
// ---------------------------------------
|
||||
@mixin cancel-button-styles() {
|
||||
@ -32,7 +34,7 @@
|
||||
// Leave <body> at 100%/16px
|
||||
// ---------------------------------------
|
||||
@function calculate-rem($size) {
|
||||
$rem: $size / 16;
|
||||
$rem: math.div($size, 16);
|
||||
@return #{$rem}rem;
|
||||
}
|
||||
|
||||
|
13
package.json
13
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "plyr",
|
||||
"version": "3.6.8",
|
||||
"version": "3.6.9",
|
||||
"description": "A simple, accessible and customizable HTML5, YouTube and Vimeo media player",
|
||||
"homepage": "https://plyr.io",
|
||||
"author": "Sam Potts <sam@potts.es>",
|
||||
@ -39,15 +39,15 @@
|
||||
"start": "gulp"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.13.15",
|
||||
"@babel/plugin-proposal-class-properties": "^7.13.0",
|
||||
"@babel/preset-env": "^7.13.15",
|
||||
"@sampotts/eslint-config": "1.1.7",
|
||||
"autoprefixer": "^10.2.5",
|
||||
"aws-sdk": "^2.888.0",
|
||||
"@babel/core": "^7.13.15",
|
||||
"@babel/preset-env": "^7.13.15",
|
||||
"@babel/plugin-proposal-class-properties": "^7.13.0",
|
||||
"babel-eslint": "^10.1.0",
|
||||
"browser-sync": "^2.26.14",
|
||||
"colorette": "1.2.2",
|
||||
"colorette": "2.0.12",
|
||||
"cssnano": "^5.0.1",
|
||||
"del": "^6.0.0",
|
||||
"eslint": "^7.23.0",
|
||||
@ -66,7 +66,7 @@
|
||||
"gulp-postcss": "^9.0.0",
|
||||
"gulp-rename": "^2.0.0",
|
||||
"gulp-replace": "^1.0.0",
|
||||
"gulp-sass": "^4.1.0",
|
||||
"gulp-sass": "^5.0.0",
|
||||
"gulp-size": "^3.0.0",
|
||||
"gulp-sourcemaps": "^3.0.0",
|
||||
"gulp-svgstore": "^7.0.1",
|
||||
@ -81,6 +81,7 @@
|
||||
"rollup-plugin-babel": "^4.4.0",
|
||||
"rollup-plugin-commonjs": "^10.1.0",
|
||||
"rollup-plugin-node-resolve": "^5.2.0",
|
||||
"sass": "^1.42.1",
|
||||
"stylelint": "^13.12.0",
|
||||
"stylelint-config-prettier": "^8.0.2",
|
||||
"stylelint-config-recommended": "^4.0.0",
|
||||
|
@ -154,7 +154,9 @@ const captions = {
|
||||
}
|
||||
|
||||
// Enable or disable captions based on track length
|
||||
toggleClass(this.elements.container, this.config.classNames.captions.enabled, !is.empty(tracks));
|
||||
if (this.elements) {
|
||||
toggleClass(this.elements.container, this.config.classNames.captions.enabled, !is.empty(tracks));
|
||||
}
|
||||
|
||||
// Update available languages in list
|
||||
if (
|
||||
|
@ -61,7 +61,7 @@ const defaults = {
|
||||
// Sprite (for icons)
|
||||
loadSprite: true,
|
||||
iconPrefix: 'plyr',
|
||||
iconUrl: 'https://cdn.plyr.io/3.6.8/plyr.svg',
|
||||
iconUrl: 'https://cdn.plyr.io/3.6.9/plyr.svg',
|
||||
|
||||
// Blank video (used to prevent errors on source change)
|
||||
blankVideo: 'https://cdn.plyr.io/static/blank.mp4',
|
||||
@ -398,6 +398,7 @@ const defaults = {
|
||||
embed: {
|
||||
provider: 'data-plyr-provider',
|
||||
id: 'data-plyr-embed-id',
|
||||
hash: 'data-plyr-embed-hash',
|
||||
},
|
||||
},
|
||||
|
||||
|
3
src/js/controls.js
vendored
3
src/js/controls.js
vendored
@ -38,7 +38,8 @@ const controls = {
|
||||
// Get icon URL
|
||||
getIconUrl() {
|
||||
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 {
|
||||
url: this.config.iconUrl,
|
||||
|
@ -124,7 +124,9 @@ class Fullscreen {
|
||||
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;
|
||||
}
|
||||
|
@ -841,7 +841,9 @@ class Listeners {
|
||||
.filter((c) => !c.contains(elements.container))
|
||||
.forEach((child) => {
|
||||
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';
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -213,8 +213,8 @@ class Ads {
|
||||
request.setAdWillPlayMuted(!this.player.muted);
|
||||
|
||||
this.loader.requestAds(request);
|
||||
} catch (e) {
|
||||
this.onAdError(e);
|
||||
} catch (error) {
|
||||
this.onAdError(error);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -28,6 +28,21 @@ function parseId(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)
|
||||
function assurePlaybackState(play) {
|
||||
if (play && !this.embed.hasPlayed) {
|
||||
@ -71,6 +86,18 @@ const vimeo = {
|
||||
const player = this;
|
||||
const config = player.config.vimeo;
|
||||
const { premium, referrerPolicy, ...frameParams } = 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) {
|
||||
@ -87,17 +114,11 @@ const vimeo = {
|
||||
muted: player.muted,
|
||||
gesture: 'media',
|
||||
playsinline: !this.config.fullscreen.iosNative,
|
||||
// hash has to be added to iframe-URL
|
||||
...hashParam,
|
||||
...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(source);
|
||||
// Build an iframe
|
||||
const iframe = createElement('iframe');
|
||||
|
21
src/js/plyr.d.ts
vendored
21
src/js/plyr.d.ts
vendored
@ -211,6 +211,11 @@ declare class Plyr {
|
||||
*/
|
||||
airplay(): void;
|
||||
|
||||
/**
|
||||
* Sets the preview thubmnails for the current source.
|
||||
*/
|
||||
setPreviewThumbnails(source: Plyr.PreviewThumbnailsOptions): void;
|
||||
|
||||
/**
|
||||
* Toggle the controls (video only). Takes optional truthy value to force it on/off.
|
||||
*/
|
||||
@ -238,8 +243,10 @@ declare class Plyr {
|
||||
|
||||
/**
|
||||
* Destroy lib instance
|
||||
* @param {Function} callback - Callback for when destroy is complete
|
||||
* @param {Boolean} soft - Whether it's a soft destroy (for source changes etc)
|
||||
*/
|
||||
destroy(): void;
|
||||
destroy(callback?: (...args: any[]) => void, soft?: boolean): void;
|
||||
}
|
||||
|
||||
declare namespace Plyr {
|
||||
@ -452,7 +459,7 @@ declare namespace Plyr {
|
||||
* Allows binding of event listeners to the controls before the default handlers. See the defaults.js for available listeners.
|
||||
* If your handler prevents default on the event (event.preventDefault()), the default handler will not fire.
|
||||
*/
|
||||
listeners?: { [key: string]: (error: PlyrEvent) => void };
|
||||
listeners?: {[key: string]: (error: PlyrEvent) => void};
|
||||
|
||||
/**
|
||||
* active: Toggles if captions should be active by default. language: Sets the default language to load (if available). 'auto' uses the browser language.
|
||||
@ -526,7 +533,8 @@ declare namespace Plyr {
|
||||
|
||||
interface AdOptions {
|
||||
enabled: boolean;
|
||||
publisherId: string;
|
||||
publisherId?: string;
|
||||
tagUrl?: string;
|
||||
}
|
||||
|
||||
interface SpeedOptions {
|
||||
@ -616,6 +624,11 @@ declare namespace Plyr {
|
||||
* Booleans are converted to HTML5 value-less attributes.
|
||||
*/
|
||||
tracks?: Track[];
|
||||
|
||||
/**
|
||||
* Enable or disable preview thumbnails for current source
|
||||
*/
|
||||
previewThumbnails?: Plyr.PreviewThumbnailsOptions;
|
||||
}
|
||||
|
||||
interface Source {
|
||||
@ -654,7 +667,7 @@ declare namespace Plyr {
|
||||
}
|
||||
|
||||
interface PlyrEvent extends CustomEvent {
|
||||
readonly detail: { readonly plyr: Plyr };
|
||||
readonly detail: {readonly plyr: Plyr};
|
||||
}
|
||||
|
||||
enum YoutubeState {
|
||||
|
@ -1,6 +1,6 @@
|
||||
// ==========================================================================
|
||||
// Plyr
|
||||
// plyr.js v3.6.8
|
||||
// plyr.js v3.6.9
|
||||
// https://github.com/sampotts/plyr
|
||||
// License: The MIT License (MIT)
|
||||
// ==========================================================================
|
||||
@ -72,7 +72,7 @@ class Plyr {
|
||||
(() => {
|
||||
try {
|
||||
return JSON.parse(this.media.getAttribute('data-plyr-config'));
|
||||
} catch (e) {
|
||||
} catch (_) {
|
||||
return {};
|
||||
}
|
||||
})(),
|
||||
@ -675,7 +675,9 @@ class Plyr {
|
||||
|
||||
// Set media speed
|
||||
setTimeout(() => {
|
||||
this.media.playbackRate = speed;
|
||||
if (this.media) {
|
||||
this.media.playbackRate = speed;
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
|
||||
@ -956,6 +958,7 @@ class Plyr {
|
||||
*/
|
||||
set currentTrack(input) {
|
||||
captions.set.call(this, input, false);
|
||||
captions.setup();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1029,6 +1032,23 @@ class Plyr {
|
||||
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
|
||||
* TODO: update player with state, support, enabled
|
||||
|
@ -1,6 +1,6 @@
|
||||
// ==========================================================================
|
||||
// Plyr Polyfilled Build
|
||||
// plyr.js v3.6.8
|
||||
// plyr.js v3.6.9
|
||||
// https://github.com/sampotts/plyr
|
||||
// License: The MIT License (MIT)
|
||||
// ==========================================================================
|
||||
|
@ -26,7 +26,7 @@ class Storage {
|
||||
window.localStorage.removeItem(test);
|
||||
|
||||
return true;
|
||||
} catch (e) {
|
||||
} catch (_) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -70,7 +70,11 @@ class 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
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ const support = {
|
||||
|
||||
try {
|
||||
return Boolean(type && this.media.canPlayType(type).replace(/no/, ''));
|
||||
} catch (e) {
|
||||
} catch (_) {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
@ -82,6 +82,9 @@ const ui = {
|
||||
// Reset time display
|
||||
controls.timeUpdate.call(this);
|
||||
|
||||
// Reset duration display
|
||||
controls.durationUpdate.call(this);
|
||||
|
||||
// Update the UI
|
||||
ui.checkPlaying.call(this);
|
||||
|
||||
@ -181,13 +184,13 @@ const ui = {
|
||||
.call(this)
|
||||
// Load image
|
||||
.then(() => loadImage(poster))
|
||||
.catch((err) => {
|
||||
.catch((error) => {
|
||||
// Hide poster on error unless it's been set by another call
|
||||
if (poster === this.poster) {
|
||||
ui.togglePoster.call(this, false);
|
||||
}
|
||||
// Rethrow
|
||||
throw err;
|
||||
throw error;
|
||||
})
|
||||
.then(() => {
|
||||
// Prevent race conditions
|
||||
|
@ -31,7 +31,7 @@ export function repaint(element, delay) {
|
||||
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
element.hidden = false;
|
||||
} catch (e) {
|
||||
} catch (_) {
|
||||
// Do nothing
|
||||
}
|
||||
}, delay);
|
||||
|
@ -19,7 +19,7 @@ const supportsPassiveListeners = (() => {
|
||||
});
|
||||
window.addEventListener('test', null, options);
|
||||
window.removeEventListener('test', null, options);
|
||||
} catch (e) {
|
||||
} catch (_) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ export default function fetch(url, responseType = 'text') {
|
||||
if (responseType === 'text') {
|
||||
try {
|
||||
resolve(JSON.parse(request.responseText));
|
||||
} catch (e) {
|
||||
} catch (_) {
|
||||
resolve(request.responseText);
|
||||
}
|
||||
} else {
|
||||
@ -35,8 +35,8 @@ export default function fetch(url, responseType = 'text') {
|
||||
request.responseType = responseType;
|
||||
|
||||
request.send();
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ const isUrl = (input) => {
|
||||
|
||||
try {
|
||||
return !isEmpty(new URL(string).hostname);
|
||||
} catch (e) {
|
||||
} catch (_) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
@ -60,12 +60,16 @@ export default function loadSprite(url, id) {
|
||||
}
|
||||
|
||||
if (useStorage) {
|
||||
window.localStorage.setItem(
|
||||
`${prefix}-${id}`,
|
||||
JSON.stringify({
|
||||
content: result,
|
||||
}),
|
||||
);
|
||||
try {
|
||||
window.localStorage.setItem(
|
||||
`${prefix}-${id}`,
|
||||
JSON.stringify({
|
||||
content: result,
|
||||
}),
|
||||
);
|
||||
} catch (_) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
|
||||
update(container, result);
|
||||
|
@ -20,7 +20,7 @@ export function parseUrl(input, safe = true) {
|
||||
|
||||
try {
|
||||
return new URL(url);
|
||||
} catch (e) {
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,3 @@
|
||||
// ==========================================================================
|
||||
// Useful functions
|
||||
// ==========================================================================
|
||||
|
||||
@function to-percentage($input) {
|
||||
@return $input * 1%;
|
||||
}
|
||||
|
@ -36,7 +36,7 @@
|
||||
z-index: 3;
|
||||
}
|
||||
|
||||
&::after:empty {
|
||||
&:empty::after {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,8 @@
|
||||
// Video styles
|
||||
// --------------------------------------------------------------
|
||||
|
||||
@use 'sass:math';
|
||||
|
||||
// Container
|
||||
.plyr--video {
|
||||
background: var(--plyr-video-background, $plyr-video-background);
|
||||
@ -14,6 +16,7 @@
|
||||
|
||||
.plyr__video-wrapper {
|
||||
background: var(--plyr-video-background, $plyr-video-background);
|
||||
height: 100%;
|
||||
margin: auto;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
@ -21,7 +24,7 @@
|
||||
}
|
||||
|
||||
// Default to 16:9 ratio but this is set by JavaScript based on config
|
||||
$embed-padding: ((100 / 16) * 9);
|
||||
$embed-padding: (math.div(100, 16) * 9);
|
||||
|
||||
.plyr__video-embed,
|
||||
.plyr__video-wrapper--fixed-ratio {
|
||||
@ -47,7 +50,7 @@ $embed-padding: ((100 / 16) * 9);
|
||||
// For Vimeo, if the full custom UI is supported
|
||||
.plyr--full-ui .plyr__video-embed > .plyr__video-embed__container {
|
||||
$height: 240;
|
||||
$offset: to-percentage(($height - $embed-padding) / ($height / 50));
|
||||
$offset: to-percentage(math.div($height - $embed-padding, math.div($height, 50)));
|
||||
padding-bottom: to-percentage($height);
|
||||
position: relative;
|
||||
transform: translateY(-$offset);
|
||||
|
@ -13,7 +13,7 @@ const babel = require('rollup-plugin-babel');
|
||||
const commonjs = require('rollup-plugin-commonjs');
|
||||
const resolve = require('rollup-plugin-node-resolve');
|
||||
// CSS
|
||||
const sass = require('gulp-sass');
|
||||
const sass = require('gulp-sass')(require('sass'));
|
||||
const postcss = require('gulp-postcss');
|
||||
const autoprefixer = require('autoprefixer');
|
||||
const cssnano = require('cssnano');
|
||||
|
@ -51,11 +51,19 @@ const paths = {
|
||||
],
|
||||
};
|
||||
|
||||
// Get branch info
|
||||
// Get git branch info
|
||||
const currentBranch = (() => {
|
||||
try {
|
||||
return gitbranch.sync();
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
})();
|
||||
|
||||
const branch = {
|
||||
current: gitbranch.sync(),
|
||||
master: 'master',
|
||||
beta: 'beta',
|
||||
current: currentBranch,
|
||||
isMaster: currentBranch === 'master',
|
||||
isBeta: currentBranch === 'beta',
|
||||
};
|
||||
|
||||
const maxAge = 31536000; // 1 year
|
||||
@ -66,7 +74,7 @@ const options = {
|
||||
},
|
||||
},
|
||||
demo: {
|
||||
uploadPath: branch.current === branch.beta ? '/beta' : null,
|
||||
uploadPath: branch.isBeta ? '/beta' : null,
|
||||
headers: {
|
||||
'Cache-Control': 'no-cache, no-store, must-revalidate, max-age=0',
|
||||
},
|
||||
@ -99,11 +107,8 @@ const renameFile = rename((p) => {
|
||||
|
||||
// Check we're on the correct branch to deploy
|
||||
const canDeploy = () => {
|
||||
const allowed = [branch.master, branch.beta];
|
||||
|
||||
if (!allowed.includes(branch.current)) {
|
||||
console.error(`Must be on ${allowed.join(', ')} to publish! (current: ${branch.current})`);
|
||||
|
||||
if (![branch.isMaster, branch.isBeta].some(Boolean)) {
|
||||
console.error(`Must be on an allowed branch to publish! (current: ${branch.current})`);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -195,7 +200,7 @@ gulp.task('demo', (done) => {
|
||||
const error = `${paths.demo}error.html`;
|
||||
const pages = [index];
|
||||
|
||||
if (branch.current === branch.master) {
|
||||
if (branch.isMaster) {
|
||||
pages.push(error);
|
||||
}
|
||||
|
||||
@ -220,7 +225,7 @@ gulp.task('open', () => {
|
||||
|
||||
return gulp.src(__filename).pipe(
|
||||
open({
|
||||
uri: `https://${domain}/${branch.current === branch.beta ? 'beta' : ''}`,
|
||||
uri: `https://${domain}/${branch.isBeta ? 'beta' : ''}`,
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
Reference in New Issue
Block a user