Compare commits

...

51 Commits

Author SHA1 Message Date
1d0d6a3a92 v3.6.12
- Fix: remove division logic from ads.scss (fixes #2370)
2021-12-17 07:45:19 +11:00
6a92e60a67 fix: remove division logic from ads.scss (fixes #2370) 2021-12-17 07:39:58 +11:00
40395a1ff5 v3.6.11
- Fix: Replace `list.slash` added in 3.6.10 with `calc`
- Chore: Package upgrades
- Chore: SASS clean up
- Chore: Improvements to style linting
2021-12-16 23:03:29 +11:00
9ea3a6923d fix: use calc instead of list.slash 2021-12-16 22:59:44 +11:00
675a853e2e chore: SASS clean up 2021-12-16 22:59:25 +11:00
950786b117 chore: npm script syntax tweak 2021-12-16 22:58:58 +11:00
626e1dba64 docs: fix typos 2021-12-16 22:56:46 +11:00
cbd1596af4 chore: stylelint config changes 2021-12-16 22:56:31 +11:00
6ea510c36e chore: package upgrades 2021-12-16 22:56:13 +11:00
0acf228dcd v3.6.10
- Fix: Use `list.slash` instead of deprecated syntax
- Chore: Clean up demo
2021-12-16 20:51:31 +11:00
91b19baf44 fix: use list.slash instead of deprecated syntax 2021-12-16 20:29:36 +11:00
990d636019 chore: clean up demo 2021-12-16 20:29:36 +11:00
b9c792b377 Fix repeated "an" (#2371) 2021-11-28 22:51:21 +11:00
d9f9dc770b 3.6.9 2021-10-13 21:48:22 +11:00
dca2ff8cfd chore: linting 2021-10-13 21:45:30 +11:00
cf8e9341f2 fix: revert math.div SASS fallback 2021-09-29 22:07:42 +10:00
5d1d247491 chore: minor code style tweak 2021-09-29 21:44:15 +10:00
fbf4d27cd4 chore: fix SASS build 2021-09-29 21:44:02 +10:00
e0b70d53cd fix: wrap localStorage sets in try/catch 2021-09-29 21:43:52 +10:00
9f7725cec1 chore: package upgrades 2021-09-29 21:43:09 +10:00
720cddff21 fix: add SASS div method fallback 2021-09-29 21:42:41 +10:00
1c33098c42 (fix): youtube videos duration (ref #2223). (#2224)
Co-authored-by: Denis Semionov <denis.semionov@prewise.com>
2021-09-29 21:14:43 +10:00
b256c102e8 Vimeo private videos: check for hash in src and add as a param (#2322)
* check for hash in src and add as a param

* Enable different methods of passing hash
2021-09-29 21:14:43 +10:00
a3716fc491 chore: update node version 2021-09-29 21:14:43 +10:00
14e276a11d fix: video height issue 2021-09-29 21:14:43 +10:00
fc85a63af4 Fix invalid CSS selector syntax (#2303)
https://jigsaw.w3.org/css-validator/ complains that "The selector :empty can't appear after the pseudo-element selector ::after". Switching their places, however, will validate.
2021-09-29 21:14:43 +10:00
f016a367b5 Fixed errors when Plyr instance is destroyed before constructor setTimeout() functions execute. (#2108)
Co-authored-by: Emilis Dambauskas <emilis.dambauskas@mps.fi>
2021-09-29 21:14:43 +10:00
d41a90f0dd change fullscreen element to player rootnode (#2204)
Co-authored-by: Walter van den Houten <63712489+wdfvdhouten@users.noreply.github.com>
2021-09-29 21:10:54 +10:00
9d751f4265 README: Link to svelte project (#2242) 2021-09-29 21:07:45 +10:00
ff2c224254 Added preview thumbnails setter & fixed cannot set property 'hover' of null (#2256)
* added iPad to isIos

* elements.controls can be null

* elements.controls can be null

* added previewThumbnails setter

* fixed readme formatting

* previewThumbnails setter to method
2021-09-29 21:07:15 +10:00
1135b1acac Fix types - add tagUrl in ads option with custom VAST (#2319) 2021-09-29 21:05:56 +10:00
30ffb30a97 Fixes iOS fullscreen not centered issue. (#2284) 2021-09-29 21:05:15 +10:00
d1a10386c0 chore(deps): bump ws from 7.4.3 to 7.4.6 (#2226)
Bumps [ws](https://github.com/websockets/ws) from 7.4.3 to 7.4.6.
- [Release notes](https://github.com/websockets/ws/releases)
- [Commits](https://github.com/websockets/ws/compare/7.4.3...7.4.6)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-08-25 00:13:41 +10:00
4d6ac4ade1 chore: update plyr.d.ts for right ts check (#2245) 2021-08-24 23:18:09 +10:00
c2bfe489ea Let icons load in iframes without a location (#2259)
Currently, icons will fail to load if the player is placed inside an iframe without a window.location. This adds an additional check to use `window.top.location` if the window does not have a location.
2021-08-24 23:16:30 +10:00
882952bba6 fix: fixed captions when switching source (#2261) 2021-08-24 23:15:45 +10:00
784f36921b Update video.scss (#2296) 2021-08-24 22:30:13 +10:00
b7dbdc133e chore(deps): bump path-parse from 1.0.6 to 1.0.7 (#2301)
Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7.
- [Release notes](https://github.com/jbgutierrez/path-parse/releases)
- [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7)

---
updated-dependencies:
- dependency-name: path-parse
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-08-24 22:28:42 +10:00
6caa2f3fed chore(deps): bump hosted-git-info from 2.8.8 to 2.8.9 (#2268)
Bumps [hosted-git-info](https://github.com/npm/hosted-git-info) from 2.8.8 to 2.8.9.
- [Release notes](https://github.com/npm/hosted-git-info/releases)
- [Changelog](https://github.com/npm/hosted-git-info/blob/v2.8.9/CHANGELOG.md)
- [Commits](https://github.com/npm/hosted-git-info/compare/v2.8.8...v2.8.9)

---
updated-dependencies:
- dependency-name: hosted-git-info
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-06 08:23:00 +10:00
3a01837561 fix: allow local builds without git 2021-07-06 08:12:51 +10:00
ba4bdb335a docs: update placehold.it references 2021-07-06 08:11:23 +10:00
ba236c4753 v3.6.8 2021-05-12 23:40:37 +10:00
a204f7c1dd Merge branch 'develop' 2021-05-12 23:37:34 +10:00
bacf9122de chore: update nvmrc to 14 2021-05-12 23:37:05 +10:00
2fdc1eac94 chore: lock file 2021-05-12 23:37:05 +10:00
5fd4391cd9 fix: fullscreen issues with Vimeo (fixes #2175) 2021-05-12 23:37:05 +10:00
6991358428 Add container to FullscreenOptions (#2161) 2021-05-12 23:35:01 +10:00
b050fde276 added iPad to isIos (#2191) 2021-05-12 23:33:48 +10:00
32444c9851 v3.6.7
- Fix: remove regression caused by optional chaining and nullish coalescing in check for `window.CSS` check for aspect-ratio (fixes #2174)
2021-04-20 08:28:23 +10:00
b93dcc43ad fix: minor syntax tweak 2021-04-19 21:16:30 +10:00
6ff6ff1673 fix: syntax fix (#2176) 2021-04-19 21:13:06 +10:00
67 changed files with 2577 additions and 2638 deletions

2
.nvmrc
View File

@ -1 +1 @@
v12.8 16

View File

@ -1,6 +1,7 @@
{ {
"plugins": ["stylelint-selector-bem-pattern", "stylelint-scss"], "plugins": ["stylelint-selector-bem-pattern"],
"extends": ["stylelint-config-recommended", "stylelint-config-sass-guidelines", "stylelint-config-prettier"], "extends": ["stylelint-config-sass-guidelines", "stylelint-config-prettier"],
"customSyntax": "postcss-scss",
"rules": { "rules": {
"selector-class-pattern": null, "selector-class-pattern": null,
"selector-no-qualifying-type": [ "selector-no-qualifying-type": [
@ -9,10 +10,7 @@
"ignore": ["attribute", "class"] "ignore": ["attribute", "class"]
} }
], ],
"string-no-newline": null, "max-nesting-depth": 4,
"indentation": 2,
"string-quotes": "single",
"max-nesting-depth": 2,
"plugin/selector-bem-pattern": { "plugin/selector-bem-pattern": {
"preset": "bem", "preset": "bem",
"componentName": "(([a-z0-9]+(?!-$)-?)+)", "componentName": "(([a-z0-9]+(?!-$)-?)+)",

View File

@ -1,3 +1,44 @@
### v3.6.12
- Fix: remove division logic from ads.scss (fixes #2370)
### v3.6.11
- Fix: Replace `list.slash` added in 3.6.10 with `calc`
- Chore: Package upgrades
- Chore: SASS clean up
- Chore: Improvements to style linting
### v3.6.10
- Fix: Use `list.slash` instead of deprecated syntax
- Chore: Clean up demo
### 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!)
- Fix: added iPadOS detection to isIos util (thanks @Benny739!)
- Fix: issues with Vimeo fullscreen
### v3.6.7
- Fix: remove regression caused by optional chaining and nullish coalescing in check for `window.CSS` check for aspect-ratio (fixes #2174)
### v3.6.6 ### v3.6.6
- Improvements to how aspect ratio is handled. Use `aspect-ratio` CSS property instead of the legacy method (still used as fallback). Also automatically determined aspect ratios are rounded to the nearast standard ratio. This fixes issues with the YouTube embeds showing a 1-2px black bar. - Improvements to how aspect ratio is handled. Use `aspect-ratio` CSS property instead of the legacy method (still used as fallback). Also automatically determined aspect ratios are rounded to the nearast standard ratio. This fixes issues with the YouTube embeds showing a 1-2px black bar.
@ -36,7 +77,7 @@
- Fix "A `ReferenceError: _classCallCheck is not defined` error has occurred." error (thanks @hex-ci) - Fix "A `ReferenceError: _classCallCheck is not defined` error has occurred." error (thanks @hex-ci)
- Fix issue with CSS custom property check (thanks @syedhusain-appspace) - Fix issue with CSS custom property check (thanks @syedhusain-appspace)
- Fix for slow loading videos not autoplaying (thanks @DanielHuntleySBG) - Fix for slow loading videos not autoplaying (thanks @DanielHuntleySBG)
- Fix for betwork requests are not cancelled after the player is destroyed (thanks @DanielHuntleySBG) - Fix for network requests are not cancelled after the player is destroyed (thanks @DanielHuntleySBG)
- Added option to disable custom controls for YouTube and Vimeo - Added option to disable custom controls for YouTube and Vimeo
### v3.6.2 ### v3.6.2
@ -81,7 +122,7 @@
### v3.5.8 ### v3.5.8
- Added `flex-direction` property to fix some issues introduced in v3.5.7 when using custom CSS - Added `flex-direction` property to fix some issues introduced in v3.5.7 when using custom CSS
- Cleaned up the organisation of some of the SCSS files (should not effect CSS output) - Cleaned up the organization of some of the SCSS files (should not effect CSS output)
- Added `referrerPolicy` option for Vimeo to prevent an issue present in the demo site - Added `referrerPolicy` option for Vimeo to prevent an issue present in the demo site
- Remove all Vimeo controls for Pro & Premium accounts - Remove all Vimeo controls for Pro & Premium accounts
- Improve thumbnail size calculations when size is set per css (thanks @ydylla) - Improve thumbnail size calculations when size is set per css (thanks @ydylla)
@ -96,7 +137,7 @@
- Accessibility tweak for the play button (thanks @lunika) - Accessibility tweak for the play button (thanks @lunika)
- Fix for ads configuration (thanks @SoftCreatR) - Fix for ads configuration (thanks @SoftCreatR)
- Fix handling listener return value (thanks @taion) - Fix handling listener return value (thanks @taion)
- Added localisation key for PIP (picture-in-picture) (thanks @lmislm) - Added localization key for PIP (picture-in-picture) (thanks @lmislm)
- Preserve viewBox attribute in SVG sprite symbols (thanks @bseib) - Preserve viewBox attribute in SVG sprite symbols (thanks @bseib)
- Fix being unable to unmute autoplayed video on iOS (thanks @sumanbh) - Fix being unable to unmute autoplayed video on iOS (thanks @sumanbh)
- Fixed Plyr container not resizing responsively (thanks @shravan2x) - Fixed Plyr container not resizing responsively (thanks @shravan2x)

View File

@ -2,11 +2,11 @@
This is the markup that is rendered for the Plyr controls. You can use the default controls or provide a customized version of markup based on your needs. You can pass the following to the `controls` option: This is the markup that is rendered for the Plyr controls. You can use the default controls or provide a customized version of markup based on your needs. You can pass the following to the `controls` option:
- `Array` of options (this builds the default controls based on your choices) - `Array` of options (this builds the default controls based on your choices)
- `Element` with the controls - `Element` with the controls
- `String` containing the desired HTML - `String` containing the desired HTML
- `false` (or empty string or array) to disable all controls - `false` (or empty string or array) to disable all controls
- `Function` that will be executed and should return one of the above - `Function` that will be executed and should return one of the above
## Using default controls ## Using default controls
@ -14,28 +14,28 @@ If you want to use the standard controls as they are, you don't need to pass any
```javascript ```javascript
controls: [ controls: [
'play-large', // The large play button in the center 'play-large', // The large play button in the center
'restart', // Restart playback 'restart', // Restart playback
'rewind', // Rewind by the seek time (default 10 seconds) 'rewind', // Rewind by the seek time (default 10 seconds)
'play', // Play/pause playback 'play', // Play/pause playback
'fast-forward', // Fast forward by the seek time (default 10 seconds) 'fast-forward', // Fast forward by the seek time (default 10 seconds)
'progress', // The progress bar and scrubber for playback and buffering 'progress', // The progress bar and scrubber for playback and buffering
'current-time', // The current time of playback 'current-time', // The current time of playback
'duration', // The full duration of the media 'duration', // The full duration of the media
'mute', // Toggle mute 'mute', // Toggle mute
'volume', // Volume control 'volume', // Volume control
'captions', // Toggle captions 'captions', // Toggle captions
'settings', // Settings menu 'settings', // Settings menu
'pip', // Picture-in-picture (currently Safari only) 'pip', // Picture-in-picture (currently Safari only)
'airplay', // Airplay (currently Safari only) 'airplay', // Airplay (currently Safari only)
'download', // Show a download button with a link to either the current source or a custom URL you specify in your options 'download', // Show a download button with a link to either the current source or a custom URL you specify in your options
'fullscreen', // Toggle fullscreen 'fullscreen', // Toggle fullscreen
]; ];
``` ```
### Internationalization using default controls ### Internationalization using default controls
You can provide an `i18n` object as one of your options when initialising the plugin which we be used when rendering the controls. You can provide an `i18n` object as one of your options when initializing the plugin which we be used when rendering the controls.
#### Example #### Example
@ -84,14 +84,14 @@ The classes and data attributes used in your template should match the `selector
You need to add several placeholders to your HTML template that are replaced when rendering: You need to add several placeholders to your HTML template that are replaced when rendering:
- `{id}` - the dynamically generated ID for the player (for form controls) - `{id}` - the dynamically generated ID for the player (for form controls)
- `{seektime}` - the seek time specified in options for fast forward and rewind - `{seektime}` - the seek time specified in options for fast forward and rewind
- `{title}` - the title of your media, if specified - `{title}` - the title of your media, if specified
### Limitations ### Limitations
- Currently the settings menus are not supported with custom controls HTML - Currently the settings menus are not supported with custom controls HTML
- AirPlay and PiP buttons can be added but you will have to manage feature detection - AirPlay and PiP buttons can be added but you will have to manage feature detection
### Example ### Example

122
README.md
View File

@ -131,21 +131,21 @@ Alternatively you can include the `plyr.js` script before the closing `</body>`
See [initialising](#initialising) for more information on advanced setups. 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. 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 separately as part of your application but to make life easier you can use the polyfilled build.
```html ```html
<script src="https://cdn.plyr.io/3.6.6/plyr.js"></script> <script src="https://cdn.plyr.io/3.6.12/plyr.js"></script>
``` ```
...or... ...or...
```html ```html
<script src="https://cdn.plyr.io/3.6.6/plyr.polyfilled.js"></script> <script src="https://cdn.plyr.io/3.6.12/plyr.polyfilled.js"></script>
``` ```
## CSS ## CSS
Include the `plyr.css` stylsheet into your `<head>`. Include the `plyr.css` stylesheet into your `<head>`.
```html ```html
<link rel="stylesheet" href="path/to/plyr.css" /> <link rel="stylesheet" href="path/to/plyr.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: If you want to use our CDN (provided by [Fastly](https://www.fastly.com/)) for the default CSS, you can use the following:
```html ```html
<link rel="stylesheet" href="https://cdn.plyr.io/3.6.6/plyr.css" /> <link rel="stylesheet" href="https://cdn.plyr.io/3.6.12/plyr.css" />
``` ```
## SVG Sprite ## 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 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.6/plyr.svg`. reference, the CDN hosted SVG sprite can be found at `https://cdn.plyr.io/3.6.12/plyr.svg`.
# Ads # Ads
@ -184,43 +184,43 @@ Here's a list of the properties and what they are used for:
| Name | Description | Default / Fallback | | Name | Description | Default / Fallback |
| ---------------------------------------------- | ------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- | | ---------------------------------------------- | ------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
| `--plyr-color-main` | The primary UI color. | ![#f03c15](https://placehold.it/15/00b3ff/000000?text=+) `#00b3ff` | | `--plyr-color-main` | The primary UI color. | ![#f03c15](https://place-hold.it/15/00b3ff/000000?text=+) `#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-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-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](https://placehold.it/15/4a5464/000000?text=+) `#4a5464` | | `--plyr-badge-background` | The background color for badges in the menu. | ![#4a5464](https://place-hold.it/15/4a5464/000000?text=+) `#4a5464` |
| `--plyr-badge-text-color` | The text color for badges. | ![#ffffff](https://placehold.it/15/ffffff/000000?text=+) `#ffffff` | | `--plyr-badge-text-color` | The text color for badges. | ![#ffffff](https://place-hold.it/15/ffffff/000000?text=+) `#ffffff` |
| `--plyr-badge-border-radius` | The border radius used for badges. | `2px` | | `--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-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-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](https://placehold.it/15/ffffff/000000?text=+) `#ffffff` | | `--plyr-captions-text-color` | The color used for the captions text. | ![#ffffff](https://place-hold.it/15/ffffff/000000?text=+) `#ffffff` |
| `--plyr-control-icon-size` | The size of the icons used in the controls. | `18px` | | `--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-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-padding` | The padding inside controls. | `--plyr-control-spacing * 0.7` (`7px`) |
| `--plyr-control-radius` | The border radius used on controls. | `3px` | | `--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-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-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](https://placehold.it/15/ffffff/000000?text=+) `#ffffff` | | `--plyr-video-control-color` | The text/icon color for video controls. | ![#ffffff](https://place-hold.it/15/ffffff/000000?text=+) `#ffffff` |
| `--plyr-video-control-color-hover` | The text/icon color used when video controls are `:hover`, `:focus` and `:focus-visible` (equivalent). | ![#ffffff](https://placehold.it/15/ffffff/000000?text=+) `#ffffff` | | `--plyr-video-control-color-hover` | The text/icon color used when video controls are `:hover`, `:focus` and `:focus-visible` (equivalent). | ![#ffffff](https://place-hold.it/15/ffffff/000000?text=+) `#ffffff` |
| `--plyr-video-control-background-hover` | The background color used when video controls are `:hover`, `:focus` and `:focus-visible` (equivalent). | `--plyr-color-main` | | `--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](https://placehold.it/15/ffffff/000000?text=+) `#ffffff` | | `--plyr-audio-controls-background` | The background for the audio controls. | ![#ffffff](https://place-hold.it/15/ffffff/000000?text=+) `#ffffff` |
| `--plyr-audio-control-color` | The text/icon color for audio controls. | ![#4a5464](https://placehold.it/15/4a5464/000000?text=+) `#4a5464` | | `--plyr-audio-control-color` | The text/icon color for audio controls. | ![#4a5464](https://place-hold.it/15/4a5464/000000?text=+) `#4a5464` |
| `--plyr-audio-control-color-hover` | The text/icon color used when audio controls are `:hover`, `:focus` and `:focus-visible` (equivalent). | ![#ffffff](https://placehold.it/15/ffffff/000000?text=+) `#ffffff` | | `--plyr-audio-control-color-hover` | The text/icon color used when audio controls are `:hover`, `:focus` and `:focus-visible` (equivalent). | ![#ffffff](https://place-hold.it/15/ffffff/000000?text=+) `#ffffff` |
| `--plyr-audio-control-background-hover` | The background color used when video controls are `:hover`, `:focus` and `:focus-visible` (equivalent). | `--plyr-color-main` | | `--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-background` | The background color for menus. | `rgba(255, 255, 255, 0.9)` |
| `--plyr-menu-color` | The text/icon color for menu items. | ![#4a5464](https://placehold.it/15/4a5464/000000?text=+) `#4a5464` | | `--plyr-menu-color` | The text/icon color for menu items. | ![#4a5464](https://place-hold.it/15/4a5464/000000?text=+) `#4a5464` |
| `--plyr-menu-shadow` | The shadow used on menus. | `0 1px 2px rgba(0, 0, 0, 0.15)` | | `--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-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-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](https://placehold.it/15/728197/000000?text=+) `#728197` | | `--plyr-menu-item-arrow-color` | The color of the arrows in the menu. | ![#728197](https://place-hold.it/15/728197/000000?text=+) `#728197` |
| `--plyr-menu-item-arrow-size` | The size of the arrows in the menu. | `4px` | | `--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](https://placehold.it/15/dcdfe5/000000?text=+) `#dcdfe5` | | `--plyr-menu-border-color` | The border color for the bottom of the back button in the top of the sub menu pages. | ![#dcdfe5](https://place-hold.it/15/dcdfe5/000000?text=+) `#dcdfe5` |
| `--plyr-menu-border-shadow-color` | The shadow below the border of the back button in the top of the sub menu pages. | ![#ffffff](https://placehold.it/15/ffffff/000000?text=+) `#ffffff` | | `--plyr-menu-border-shadow-color` | The shadow below the border of the back button in the top of the sub menu pages. | ![#ffffff](https://place-hold.it/15/ffffff/000000?text=+) `#ffffff` |
| `--plyr-progress-loading-size` | The size of the stripes in the loading state in the scrubber. | `25px` | | `--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-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-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-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-height` | The height of the scrubber handle/thumb. | `13px` |
| `--plyr-range-thumb-background` | The background of the scrubber handle/thumb. | ![#ffffff](https://placehold.it/15/ffffff/000000?text=+) `#ffffff` | | `--plyr-range-thumb-background` | The background of the scrubber handle/thumb. | ![#ffffff](https://place-hold.it/15/ffffff/000000?text=+) `#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-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-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` | | `--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-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-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-background` | The background color for tooltips. | `rgba(255, 255, 255, 0.9)` |
| `--plyr-tooltip-color` | The text color for tooltips. | ![#4a5464](https://placehold.it/15/4a5464/000000?text=+) `#4a5464` | | `--plyr-tooltip-color` | The text color for tooltips. | ![#4a5464](https://place-hold.it/15/4a5464/000000?text=+) `#4a5464` |
| `--plyr-tooltip-padding` | The padding for tooltips. | `calc(var(--plyr-control-spacing) / 2))` | | `--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-arrow-size` | The size of the arrow under tooltips. | `4px` |
| `--plyr-tooltip-radius` | The border radius on tooltips. | `3px` | | `--plyr-tooltip-radius` | The border radius on tooltips. | `3px` |
@ -267,9 +267,7 @@ You can set them in your CSS for all players:
...or in your HTML: ...or in your HTML:
```html ```html
<video class="player" style="--plyr-color-main: #1ac266;"> <video class="player" style="--plyr-color-main: #1ac266;">...</video>
...
</video>
``` ```
### SASS ### SASS
@ -344,7 +342,7 @@ The HTMLElement or string selector can be the target `<video>`, `<audio>`, or `<
You have two choices here. You can either use a simple array loop to map the constructor: You have two choices here. You can either use a simple array loop to map the constructor:
```javascript ```javascript
const players = Array.from(document.querySelectorAll('.js-player')).map(p => new Plyr(p)); const players = Array.from(document.querySelectorAll('.js-player')).map((p) => new Plyr(p));
``` ```
...or use a static method where you can pass a [CSS string selector](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors), a [NodeList](https://developer.mozilla.org/en-US/docs/Web/API/NodeList), an [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) of [HTMLElement](https://developer.mozilla.org/en/docs/Web/API/HTMLElement), or a [JQuery](https://jquery.com) object: ...or use a static method where you can pass a [CSS string selector](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors), a [NodeList](https://developer.mozilla.org/en-US/docs/Web/API/NodeList), an [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) of [HTMLElement](https://developer.mozilla.org/en/docs/Web/API/HTMLElement), or a [JQuery](https://jquery.com) object:
@ -400,7 +398,7 @@ Note the single quotes encapsulating the JSON and double quotes on the object ke
| `invertTime` | Boolean | `true` | Display the current time as a countdown rather than an incremental counter. | | `invertTime` | Boolean | `true` | Display the current time as a countdown rather than an incremental counter. |
| `toggleInvert` | Boolean | `true` | Allow users to click to toggle the above. | | `toggleInvert` | Boolean | `true` | Allow users to click to toggle the above. |
| `listeners` | Object | `null` | 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` | Object | `null` | 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. |
| `captions` | Object | `{ active: false, language: 'auto', update: false }` | `active`: Toggles if captions should be active by default. `language`: Sets the default language to load (if available). 'auto' uses the browser language. `update`: Listen to changes to tracks and update menu. This is needed for some streaming libraries, but can result in unselectable language options). | | `captions` | Object | `{ active: false, language: 'auto', update: false }` | `active`: Toggles if captions should be active by default. `language`: Sets the default language to load (if available). 'auto' uses the browser language. `update`: Listen to changes to tracks and update menu. This is needed for some streaming libraries, but can result in non-selectable language options). |
| `fullscreen` | Object | `{ enabled: true, fallback: true, iosNative: false, container: null }` | `enabled`: Toggles whether fullscreen should be enabled. `fallback`: Allow fallback to a full-window solution (`true`/`false`/`'force'`). `iosNative`: whether to use native iOS fullscreen when entering fullscreen (no custom controls). `container`: A selector for an ancestor of the player element, allows contextual content to remain visual in fullscreen mode. Non-ancestors are ignored. | | `fullscreen` | Object | `{ enabled: true, fallback: true, iosNative: false, container: null }` | `enabled`: Toggles whether fullscreen should be enabled. `fallback`: Allow fallback to a full-window solution (`true`/`false`/`'force'`). `iosNative`: whether to use native iOS fullscreen when entering fullscreen (no custom controls). `container`: A selector for an ancestor of the player element, allows contextual content to remain visual in fullscreen mode. Non-ancestors are ignored. |
| `ratio` | String | `null` | Force an aspect ratio for all videos. The format is `'w:h'` - e.g. `'16:9'` or `'4:3'`. If this is not specified then the default for HTML5 and Vimeo is to use the native resolution of the video. As dimensions are not available from YouTube via SDK, 16:9 is forced as a sensible default. | | `ratio` | String | `null` | Force an aspect ratio for all videos. The format is `'w:h'` - e.g. `'16:9'` or `'4:3'`. If this is not specified then the default for HTML5 and Vimeo is to use the native resolution of the video. As dimensions are not available from YouTube via SDK, 16:9 is forced as a sensible default. |
| `storage` | Object | `{ enabled: true, key: 'plyr' }` | `enabled`: Allow use of local storage to store user settings. `key`: The key name to use. | | `storage` | Object | `{ enabled: true, key: 'plyr' }` | `enabled`: Allow use of local storage to store user settings. `key`: The key name to use. |
@ -437,7 +435,7 @@ const player = new Plyr('#player', {
You can also access the object through any events: You can also access the object through any events:
```javascript ```javascript
element.addEventListener('ready', event => { element.addEventListener('ready', (event) => {
const player = event.detail.plyr; const player = event.detail.plyr;
}); });
``` ```
@ -451,28 +449,29 @@ player.play(); // Start playback
player.fullscreen.enter(); // Enter fullscreen player.fullscreen.enter(); // Enter fullscreen
``` ```
| Method | Parameters | Description | | Method | Parameters | Description |
| -------------------------- | ---------------- | ---------------------------------------------------------------------------------------------------------- | | -------------------------------------------------------- | ---------------- | ---------------------------------------------------------------------------------------------------------- |
| `play()`&sup1; | - | Start playback. | | `play()`&sup1; | - | Start playback. |
| `pause()` | - | Pause playback. | | `pause()` | - | Pause playback. |
| `togglePlay(toggle)`&sup1; | Boolean | Toggle playback, if no parameters are passed, it will toggle based on current status. | | `togglePlay(toggle)`&sup1; | Boolean | Toggle playback, if no parameters are passed, it will toggle based on current status. |
| `stop()` | - | Stop playback and reset to start. | | `stop()` | - | Stop playback and reset to start. |
| `restart()` | - | Restart playback. | | `restart()` | - | Restart playback. |
| `rewind(seekTime)` | Number | Rewind playback by the specified seek time. If no parameter is passed, the default seek time will be used. | | `rewind(seekTime)` | Number | Rewind playback by the specified seek time. If no parameter is passed, the default seek time will be used. |
| `forward(seekTime)` | Number | Fast forward by the specified seek time. If no parameter is passed, the default seek time will be used. | | `forward(seekTime)` | Number | Fast forward by the specified seek time. If no parameter is passed, the default seek time will be used. |
| `increaseVolume(step)` | Number | Increase volume by the specified step. If no parameter is passed, the default step will be used. | | `increaseVolume(step)` | Number | Increase volume by the specified step. If no parameter is passed, the default step will be used. |
| `decreaseVolume(step)` | Number | Increase volume by the specified step. If no parameter is passed, the default step will be used. | | `decreaseVolume(step)` | Number | Increase volume by the specified step. If no parameter is passed, the default step will be used. |
| `toggleCaptions(toggle)` | Boolean | Toggle captions display. If no parameter is passed, it will toggle based on current status. | | `toggleCaptions(toggle)` | Boolean | Toggle captions display. If no parameter is passed, it will toggle based on current status. |
| `fullscreen.enter()` | - | Enter fullscreen. If fullscreen is not supported, a fallback "full window/viewport" is used instead. | | `fullscreen.enter()` | - | Enter fullscreen. If fullscreen is not supported, a fallback "full window/viewport" is used instead. |
| `fullscreen.exit()` | - | Exit fullscreen. | | `fullscreen.exit()` | - | Exit fullscreen. |
| `fullscreen.toggle()` | - | Toggle fullscreen. | | `fullscreen.toggle()` | - | Toggle fullscreen. |
| `airplay()` | - | Trigger the airplay dialog on supported devices. | | `airplay()` | - | Trigger the airplay dialog on supported devices. |
| `toggleControls(toggle)` | Boolean | Toggle the controls (video only). Takes optional truthy value to force it on/off. | | `setPreviewThumbnails(source: PreviewThumbnailsOptions)` | - | Sets the preview thumbnails for the current source. |
| `on(event, function)` | String, Function | Add an event listener for the specified event. | | `toggleControls(toggle)` | Boolean | Toggle the controls (video only). Takes optional truthy value to force it on/off. |
| `once(event, function)` | String, Function | Add an event listener for the specified event once. | | `on(event, function)` | String, Function | Add an event listener for the specified event. |
| `off(event, function)` | String, Function | Remove an event listener for the specified event. | | `once(event, function)` | String, Function | Add an event listener for the specified event once. |
| `supports(type)` | String | Check support for a mime type. | | `off(event, function)` | String, Function | Remove an event listener for the specified event. |
| `destroy()` | - | Destroy the instance and garbage collect any elements. | | `supports(type)` | String | Check support for a mime type. |
| `destroy()` | - | Destroy the instance and garbage collect any elements. |
1. For HTML5 players, `play()` will return a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) for most browsers - e.g. Chrome, Firefox, Opera, Safari and Edge [according to MDN](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/play) at time of writing. 1. For HTML5 players, `play()` will return a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) for most browsers - e.g. Chrome, Firefox, Opera, Safari and Edge [according to MDN](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/play) at time of writing.
@ -513,6 +512,7 @@ player.fullscreen.active; // false;
| `loop` | ✓ | ✓ | Gets or sets the current loop state of the player. The setter accepts a boolean. | | `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. | | `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. | | `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 thumbnail source for the player. The setter accepts a string |
| `autoplay` | ✓ | ✓ | Gets or sets the autoplay state of the player. The setter accepts a boolean. | | `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 | | `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. | | `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. |
@ -635,7 +635,7 @@ reference to the instance, you can use the `on()` API method or `addEventListene
property. Here's an example: property. Here's an example:
```javascript ```javascript
player.on('ready', event => { player.on('ready', (event) => {
const instance = event.detail.plyr; const instance = event.detail.plyr;
}); });
``` ```
@ -782,16 +782,16 @@ If a User Agent is disabled but supports `<video>` and `<audio>` natively, it wi
Some awesome folks have made plugins for CMSs and Components for JavaScript frameworks: Some awesome folks have made plugins for CMSs and Components for JavaScript frameworks:
| Type | Maintainer | Link | | Type | Maintainer | Link |
| --------- | ------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | | ----------- | --------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- |
| WordPress | Brandon Lavigne ([@drrobotnik](https://github.com/drrobotnik)) | [https://wordpress.org/plugins/plyr/](https://wordpress.org/plugins/plyr/) | | WordPress | Brandon Lavigne ([@drrobotnik](https://github.com/drrobotnik)) | [https://wordpress.org/plugins/plyr/](https://wordpress.org/plugins/plyr/) |
| Angular | Simon Bobrov ([@smnbbrv](https://github.com/smnbbrv)) | [https://github.com/smnbbrv/ngx-plyr](https://github.com/smnbbrv/ngx-plyr) | | Angular | Simon Bobrov ([@smnbbrv](https://github.com/smnbbrv)) | [https://github.com/smnbbrv/ngx-plyr](https://github.com/smnbbrv/ngx-plyr) |
| React | Chintan Prajapati ([@chintan9](https://github.com/chintan9)) | [https://github.com/chintan9/plyr-react](https://github.com/chintan9/plyr-react) | | React | Chintan Prajapati ([@chintan9](https://github.com/chintan9)) | [https://github.com/chintan9/plyr-react](https://github.com/chintan9/plyr-react) |
| Vue | Gabe Dunn ([@redxtech](https://github.com/redxtech)) | [https://github.com/redxtech/vue-plyr](https://github.com/redxtech/vue-plyr) | | Vue | Gabe Dunn ([@redxtech](https://github.com/redxtech)) | [https://github.com/redxtech/vue-plyr](https://github.com/redxtech/vue-plyr) |
| Neos | Jon Uhlmann ([@jonnitto](https://github.com/jonnitto)) | [https://packagist.org/packages/jonnitto/plyr](https://packagist.org/packages/jonnitto/plyr) | | 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) | | 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) | | 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 # Issues

View File

@ -105,14 +105,6 @@
</button> </button>
</p> </p>
<p>
Premium video monetization from
<a href="https://vi.ai/publisher-video-monetization/?aid=plyrio" target="_blank" class="no-border">
<img src="https://cdn.plyr.io/static/vi-logo-24x24.svg" alt="ai.vi" />
<span class="sr-only">ai.vi</span>
</a>
</p>
<div class="call-to-action"> <div class="call-to-action">
<a href="https://github.com/sampotts/plyr" target="_blank" class="button js-shr"> <a href="https://github.com/sampotts/plyr" target="_blank" class="button js-shr">
<svg class="icon" role="presentation"> <svg class="icon" role="presentation">

View File

@ -2,8 +2,8 @@
// Plyr.io Demo Page // Plyr.io Demo Page
// ========================================================================== // ==========================================================================
@charset 'UTF-8'; @charset 'UTF-8';
@import '../../../../src/sass/lib/css-vars'; @import '../../../../src/sass/lib/css-vars';
$css-vars-use-native: true; $css-vars-use-native: true;
// Settings // Settings

View File

@ -45,7 +45,7 @@
} }
&.tab-focus { &.tab-focus {
@include tab-focus(); @include tab-focus;
} }
&:active { &:active {
@ -64,7 +64,7 @@
// Count bubble // Count bubble
.button__count { .button__count {
animation: fadein 0.2s ease; animation: fade-in 0.2s ease;
background: $color-button-count-background; background: $color-button-count-background;
color: $color-button-count-text; color: $color-button-count-text;
margin-left: ($spacing-base * 0.75); margin-left: ($spacing-base * 0.75);

View File

@ -7,7 +7,7 @@ header {
text-align: center; text-align: center;
h1 span { h1 span {
animation: shrinkHide 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) 2s forwards; animation: shrink-hide 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) 2s forwards;
display: inline-block; display: inline-block;
font-weight: $font-weight-light; font-weight: $font-weight-light;
opacity: 0.5; opacity: 0.5;

View File

@ -2,6 +2,8 @@
// Icons // Icons
// ========================================================================== // ==========================================================================
@use 'sass:math';
// Base size icon styles // Base size icon styles
.icon { .icon {
fill: currentColor; fill: currentColor;
@ -19,5 +21,5 @@ label svg {
a .icon, a .icon,
.btn .icon { .btn .icon {
margin-right: ($spacing-base / 2); margin-right: math.div($spacing-base, 4);
} }

View File

@ -5,7 +5,7 @@
// Make a <button> look like an <a> // Make a <button> look like an <a>
button.faux-link { button.faux-link {
@extend a; // stylelint-disable-line @extend a; // stylelint-disable-line
@include cancel-button-styles(); @include cancel-button-styles;
} }
// Links // Links
@ -39,7 +39,7 @@ a {
} }
&.tab-focus { &.tab-focus {
@include tab-focus(); @include tab-focus;
} }
&.no-border::after { &.no-border::after {

View File

@ -2,6 +2,8 @@
// Examples // Examples
// ========================================================================== // ==========================================================================
@use 'sass:math';
// Example players // Example players
.plyr { .plyr {
border-radius: $border-radius-large; border-radius: $border-radius-large;
@ -31,6 +33,6 @@
color: $color-gray-500; color: $color-gray-500;
.icon { .icon {
margin-right: ceil($spacing-base / 6); margin-right: math.div($spacing-base, 6);
} }
} }

View File

@ -2,6 +2,8 @@
// Core // Core
// ========================================================================== // ==========================================================================
@use 'sass:math';
html, html,
body { body {
display: flex; display: flex;
@ -46,7 +48,7 @@ aside {
.icon { .icon {
fill: $color-twitter; fill: $color-twitter;
margin-right: ($spacing-base / 2); margin-right: math.div($spacing-base, 2);
} }
p { p {

View File

@ -3,23 +3,26 @@
// ========================================================================== // ==========================================================================
// Fade // Fade
@keyframes fadein { @keyframes fade-in {
0% { 0% {
opacity: 0; opacity: 0;
} }
100% { 100% {
opacity: 1; opacity: 1;
} }
} }
@keyframes shrinkHide { @keyframes shrink-hide {
0% { 0% {
opacity: 0.5; opacity: 0.5;
width: 38px; width: 38px;
} }
20% { 20% {
width: 45px; width: 45px;
} }
100% { 100% {
opacity: 0; opacity: 0;
width: 0; width: 0;

View File

@ -4,7 +4,7 @@
@font-face { @font-face {
font-display: swap; font-display: swap;
font-family: 'Gordita'; font-family: Gordita;
font-style: normal; font-style: normal;
font-weight: $font-weight-light; font-weight: $font-weight-light;
src: url('https://cdn.plyr.io/static/fonts/gordita-light.woff2') format('woff2'), src: url('https://cdn.plyr.io/static/fonts/gordita-light.woff2') format('woff2'),
@ -13,7 +13,7 @@
@font-face { @font-face {
font-display: swap; font-display: swap;
font-family: 'Gordita'; font-family: Gordita;
font-style: normal; font-style: normal;
font-weight: $font-weight-regular; font-weight: $font-weight-regular;
src: url('https://cdn.plyr.io/static/fonts/gordita-regular.woff2') format('woff2'), src: url('https://cdn.plyr.io/static/fonts/gordita-regular.woff2') format('woff2'),
@ -22,7 +22,7 @@
@font-face { @font-face {
font-display: swap; font-display: swap;
font-family: 'Gordita'; font-family: Gordita;
font-style: normal; font-style: normal;
font-weight: $font-weight-medium; font-weight: $font-weight-medium;
src: url('https://cdn.plyr.io/static/fonts/gordita-medium.woff2') format('woff2'), src: url('https://cdn.plyr.io/static/fonts/gordita-medium.woff2') format('woff2'),
@ -31,7 +31,7 @@
@font-face { @font-face {
font-display: swap; font-display: swap;
font-family: 'Gordita'; font-family: Gordita;
font-style: normal; font-style: normal;
font-weight: $font-weight-bold; font-weight: $font-weight-bold;
src: url('https://cdn.plyr.io/static/fonts/gordita-bold.woff2') format('woff2'), src: url('https://cdn.plyr.io/static/fonts/gordita-bold.woff2') format('woff2'),
@ -40,7 +40,7 @@
@font-face { @font-face {
font-display: swap; font-display: swap;
font-family: 'Gordita'; font-family: Gordita;
font-style: normal; font-style: normal;
font-weight: $font-weight-black; font-weight: $font-weight-black;
src: url('https://cdn.plyr.io/static/fonts/gordita-black.woff2') format('woff2'), src: url('https://cdn.plyr.io/static/fonts/gordita-black.woff2') format('woff2'),

View File

@ -2,6 +2,8 @@
// Mixins // Mixins
// ========================================================================== // ==========================================================================
@use 'sass:math';
// Convert a <button> into an <a> // Convert a <button> into an <a>
// --------------------------------------- // ---------------------------------------
@mixin cancel-button-styles() { @mixin cancel-button-styles() {
@ -16,7 +18,7 @@
position: relative; position: relative;
text-align: inherit; text-align: inherit;
text-shadow: inherit; text-shadow: inherit;
-moz-user-select: text; // stylelint-disable-line user-select: text;
vertical-align: baseline; vertical-align: baseline;
width: auto; width: auto;
} }
@ -32,7 +34,7 @@
// Leave <body> at 100%/16px // Leave <body> at 100%/16px
// --------------------------------------- // ---------------------------------------
@function calculate-rem($size) { @function calculate-rem($size) {
$rem: $size / 16; $rem: math.div($size, 16);
@return #{$rem}rem; @return #{$rem}rem;
} }

View File

@ -11,8 +11,7 @@
html { html {
line-height: 1.15; /* 1 */ line-height: 1.15; /* 1 */
-ms-text-size-adjust: 100%; /* 2 */ text-size-adjust: 100%; /* 2 */
-webkit-text-size-adjust: 100%; /* 2 */
} }
/* Sections /* Sections
@ -89,7 +88,7 @@ hr {
*/ */
pre { pre {
font-family: monospace, monospace; /* 1 */ font-family: monospace; /* 1 */
font-size: 1em; /* 2 */ font-size: 1em; /* 2 */
} }
@ -103,7 +102,7 @@ pre {
a { a {
background-color: transparent; /* 1 */ background-color: transparent; /* 1 */
-webkit-text-decoration-skip: objects; /* 2 */ text-decoration-skip: objects; /* 2 */
} }
/** /**
@ -112,7 +111,7 @@ a {
*/ */
abbr[title] { abbr[title] {
border-bottom: none; /* 1 */ border-bottom: 0; /* 1 */
text-decoration: underline; /* 2 */ text-decoration: underline; /* 2 */
text-decoration: underline dotted; /* 2 */ text-decoration: underline dotted; /* 2 */
} }
@ -281,7 +280,7 @@ button,
html [type='button'], html [type='button'],
[type='reset'], [type='reset'],
[type='submit'] { [type='submit'] {
-webkit-appearance: button; /* 2 */ appearance: button; /* 2 */
} }
/** /**
@ -375,7 +374,7 @@ textarea {
*/ */
[type='search'] { [type='search'] {
-webkit-appearance: textfield; /* 1 */ appearance: textfield; /* 1 */
outline-offset: -2px; /* 2 */ outline-offset: -2px; /* 2 */
} }
@ -385,7 +384,7 @@ textarea {
[type='search']::-webkit-search-cancel-button, [type='search']::-webkit-search-cancel-button,
[type='search']::-webkit-search-decoration { [type='search']::-webkit-search-decoration {
-webkit-appearance: none; appearance: none;
} }
/** /**
@ -394,7 +393,7 @@ textarea {
*/ */
::-webkit-file-upload-button { ::-webkit-file-upload-button {
-webkit-appearance: button; /* 1 */ appearance: button; /* 1 */
font: inherit; /* 2 */ font: inherit; /* 2 */
} }

View File

@ -3,7 +3,7 @@
// ========================================================================== // ==========================================================================
// Grayscale // Grayscale
$color-gray-900: hsl(210, 15%, 16%); $color-gray-900: hsl(210deg 15% 16%);
$color-gray-800: lighten($color-gray-900, 9%); $color-gray-800: lighten($color-gray-900, 9%);
$color-gray-700: lighten($color-gray-800, 9%); $color-gray-700: lighten($color-gray-800, 9%);
$color-gray-600: lighten($color-gray-700, 9%); $color-gray-600: lighten($color-gray-700, 9%);
@ -15,7 +15,7 @@ $color-gray-100: lighten($color-gray-200, 9%);
$color-gray-50: lighten($color-gray-100, 9%); $color-gray-50: lighten($color-gray-100, 9%);
// Branding // Branding
$color-brand-primary: hsl(198, 100%, 50%); $color-brand-primary: hsl(198deg 100% 50%);
// Text // Text
$color-text: $color-gray-700; $color-text: $color-gray-700;
@ -28,13 +28,13 @@ $color-twitter: #4baaf4;
$color-link: $color-brand-primary; $color-link: $color-brand-primary;
// Background // Background
$color-background-from: hsl(198, 100%, 94%); $color-background-from: hsl(198deg 100% 94%);
$color-background-to: hsl(198, 100%, 98%); $color-background-to: hsl(198deg 100% 98%);
// Buttons // Buttons
$color-button-background: $color-brand-primary; $color-button-background: $color-brand-primary;
$color-button-text: #fff; $color-button-text: #fff;
$color-button-background-hover: hsl(198, 100%, 55%); $color-button-background-hover: hsl(198deg 100% 55%);
$color-button-count-background: #fff; $color-button-count-background: #fff;
$color-button-count-text: $color-gray-600; $color-button-count-text: $color-gray-600;

View File

@ -4,18 +4,14 @@
$font-sans-serif: 'Gordita', 'Avenir', 'Helvetica Neue', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', $font-sans-serif: 'Gordita', 'Avenir', 'Helvetica Neue', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji',
'Segoe UI Symbol'; 'Segoe UI Symbol';
$font-size-base: 15; $font-size-base: 15;
$font-size-small: 13; $font-size-small: 13;
$font-size-large: 18; $font-size-large: 18;
$font-size-h1: 64; $font-size-h1: 64;
$font-weight-light: 300; $font-weight-light: 300;
$font-weight-regular: 400; $font-weight-regular: 400;
$font-weight-medium: 500; $font-weight-medium: 500;
$font-weight-bold: 600; $font-weight-bold: 600;
$font-weight-black: 900; $font-weight-black: 900;
$line-height-base: 1.75; $line-height-base: 1.75;
$letter-spacing-headings: -0.025em; $letter-spacing-headings: -0.025em;

View File

@ -8,8 +8,9 @@ html {
} }
body { body {
@include font-smoothing(); @include font-smoothing;
@include font-size($font-size-base); @include font-size($font-size-base);
color: $color-text; color: $color-text;
font-family: $font-sans-serif; font-family: $font-sans-serif;
font-weight: $font-weight-medium; font-weight: $font-weight-medium;
@ -30,5 +31,6 @@ small {
small { small {
@include font-size($font-size-small); @include font-size($font-size-small);
display: block; display: block;
} }

View File

@ -4,6 +4,7 @@
h1 { h1 {
@include font-size($font-size-h1); @include font-size($font-size-h1);
color: $color-headings; color: $color-headings;
font-weight: $font-weight-bold; font-weight: $font-weight-bold;
letter-spacing: $letter-spacing-headings; letter-spacing: $letter-spacing-headings;

View File

@ -1,6 +1,6 @@
{ {
"name": "plyr", "name": "plyr",
"version": "3.6.6", "version": "3.6.12",
"description": "A simple, accessible and customizable HTML5, YouTube and Vimeo media player", "description": "A simple, accessible and customizable HTML5, YouTube and Vimeo media player",
"homepage": "https://plyr.io", "homepage": "https://plyr.io",
"author": "Sam Potts <sam@potts.es>", "author": "Sam Potts <sam@potts.es>",
@ -31,24 +31,24 @@
"browserslist": "> 1%", "browserslist": "> 1%",
"scripts": { "scripts": {
"build": "gulp build", "build": "gulp build",
"lint": "eslint src/js && npm run-script remark", "lint": "eslint src/js && npm run remark && stylelint **/*.scss",
"lint:fix": "eslint --fix src/js", "lint:fix": "eslint --fix src/js && stylelint **/*.scss --fix",
"remark": "remark -f --use 'validate-links=repository:\"sampotts/plyr\"' '{,!(node_modules),.?**/}*.md'", "remark": "remark -f --use 'validate-links=repository:\"sampotts/plyr\"' '{,!(node_modules),.?**/}*.md'",
"deploy": "yarn lint && gulp version && gulp build && gulp deploy", "deploy": "yarn lint && gulp version && gulp build && gulp deploy",
"format": "prettier --write \"./{src,demo/src}/**/*.{js,scss}\"", "format": "prettier --write \"./{src,demo/src}/**/*.{js,scss}\"",
"start": "gulp" "start": "gulp"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.16.5",
"@babel/plugin-proposal-class-properties": "^7.16.5",
"@babel/preset-env": "^7.16.5",
"@sampotts/eslint-config": "1.1.7", "@sampotts/eslint-config": "1.1.7",
"autoprefixer": "^10.2.5", "autoprefixer": "^10.4.0",
"aws-sdk": "^2.888.0", "aws-sdk": "^2.1046.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", "babel-eslint": "^10.1.0",
"browser-sync": "^2.26.14", "browser-sync": "^2.27.7",
"colorette": "1.2.2", "colorette": "2.0.16",
"cssnano": "^5.0.1", "cssnano": "^5.0.13",
"del": "^6.0.0", "del": "^6.0.0",
"eslint": "^7.23.0", "eslint": "^7.23.0",
"fancy-log": "^1.3.3", "fancy-log": "^1.3.3",
@ -56,41 +56,40 @@
"gulp": "^4.0.2", "gulp": "^4.0.2",
"gulp-awspublish": "^4.1.2", "gulp-awspublish": "^4.1.2",
"gulp-better-rollup": "^4.0.1", "gulp-better-rollup": "^4.0.1",
"gulp-filter": "^6.0.0", "gulp-filter": "^7.0.0",
"gulp-header": "^2.0.9", "gulp-header": "^2.0.9",
"gulp-hub": "^4.2.0", "gulp-hub": "^4.2.0",
"gulp-if": "^3.0.0", "gulp-if": "^3.0.0",
"gulp-imagemin": "^7.1.0", "gulp-imagemin": "^7.1.0",
"gulp-open": "^3.0.1", "gulp-open": "^3.0.1",
"gulp-plumber": "^1.2.1", "gulp-plumber": "^1.2.1",
"gulp-postcss": "^9.0.0", "gulp-postcss": "^9.0.1",
"gulp-rename": "^2.0.0", "gulp-rename": "^2.0.0",
"gulp-replace": "^1.0.0", "gulp-replace": "^1.1.3",
"gulp-sass": "^4.1.0", "gulp-sass": "^5.0.0",
"gulp-size": "^3.0.0", "gulp-size": "^4.0.1",
"gulp-sourcemaps": "^3.0.0", "gulp-sourcemaps": "^3.0.0",
"gulp-svgstore": "^7.0.1", "gulp-svgstore": "^9.0.0",
"gulp-terser": "^2.0.1", "gulp-terser": "^2.1.0",
"postcss": "^8.2.10", "postcss": "^8.4.5",
"postcss-custom-properties": "^11.0.0", "postcss-custom-properties": "^12.0.1",
"postcss-scss": "^4.0.2",
"prettier-eslint": "^12.0.0", "prettier-eslint": "^12.0.0",
"prettier-stylelint": "^0.4.2", "prettier-stylelint": "^0.4.2",
"remark-cli": "^9.0.0", "remark-cli": "^10.0.1",
"remark-validate-links": "^10.0.4", "remark-validate-links": "^11.0.2",
"rollup": "^2.45.2", "rollup": "^2.61.1",
"rollup-plugin-babel": "^4.4.0", "rollup-plugin-babel": "^4.4.0",
"rollup-plugin-commonjs": "^10.1.0", "rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-node-resolve": "^5.2.0", "rollup-plugin-node-resolve": "^5.2.0",
"stylelint": "^13.12.0", "sass": "^1.45.0",
"stylelint-config-prettier": "^8.0.2", "stylelint": "^14.1.0",
"stylelint-config-recommended": "^4.0.0", "stylelint-config-prettier": "^9.0.3",
"stylelint-config-sass-guidelines": "^8.0.0", "stylelint-config-sass-guidelines": "^9.0.1",
"stylelint-order": "^4.1.0", "stylelint-selector-bem-pattern": "^2.1.1"
"stylelint-scss": "^3.19.0",
"stylelint-selector-bem-pattern": "^2.1.0"
}, },
"dependencies": { "dependencies": {
"core-js": "^3.10.1", "core-js": "^3.20.0",
"custom-event-polyfill": "^1.0.7", "custom-event-polyfill": "^1.0.7",
"loadjs": "^4.2.0", "loadjs": "^4.2.0",
"rangetouch": "^2.0.1", "rangetouch": "^2.0.1",

View File

@ -12,7 +12,9 @@
// Linting // Linting
"stylelint.enable": true, "stylelint.enable": true,
"stylelint.validate": ["css", "scss"],
"css.validate": false, "css.validate": false,
"less.validate": false,
"scss.validate": false, "scss.validate": false,
"javascript.validate.enable": false, "javascript.validate.enable": false,

View File

@ -154,7 +154,9 @@ const captions = {
} }
// 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)); if (this.elements) {
toggleClass(this.elements.container, this.config.classNames.captions.enabled, !is.empty(tracks));
}
// Update available languages in list // Update available languages in list
if ( if (

View File

@ -61,7 +61,7 @@ const defaults = {
// Sprite (for icons) // Sprite (for icons)
loadSprite: true, loadSprite: true,
iconPrefix: 'plyr', iconPrefix: 'plyr',
iconUrl: 'https://cdn.plyr.io/3.6.6/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',
@ -398,6 +398,7 @@ const defaults = {
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',
}, },
}, },

3
src/js/controls.js vendored
View File

@ -38,7 +38,8 @@ const controls = {
// 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,

View File

@ -124,7 +124,9 @@ class Fullscreen {
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;
} }

View File

@ -73,7 +73,7 @@ const html5 = {
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)) {
player.config.quality.onChange(input); player.config.quality.onChange(input);
} else { } else {

View File

@ -10,7 +10,7 @@ import { getElement, getElements, matches, toggleClass } from './utils/elements'
import { off, on, once, toggleListener, triggerEvent } from './utils/events'; import { off, on, once, toggleListener, triggerEvent } from './utils/events';
import is from './utils/is'; import is from './utils/is';
import { silencePromise } from './utils/promise'; import { silencePromise } from './utils/promise';
import { getAspectRatio, setAspectRatio } from './utils/style'; import { getAspectRatio, getViewportSize, supportsCSS } from './utils/style';
class Listeners { class Listeners {
constructor(player) { constructor(player) {
@ -149,16 +149,16 @@ class Listeners {
break; break;
/* case 73: /* case 73:
this.setLoop('start'); this.setLoop('start');
break; break;
case 76: case 76:
this.setLoop(); this.setLoop();
break; break;
case 79: case 79:
this.setLoop('end'); this.setLoop('end');
break; */ break; */
default: default:
break; break;
@ -305,39 +305,49 @@ class Listeners {
); );
// Set a gutter for Vimeo // Set a gutter for Vimeo
const setGutter = (ratio, padding, toggle) => { const setGutter = () => {
if (!player.isVimeo || player.config.vimeo.premium) { if (!player.isVimeo || player.config.vimeo.premium) {
return; return;
} }
const target = player.elements.wrapper.firstChild; const target = elements.wrapper;
const [, y] = ratio; const { active } = player.fullscreen;
const [videoX, videoY] = getAspectRatio.call(player); const [videoWidth, videoHeight] = getAspectRatio.call(player);
const useNativeAspectRatio = supportsCSS(`aspect-ratio: ${videoWidth} / ${videoHeight}`);
target.style.maxWidth = toggle ? `${(y / videoY) * videoX}px` : null; // If not active, remove styles
target.style.margin = toggle ? '0 auto' : null; if (!active) {
}; if (useNativeAspectRatio) {
target.style.width = null;
// Resize on fullscreen change target.style.height = null;
const setPlayerSize = (measure) => { } else {
// If we don't need to measure the viewport target.style.maxWidth = null;
if (!measure) { target.style.margin = null;
return setAspectRatio.call(player); }
return;
} }
const rect = elements.container.getBoundingClientRect(); // Determine which dimension will overflow and constrain view
const { width, height } = rect; const [viewportWidth, viewportHeight] = getViewportSize();
const overflow = viewportWidth / viewportHeight > videoWidth / videoHeight;
return setAspectRatio.call(player, `${width}:${height}`); if (useNativeAspectRatio) {
target.style.width = overflow ? 'auto' : '100%';
target.style.height = overflow ? '100%' : 'auto';
} else {
target.style.maxWidth = overflow ? `${(viewportHeight / videoHeight) * videoWidth}px` : null;
target.style.margin = overflow ? '0 auto' : null;
}
}; };
// Handle resizing
const resized = () => { const resized = () => {
clearTimeout(timers.resized); clearTimeout(timers.resized);
timers.resized = setTimeout(setPlayerSize, 50); timers.resized = setTimeout(setGutter, 50);
}; };
on.call(player, elements.container, 'enterfullscreen exitfullscreen', (event) => { on.call(player, elements.container, 'enterfullscreen exitfullscreen', (event) => {
const { target, usingNative } = player.fullscreen; const { target } = player.fullscreen;
// Ignore events not from target // Ignore events not from target
if (target !== elements.container) { if (target !== elements.container) {
@ -349,26 +359,12 @@ class Listeners {
return; return;
} }
const isEnter = event.type === 'enterfullscreen';
// Set the player size when entering fullscreen to viewport size
const { padding, ratio } = setPlayerSize(isEnter);
// Set Vimeo gutter // Set Vimeo gutter
setGutter(ratio, padding, isEnter); setGutter();
// Horrible hack for Safari 14 not repainting properly on entering fullscreen // Watch for resizes
if (isEnter) { const method = event.type === 'enterfullscreen' ? on : off;
setTimeout(() => repaint(elements.container), 100); method.call(player, window, 'resize', resized);
}
// If not using native browser fullscreen API, we need to check for resizes of viewport
if (!usingNative) {
if (isEnter) {
on.call(player, window, 'resize', resized);
} else {
off.call(player, window, 'resize', resized);
}
}
}); });
}; };
@ -845,7 +841,9 @@ class Listeners {
.filter((c) => !c.contains(elements.container)) .filter((c) => !c.contains(elements.container))
.forEach((child) => { .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';
}
}); });
}); });
} }

View File

@ -213,8 +213,8 @@ class Ads {
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);
} }
}; };

View File

@ -28,6 +28,21 @@ function parseId(url) {
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}[&params]
* - [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)
function assurePlaybackState(play) { function assurePlaybackState(play) {
if (play && !this.embed.hasPlayed) { if (play && !this.embed.hasPlayed) {
@ -71,6 +86,18 @@ const vimeo = {
const player = this; const player = this;
const config = player.config.vimeo; const config = player.config.vimeo;
const { premium, referrerPolicy, ...frameParams } = config; 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 the owner has a pro or premium account then we can hide controls etc
if (premium) { if (premium) {
@ -87,17 +114,11 @@ const vimeo = {
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(source); const id = parseId(source);
// Build an iframe // Build an iframe
const iframe = createElement('iframe'); const iframe = createElement('iframe');

22
src/js/plyr.d.ts vendored
View File

@ -211,6 +211,11 @@ declare class Plyr {
*/ */
airplay(): void; 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. * Toggle the controls (video only). Takes optional truthy value to force it on/off.
*/ */
@ -238,8 +243,10 @@ declare class Plyr {
/** /**
* Destroy lib instance * 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 { 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. * 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. * 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. * 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 { interface AdOptions {
enabled: boolean; enabled: boolean;
publisherId: string; publisherId?: string;
tagUrl?: string;
} }
interface SpeedOptions { interface SpeedOptions {
@ -549,6 +557,7 @@ declare namespace Plyr {
fallback?: boolean | 'force'; fallback?: boolean | 'force';
allowAudio?: boolean; allowAudio?: boolean;
iosNative?: boolean; iosNative?: boolean;
container?: string;
} }
interface CaptionOptions { interface CaptionOptions {
@ -615,6 +624,11 @@ declare namespace Plyr {
* Booleans are converted to HTML5 value-less attributes. * Booleans are converted to HTML5 value-less attributes.
*/ */
tracks?: Track[]; tracks?: Track[];
/**
* Enable or disable preview thumbnails for current source
*/
previewThumbnails?: Plyr.PreviewThumbnailsOptions;
} }
interface Source { interface Source {
@ -653,7 +667,7 @@ declare namespace Plyr {
} }
interface PlyrEvent extends CustomEvent { interface PlyrEvent extends CustomEvent {
readonly detail: { readonly plyr: Plyr }; readonly detail: {readonly plyr: Plyr};
} }
enum YoutubeState { enum YoutubeState {

View File

@ -1,6 +1,6 @@
// ========================================================================== // ==========================================================================
// Plyr // Plyr
// plyr.js v3.6.6 // plyr.js v3.6.12
// https://github.com/sampotts/plyr // https://github.com/sampotts/plyr
// License: The MIT License (MIT) // License: The MIT License (MIT)
// ========================================================================== // ==========================================================================
@ -72,7 +72,7 @@ class Plyr {
(() => { (() => {
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 {};
} }
})(), })(),
@ -675,7 +675,9 @@ class Plyr {
// Set media speed // Set media speed
setTimeout(() => { setTimeout(() => {
this.media.playbackRate = speed; if (this.media) {
this.media.playbackRate = speed;
}
}, 0); }, 0);
} }
@ -956,6 +958,7 @@ class Plyr {
*/ */
set currentTrack(input) { set currentTrack(input) {
captions.set.call(this, input, false); captions.set.call(this, input, false);
captions.setup();
} }
/** /**
@ -1029,6 +1032,23 @@ class Plyr {
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

View File

@ -1,6 +1,6 @@
// ========================================================================== // ==========================================================================
// Plyr Polyfilled Build // Plyr Polyfilled Build
// plyr.js v3.6.6 // plyr.js v3.6.12
// https://github.com/sampotts/plyr // https://github.com/sampotts/plyr
// License: The MIT License (MIT) // License: The MIT License (MIT)
// ========================================================================== // ==========================================================================

View File

@ -26,7 +26,7 @@ class Storage {
window.localStorage.removeItem(test); window.localStorage.removeItem(test);
return true; return true;
} catch (e) { } catch (_) {
return false; return false;
} }
} }
@ -70,7 +70,11 @@ class Storage {
extend(storage, object); extend(storage, object);
// Update storage // Update storage
window.localStorage.setItem(this.key, JSON.stringify(storage)); try {
window.localStorage.setItem(this.key, JSON.stringify(storage));
} catch (_) {
// Do nothing
}
}; };
} }

View File

@ -88,7 +88,7 @@ const support = {
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;
} }
}, },

View File

@ -82,6 +82,9 @@ const ui = {
// Reset time display // Reset time display
controls.timeUpdate.call(this); controls.timeUpdate.call(this);
// Reset duration display
controls.durationUpdate.call(this);
// Update the UI // Update the UI
ui.checkPlaying.call(this); ui.checkPlaying.call(this);
@ -181,13 +184,13 @@ const ui = {
.call(this) .call(this)
// Load image // Load image
.then(() => loadImage(poster)) .then(() => loadImage(poster))
.catch((err) => { .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

View File

@ -31,7 +31,7 @@ export function repaint(element, delay) {
// eslint-disable-next-line no-param-reassign // eslint-disable-next-line no-param-reassign
element.hidden = false; element.hidden = false;
} catch (e) { } catch (_) {
// Do nothing // Do nothing
} }
}, delay); }, delay);

View File

@ -8,7 +8,9 @@ const browser = {
isEdge: window.navigator.userAgent.includes('Edge'), isEdge: window.navigator.userAgent.includes('Edge'),
isWebkit: 'WebkitAppearance' in document.documentElement.style && !/Edge/.test(navigator.userAgent), isWebkit: 'WebkitAppearance' in document.documentElement.style && !/Edge/.test(navigator.userAgent),
isIPhone: /(iPhone|iPod)/gi.test(navigator.platform), isIPhone: /(iPhone|iPod)/gi.test(navigator.platform),
isIos: /(iPad|iPhone|iPod)/gi.test(navigator.platform), isIos:
(navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1) ||
/(iPad|iPhone|iPod)/gi.test(navigator.platform),
}; };
export default browser; export default browser;

View File

@ -19,7 +19,7 @@ const supportsPassiveListeners = (() => {
}); });
window.addEventListener('test', null, options); window.addEventListener('test', null, options);
window.removeEventListener('test', null, options); window.removeEventListener('test', null, options);
} catch (e) { } catch (_) {
// Do nothing // Do nothing
} }

View File

@ -17,7 +17,7 @@ export default function fetch(url, responseType = 'text') {
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 {
@ -35,8 +35,8 @@ export default function fetch(url, responseType = 'text') {
request.responseType = responseType; request.responseType = responseType;
request.send(); request.send();
} catch (e) { } catch (error) {
reject(e); reject(error);
} }
}); });
} }

View File

@ -51,7 +51,7 @@ const isUrl = (input) => {
try { try {
return !isEmpty(new URL(string).hostname); return !isEmpty(new URL(string).hostname);
} catch (e) { } catch (_) {
return false; return false;
} }
}; };

View File

@ -60,12 +60,16 @@ export default function loadSprite(url, id) {
} }
if (useStorage) { if (useStorage) {
window.localStorage.setItem( try {
`${prefix}-${id}`, window.localStorage.setItem(
JSON.stringify({ `${prefix}-${id}`,
content: result, JSON.stringify({
}), content: result,
); }),
);
} catch (_) {
// Do nothing
}
} }
update(container, result); update(container, result);

View File

@ -5,6 +5,15 @@
import { closest } from './arrays'; import { closest } from './arrays';
import is from './is'; import is from './is';
// Check support for a CSS declaration
export function supportsCSS(declaration) {
if (!window || !window.CSS) {
return false;
}
return window.CSS.supports(declaration);
}
// Standard/common aspect ratios // Standard/common aspect ratios
const standardRatios = [ const standardRatios = [
[1, 1], [1, 1],
@ -67,10 +76,10 @@ export function getAspectRatio(input) {
// Get from HTML5 video // Get from HTML5 video
if (ratio === null && this.isHTML5) { if (ratio === null && this.isHTML5) {
const { videoWidth, videoHeight } = this.media; const { videoWidth, videoHeight } = this.media;
ratio = reduceAspectRatio([videoWidth, videoHeight]); ratio = [videoWidth, videoHeight];
} }
return ratio; return reduceAspectRatio(ratio);
} }
// Set aspect ratio for responsive container // Set aspect ratio for responsive container
@ -86,8 +95,8 @@ export function setAspectRatio(input) {
return {}; return {};
} }
const [x, y] = ratio; const [x, y] = reduceAspectRatio(ratio);
const useNative = window.CSS?.supports(`aspect-ratio: ${x} / ${y}`) ?? false; const useNative = supportsCSS(`aspect-ratio: ${x}/${y}`);
const padding = (100 / x) * y; const padding = (100 / x) * y;
if (useNative) { if (useNative) {
@ -107,7 +116,7 @@ export function setAspectRatio(input) {
this.media.style.transform = `translateY(-${offset}%)`; this.media.style.transform = `translateY(-${offset}%)`;
} }
} else if (this.isHTML5) { } else if (this.isHTML5) {
wrapper.classList.toggle(this.config.classNames.videoFixedRatio, ratio !== null); wrapper.classList.add(this.config.classNames.videoFixedRatio);
} }
return { padding, ratio }; return { padding, ratio };
@ -127,4 +136,10 @@ export function roundAspectRatio(x, y, tolerance = 0.05) {
return [x, y]; return [x, y];
} }
export default { setAspectRatio }; // Get the size of the viewport
// https://stackoverflow.com/questions/1248081/how-to-get-the-browser-viewport-dimensions
export function getViewportSize() {
const width = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0);
const height = Math.max(document.documentElement.clientHeight || 0, window.innerHeight || 0);
return [width, height];
}

View File

@ -20,7 +20,7 @@ export function parseUrl(input, safe = true) {
try { try {
return new URL(url); return new URL(url);
} catch (e) { } catch (_) {
return null; return null;
} }
} }

View File

@ -5,6 +5,7 @@
// Base // Base
.plyr { .plyr {
@include plyr-font-smoothing($plyr-font-smoothing); @include plyr-font-smoothing($plyr-font-smoothing);
align-items: center; align-items: center;
direction: ltr; direction: ltr;
display: flex; display: flex;

View File

@ -29,7 +29,7 @@
// Tab focus // Tab focus
&.plyr__tab-focus { &.plyr__tab-focus {
@include plyr-tab-focus(); @include plyr-tab-focus;
} }
} }

View File

@ -56,6 +56,7 @@
.plyr [data-plyr='fullscreen'] { .plyr [data-plyr='fullscreen'] {
display: none; display: none;
} }
.plyr--captions-enabled [data-plyr='captions'], .plyr--captions-enabled [data-plyr='captions'],
.plyr--pip-supported [data-plyr='pip'], .plyr--pip-supported [data-plyr='pip'],
.plyr--airplay-supported [data-plyr='airplay'], .plyr--airplay-supported [data-plyr='airplay'],

View File

@ -10,6 +10,7 @@
.plyr__control svg { .plyr__control svg {
transition: transform 0.3s ease; transition: transform 0.3s ease;
} }
.plyr__control[aria-expanded='true'] { .plyr__control[aria-expanded='true'] {
svg { svg {
transform: rotate(90deg); transform: rotate(90deg);
@ -73,10 +74,7 @@
color: $plyr-menu-color; color: $plyr-menu-color;
display: flex; display: flex;
font-size: $plyr-font-size-menu; font-size: $plyr-font-size-menu;
padding-bottom: calc(#{$plyr-control-padding} / 1.5); padding: calc(#{$plyr-control-padding} / 1.5) calc(#{$plyr-control-padding} * 1.5);
padding-left: calc(#{$plyr-control-padding} * 1.5);
padding-right: calc(#{$plyr-control-padding} * 1.5);
padding-top: calc(#{$plyr-control-padding} / 1.5);
user-select: none; user-select: none;
width: 100%; width: 100%;
@ -176,6 +174,7 @@
&::before { &::before {
background: $plyr-control-toggle-checked-background; background: $plyr-control-toggle-checked-background;
} }
&::after { &::after {
opacity: 1; opacity: 1;
transform: translateY(-50%) scale(1); transform: translateY(-50%) scale(1);

View File

@ -3,10 +3,11 @@
// -------------------------------------------------------------- // --------------------------------------------------------------
.plyr--full-ui input[type='range'] { .plyr--full-ui input[type='range'] {
-webkit-appearance: none; /* stylelint-disable-line */ appearance: none;
background: transparent; background: transparent;
border: 0; border: 0;
border-radius: calc(#{$plyr-range-thumb-height} * 2); border-radius: calc(#{$plyr-range-thumb-height} * 2);
// `color` property is used in JS to populate lower fill for WebKit // `color` property is used in JS to populate lower fill for WebKit
color: $plyr-range-fill-background; color: $plyr-range-fill-background;
display: block; display: block;
@ -18,23 +19,25 @@
width: 100%; width: 100%;
&::-webkit-slider-runnable-track { &::-webkit-slider-runnable-track {
@include plyr-range-track(); @include plyr-range-track;
background-image: linear-gradient(to right, currentColor var(--value, 0%), transparent var(--value, 0%)); background-image: linear-gradient(to right, currentColor var(--value, 0%), transparent var(--value, 0%));
} }
&::-webkit-slider-thumb { &::-webkit-slider-thumb {
@include plyr-range-thumb(); @include plyr-range-thumb;
-webkit-appearance: none; /* stylelint-disable-line */
appearance: none;
margin-top: calc(((#{$plyr-range-thumb-height} - #{$plyr-range-track-height}) / 2) * -1); margin-top: calc(((#{$plyr-range-thumb-height} - #{$plyr-range-track-height}) / 2) * -1);
} }
// Mozilla // Mozilla
&::-moz-range-track { &::-moz-range-track {
@include plyr-range-track(); @include plyr-range-track;
} }
&::-moz-range-thumb { &::-moz-range-thumb {
@include plyr-range-thumb(); @include plyr-range-thumb;
} }
&::-moz-range-progress { &::-moz-range-progress {
@ -45,22 +48,24 @@
// Microsoft // Microsoft
&::-ms-track { &::-ms-track {
@include plyr-range-track(); @include plyr-range-track;
color: transparent; color: transparent;
} }
&::-ms-fill-upper { &::-ms-fill-upper {
@include plyr-range-track(); @include plyr-range-track;
} }
&::-ms-fill-lower { &::-ms-fill-lower {
@include plyr-range-track(); @include plyr-range-track;
background: currentColor; background: currentColor;
} }
&::-ms-thumb { &::-ms-thumb {
@include plyr-range-thumb(); @include plyr-range-thumb;
// For some reason, Edge uses the -webkit margin above // For some reason, Edge uses the -webkit margin above
margin-top: 0; margin-top: 0;
} }
@ -70,25 +75,25 @@
} }
// Focus styles // Focus styles
&:focus {
outline: 0;
}
&::-moz-focus-outer { &::-moz-focus-outer {
border: 0; border: 0;
} }
&:focus {
outline: 0;
}
&.plyr__tab-focus { &.plyr__tab-focus {
&::-webkit-slider-runnable-track { &::-webkit-slider-runnable-track {
@include plyr-tab-focus(); @include plyr-tab-focus;
} }
&::-moz-range-track { &::-moz-range-track {
@include plyr-tab-focus(); @include plyr-tab-focus;
} }
&::-ms-track { &::-ms-track {
@include plyr-tab-focus(); @include plyr-tab-focus;
} }
} }
} }

View File

@ -1,3 +1,4 @@
/* stylelint-disable selector-max-compound-selectors */
// -------------------------------------------------------------- // --------------------------------------------------------------
// Tooltips // Tooltips
// -------------------------------------------------------------- // --------------------------------------------------------------

View File

@ -1,5 +1,8 @@
// Downloaded from https://github.com/malyw/css-vars (and modified) // Downloaded from https://github.com/malyw/css-vars (and modified)
@use 'sass:list';
@use 'sass:map';
// global map to be filled via variables // global map to be filled via variables
$css-vars: (); $css-vars: ();
@ -21,36 +24,35 @@ $css-vars-use-native: false !default;
/// ///
// Emulates var() CSS native function behavior // Emulates var() CSS native function behavior
//
// $args[0] {String} "--" + variable name // $args[0] {String} "--" + variable name
// [$args[1]] Optional default value if variable is not assigned yet // [$args[1]] Optional default value if variable is not assigned yet
//
// E.G.: // E.G.:
// color: var(--main-color); // color: var(--main-color);
// background: var(--main-background, green); // background: var(--main-background, green);
/// ///
@function var($args...) { @function var($args...) {
// CHECK PARAMS // CHECK PARAMS
@if (length($args) ==0) { @if length($args) == 0 {
@error 'Variable name is expected to be passed to the var() function'; @error 'Variable name is expected to be passed to the var() function';
} }
@if (str-length(nth($args, 1)) < 2 or str-slice(nth($args, 1), 0, 2) != '--') {
@if str-length(nth($args, 1)) < 2 or str-slice(nth($args, 1), 0, 2) != '--' {
@error "Variable name is expected to start from '--'"; @error "Variable name is expected to start from '--'";
} }
// PROCESS // PROCESS
$var-name: nth($args, 1); $var-name: list.nth($args, 1);
$var-value: map-get($css-vars, $var-name); $var-value: map.get($css-vars, $var-name);
@if ($css-vars-use-native) { @if $css-vars-use-native {
// CSS variables // CSS variables
// Native CSS: don't process function in case of native // Native CSS: don't process function in case of native
@return unquote('var(' + $args + ')'); @return unquote('var(' + $args + ')');
} @else { } @else {
@if ($var-value == null) { @if not $var-value {
// variable is not provided so far // variable is not provided so far
@if (length($args) == 2) { @if length($args) == 2 {
$var-value: nth($args, 2); $var-value: list.nth($args, 2);
} }
} }
@ -70,20 +72,21 @@ $css-vars-use-native: false !default;
/// ///
@mixin css-vars($var-map: null) { @mixin css-vars($var-map: null) {
// CHECK PARAMS // CHECK PARAMS
@if ($var-map == null) { @if not $var-map {
@error 'Map of variables is expected, instead got: null'; @error 'Map of variables is expected, instead got: null';
} }
@if (type_of($var-map) != map) {
@if type_of($var-map) != map {
@error 'Map of variables is expected, instead got another type passed: #{type_of($var, ap)}'; @error 'Map of variables is expected, instead got another type passed: #{type_of($var, ap)}';
} }
// PROCESS // PROCESS
@if ($css-vars-use-native) { @if $css-vars-use-native {
// CSS variables // CSS variables
// Native CSS: assign CSS custom properties to the global scope // Native CSS: assign CSS custom properties to the global scope
@at-root :root { @at-root :root {
@each $var-name, $var-value in $var-map { @each $var-name, $var-value in $var-map {
@if (type_of($var-value) == string) { @if type_of($var-value) == string {
#{$var-name}: $var-value; // to prevent quotes interpolation #{$var-name}: $var-value; // to prevent quotes interpolation
} @else { } @else {
#{$var-name}: #{$var-value}; #{$var-name}: #{$var-value};

View File

@ -1,7 +1,3 @@
// ==========================================================================
// Useful functions
// ==========================================================================
@function to-percentage($input) { @function to-percentage($input) {
@return $input * 1%; @return $input * 1%;
} }

View File

@ -5,10 +5,8 @@
// Nicer focus styles // Nicer focus styles
// --------------------------------------- // ---------------------------------------
@mixin plyr-tab-focus($color: $plyr-tab-focus-color) { @mixin plyr-tab-focus($color: $plyr-tab-focus-color) {
outline-color: $color; outline: $color dotted 3px;
outline-offset: 2px; outline-offset: 2px;
outline-style: dotted;
outline-width: 3px;
} }
// Font smoothing // Font smoothing
@ -59,17 +57,6 @@
height: 100%; height: 100%;
} }
.plyr__video-wrapper {
height: 100%;
position: static;
}
// Vimeo requires some different styling
&.plyr--vimeo .plyr__video-wrapper {
height: 0;
position: relative;
}
// Display correct icon // Display correct icon
.plyr__control .icon--exit-fullscreen { .plyr__control .icon--exit-fullscreen {
display: block; display: block;

View File

@ -36,7 +36,7 @@
z-index: 3; z-index: 3;
} }
&::after:empty { &:empty::after {
display: none; display: none;
} }
} }
@ -47,10 +47,10 @@
display: block; display: block;
height: $plyr-range-track-height; height: $plyr-range-track-height;
left: 0; left: 0;
margin: -($plyr-range-track-height / 2) 0 0;
opacity: 0.8; opacity: 0.8;
position: absolute; position: absolute;
top: 50%; top: 50%;
transform: translateY(-50%);
width: 3px; width: 3px;
z-index: 3; // Between progress and thumb z-index: 3; // Between progress and thumb
} }

View File

@ -4,15 +4,14 @@
// TODO: Review use of BEM classnames // TODO: Review use of BEM classnames
// ========================================================================== // ==========================================================================
@charset 'UTF-8'; @charset 'UTF-8';
@import 'lib/css-vars'; @import 'lib/css-vars';
$css-vars-use-native: true; $css-vars-use-native: true;
@import 'settings/breakpoints'; @import 'settings/breakpoints';
@import 'settings/colors'; @import 'settings/colors';
@import 'settings/cosmetics'; @import 'settings/cosmetics';
@import 'settings/type'; @import 'settings/type';
@import 'settings/badges'; @import 'settings/badges';
@import 'settings/captions'; @import 'settings/captions';
@import 'settings/controls'; @import 'settings/controls';
@ -21,13 +20,10 @@ $css-vars-use-native: true;
@import 'settings/progress'; @import 'settings/progress';
@import 'settings/sliders'; @import 'settings/sliders';
@import 'settings/tooltips'; @import 'settings/tooltips';
@import 'lib/animation'; @import 'lib/animation';
@import 'lib/functions'; @import 'lib/functions';
@import 'lib/mixins'; @import 'lib/mixins';
@import 'base'; @import 'base';
@import 'components/badges'; @import 'components/badges';
@import 'components/captions'; @import 'components/captions';
@import 'components/control'; @import 'components/control';
@ -39,14 +35,10 @@ $css-vars-use-native: true;
@import 'components/tooltips'; @import 'components/tooltips';
@import 'components/progress'; @import 'components/progress';
@import 'components/volume'; @import 'components/volume';
@import 'types/audio'; @import 'types/audio';
@import 'types/video'; @import 'types/video';
@import 'states/fullscreen'; @import 'states/fullscreen';
@import 'plugins/ads'; @import 'plugins/ads';
@import 'plugins/preview-thumbnails/index'; @import 'plugins/preview-thumbnails/index';
@import 'utils/animation'; @import 'utils/animation';
@import 'utils/hidden'; @import 'utils/hidden';

View File

@ -4,7 +4,6 @@
$plyr-captions-background: var(--plyr-captions-background, rgba(#000, 0.8)) !default; $plyr-captions-background: var(--plyr-captions-background, rgba(#000, 0.8)) !default;
$plyr-captions-text-color: var(--plyr-captions-text-color, #fff) !default; $plyr-captions-text-color: var(--plyr-captions-text-color, #fff) !default;
$plyr-font-size-captions-base: $plyr-font-size-base !default; $plyr-font-size-captions-base: $plyr-font-size-base !default;
$plyr-font-size-captions-small: $plyr-font-size-small !default; $plyr-font-size-captions-small: $plyr-font-size-small !default;
$plyr-font-size-captions-medium: $plyr-font-size-large !default; $plyr-font-size-captions-medium: $plyr-font-size-large !default;

View File

@ -2,17 +2,17 @@
// Colors // Colors
// ========================================================================== // ==========================================================================
$plyr-color-main: var(--plyr-color-main, hsl(198, 100%, 50%)) !default; $plyr-color-main: var(--plyr-color-main, hsl(198deg 100% 50%)) !default;
$plyr-video-background: var(--plyr-video-background, rgba(0,0,0,1)) !default; $plyr-video-background: var(--plyr-video-background, rgb(0 0 0 / 100%)) !default;
// Grayscale // Grayscale
$plyr-color-gray-900: hsl(216, 15%, 16%) !default; $plyr-color-gray-900: hsl(216deg 15% 16%) !default;
$plyr-color-gray-800: hsl(216, 15%, 25%) !default; $plyr-color-gray-800: hsl(216deg 15% 25%) !default;
$plyr-color-gray-700: hsl(216, 15%, 34%) !default; $plyr-color-gray-700: hsl(216deg 15% 34%) !default;
$plyr-color-gray-600: hsl(216, 15%, 43%) !default; $plyr-color-gray-600: hsl(216deg 15% 43%) !default;
$plyr-color-gray-500: hsl(216, 15%, 52%) !default; $plyr-color-gray-500: hsl(216deg 15% 52%) !default;
$plyr-color-gray-400: hsl(216, 15%, 61%) !default; $plyr-color-gray-400: hsl(216deg 15% 61%) !default;
$plyr-color-gray-300: hsl(216, 15%, 70%) !default; $plyr-color-gray-300: hsl(216deg 15% 70%) !default;
$plyr-color-gray-200: hsl(216, 15%, 79%) !default; $plyr-color-gray-200: hsl(216deg 15% 79%) !default;
$plyr-color-gray-100: hsl(216, 15%, 88%) !default; $plyr-color-gray-100: hsl(216deg 15% 88%) !default;
$plyr-color-gray-50: hsl(216, 15%, 97%) !default; $plyr-color-gray-50: hsl(216deg 15% 97%) !default;

View File

@ -7,12 +7,10 @@ $plyr-control-spacing: var(--plyr-control-spacing, 10px) !default;
$plyr-control-padding: calc(#{$plyr-control-spacing} * 0.7); $plyr-control-padding: calc(#{$plyr-control-spacing} * 0.7);
$plyr-control-padding: var(--plyr-control-padding, $plyr-control-padding) !default; $plyr-control-padding: var(--plyr-control-padding, $plyr-control-padding) !default;
$plyr-control-radius: var(--plyr-control-radius, 3px) !default; $plyr-control-radius: var(--plyr-control-radius, 3px) !default;
$plyr-control-toggle-checked-background: var( $plyr-control-toggle-checked-background: var(
--plyr-control-toggle-checked-background, --plyr-control-toggle-checked-background,
var(--plyr-color-main, $plyr-color-main) var(--plyr-color-main, $plyr-color-main)
) !default; ) !default;
$plyr-video-controls-background: var( $plyr-video-controls-background: var(
--plyr-video-controls-background, --plyr-video-controls-background,
linear-gradient(rgba(#000, 0), rgba(#000, 0.75)) linear-gradient(rgba(#000, 0), rgba(#000, 0.75))
@ -23,7 +21,6 @@ $plyr-video-control-background-hover: var(
--plyr-video-control-background-hover, --plyr-video-control-background-hover,
var(--plyr-color-main, $plyr-color-main) var(--plyr-color-main, $plyr-color-main)
) !default; ) !default;
$plyr-audio-controls-background: var(--plyr-audio-controls-background, #fff) !default; $plyr-audio-controls-background: var(--plyr-audio-controls-background, #fff) !default;
$plyr-audio-control-color: var(--plyr-audio-control-color, $plyr-color-gray-700) !default; $plyr-audio-control-color: var(--plyr-audio-control-color, $plyr-color-gray-700) !default;
$plyr-audio-control-color-hover: var(--plyr-audio-control-color-hover, #fff) !default; $plyr-audio-control-color-hover: var(--plyr-audio-control-color-hover, #fff) !default;

View File

@ -7,9 +7,7 @@ $plyr-menu-radius: var(--plyr-menu-radius, 4px) !default;
$plyr-menu-color: var(--plyr-menu-color, $plyr-color-gray-700) !default; $plyr-menu-color: var(--plyr-menu-color, $plyr-color-gray-700) !default;
$plyr-menu-shadow: var(--plyr-menu-shadow, 0 1px 2px rgba(#000, 0.15)) !default; $plyr-menu-shadow: var(--plyr-menu-shadow, 0 1px 2px rgba(#000, 0.15)) !default;
$plyr-menu-arrow-size: var(--plyr-menu-arrow-size, 4px) !default; $plyr-menu-arrow-size: var(--plyr-menu-arrow-size, 4px) !default;
$plyr-menu-item-arrow-size: var(--plyr-menu-item-arrow-size, 4px) !default; $plyr-menu-item-arrow-size: var(--plyr-menu-item-arrow-size, 4px) !default;
$plyr-menu-item-arrow-color: var(--plyr-menu-arrow-color, $plyr-color-gray-500) !default; $plyr-menu-item-arrow-color: var(--plyr-menu-arrow-color, $plyr-color-gray-500) !default;
$plyr-menu-back-border-color: var(--plyr-menu-back-border-color, $plyr-color-gray-100) !default; $plyr-menu-back-border-color: var(--plyr-menu-back-border-color, $plyr-color-gray-100) !default;
$plyr-menu-back-border-shadow-color: var(--plyr-menu-back-border-shadow-color, #fff) !default; $plyr-menu-back-border-shadow-color: var(--plyr-menu-back-border-shadow-color, #fff) !default;

View File

@ -29,7 +29,6 @@ $plyr-video-range-thumb-active-shadow-color: var(
--plyr-audio-range-thumb-active-shadow-color, --plyr-audio-range-thumb-active-shadow-color,
rgba(#fff, 0.5) rgba(#fff, 0.5)
) !default; ) !default;
$plyr-audio-range-track-background: var( $plyr-audio-range-track-background: var(
--plyr-audio-range-track-background, --plyr-audio-range-track-background,
$plyr-audio-progress-buffered-background $plyr-audio-progress-buffered-background

View File

@ -7,14 +7,10 @@ $plyr-font-size-base: var(--plyr-font-size-base, 15px) !default;
$plyr-font-size-small: var(--plyr-font-size-small, 13px) !default; $plyr-font-size-small: var(--plyr-font-size-small, 13px) !default;
$plyr-font-size-large: var(--plyr-font-size-large, 18px) !default; $plyr-font-size-large: var(--plyr-font-size-large, 18px) !default;
$plyr-font-size-xlarge: var(--plyr-font-size-xlarge, 21px) !default; $plyr-font-size-xlarge: var(--plyr-font-size-xlarge, 21px) !default;
$plyr-font-size-time: var(--plyr-font-size-time, $plyr-font-size-small) !default; $plyr-font-size-time: var(--plyr-font-size-time, $plyr-font-size-small) !default;
$plyr-font-size-menu: var(--plyr-font-size-menu, $plyr-font-size-small) !default; $plyr-font-size-menu: var(--plyr-font-size-menu, $plyr-font-size-small) !default;
$plyr-font-size-badge: var(--plyr-font-size-badge, 9px) !default; $plyr-font-size-badge: var(--plyr-font-size-badge, 9px) !default;
$plyr-font-weight-regular: var(--plyr-font-weight-regular, 400) !default; $plyr-font-weight-regular: var(--plyr-font-weight-regular, 400) !default;
$plyr-font-weight-bold: var(--plyr-font-weight-bold, 600) !default; $plyr-font-weight-bold: var(--plyr-font-weight-bold, 600) !default;
$plyr-line-height: var(--plyr-line-height, 1.7) !default; $plyr-line-height: var(--plyr-line-height, 1.7) !default;
$plyr-font-smoothing: var(--plyr-font-smoothing, false) !default; $plyr-font-smoothing: var(--plyr-font-smoothing, false) !default;

View File

@ -3,27 +3,13 @@
// -------------------------------------------------------------- // --------------------------------------------------------------
.plyr:fullscreen { .plyr:fullscreen {
@include plyr-fullscreen-active(); @include plyr-fullscreen-active;
}
/* stylelint-disable-next-line */
.plyr:-webkit-full-screen {
@include plyr-fullscreen-active();
}
/* stylelint-disable-next-line */
.plyr:-moz-full-screen {
@include plyr-fullscreen-active();
}
/* stylelint-disable-next-line */
.plyr:-ms-fullscreen {
@include plyr-fullscreen-active();
} }
// Fallback for unsupported browsers // Fallback for unsupported browsers
.plyr--fullscreen-fallback { .plyr--fullscreen-fallback {
@include plyr-fullscreen-active(); @include plyr-fullscreen-active;
bottom: 0; bottom: 0;
display: block; display: block;
left: 0; left: 0;

View File

@ -2,6 +2,8 @@
// Video styles // Video styles
// -------------------------------------------------------------- // --------------------------------------------------------------
@use 'sass:math';
// Container // Container
.plyr--video { .plyr--video {
background: var(--plyr-video-background, $plyr-video-background); background: var(--plyr-video-background, $plyr-video-background);
@ -22,7 +24,7 @@
} }
// Default to 16:9 ratio but this is set by JavaScript based on config // 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-embed,
.plyr__video-wrapper--fixed-ratio { .plyr__video-wrapper--fixed-ratio {
@ -45,17 +47,14 @@ $embed-padding: ((100 / 16) * 9);
width: 100%; width: 100%;
} }
// If the full custom UI is supported // For Vimeo, if the full custom UI is supported
.plyr--full-ui .plyr__video-embed { .plyr--full-ui .plyr__video-embed > .plyr__video-embed__container {
$height: 240; $height: 240;
$offset: to-percentage(($height - $embed-padding) / ($height / 50)); $offset: to-percentage(math.div($height - $embed-padding, math.div($height, 50)));
// Only used for Vimeo padding-bottom: to-percentage($height);
> .plyr__video-embed__container { position: relative;
padding-bottom: to-percentage($height); transform: translateY(-$offset);
position: relative;
transform: translateY(-$offset);
}
} }
// Controls container // Controls container

View File

@ -13,7 +13,7 @@ const babel = require('rollup-plugin-babel');
const commonjs = require('rollup-plugin-commonjs'); const commonjs = require('rollup-plugin-commonjs');
const resolve = require('rollup-plugin-node-resolve'); const resolve = require('rollup-plugin-node-resolve');
// CSS // CSS
const sass = require('gulp-sass'); const sass = require('gulp-sass')(require('sass'));
const postcss = require('gulp-postcss'); const postcss = require('gulp-postcss');
const autoprefixer = require('autoprefixer'); const autoprefixer = require('autoprefixer');
const cssnano = require('cssnano'); const cssnano = require('cssnano');

View File

@ -51,11 +51,19 @@ const paths = {
], ],
}; };
// Get branch info // Get git branch info
const currentBranch = (() => {
try {
return gitbranch.sync();
} catch (_) {
return null;
}
})();
const branch = { const branch = {
current: gitbranch.sync(), current: currentBranch,
master: 'master', isMaster: currentBranch === 'master',
beta: 'beta', isBeta: currentBranch === 'beta',
}; };
const maxAge = 31536000; // 1 year const maxAge = 31536000; // 1 year
@ -66,7 +74,7 @@ const options = {
}, },
}, },
demo: { demo: {
uploadPath: branch.current === branch.beta ? '/beta' : null, uploadPath: branch.isBeta ? '/beta' : null,
headers: { headers: {
'Cache-Control': 'no-cache, no-store, must-revalidate, max-age=0', '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 // Check we're on the correct branch to deploy
const canDeploy = () => { const canDeploy = () => {
const allowed = [branch.master, branch.beta]; if (![branch.isMaster, branch.isBeta].some(Boolean)) {
console.error(`Must be on an allowed branch to publish! (current: ${branch.current})`);
if (!allowed.includes(branch.current)) {
console.error(`Must be on ${allowed.join(', ')} to publish! (current: ${branch.current})`);
return false; return false;
} }
@ -195,7 +200,7 @@ gulp.task('demo', (done) => {
const error = `${paths.demo}error.html`; const error = `${paths.demo}error.html`;
const pages = [index]; const pages = [index];
if (branch.current === branch.master) { if (branch.isMaster) {
pages.push(error); pages.push(error);
} }
@ -220,7 +225,7 @@ gulp.task('open', () => {
return gulp.src(__filename).pipe( return gulp.src(__filename).pipe(
open({ open({
uri: `https://${domain}/${branch.current === branch.beta ? 'beta' : ''}`, uri: `https://${domain}/${branch.isBeta ? 'beta' : ''}`,
}), }),
); );
}); });

4331
yarn.lock

File diff suppressed because it is too large Load Diff