Compare commits
77 Commits
Author | SHA1 | Date | |
---|---|---|---|
20bf5a8833 | |||
de0402bebf | |||
db1b89b1c1 | |||
ea3675fcdc | |||
e8beabd6a8 | |||
433acd6f41 | |||
69ced1313a | |||
511a7db7c2 | |||
6a62e3d085 | |||
aba00d0ab6 | |||
c115dfc6a6 | |||
6030b300f6 | |||
fff26351c9 | |||
e0fb524382 | |||
ebda039395 | |||
ed456197f5 | |||
66187c348a | |||
cacaef7def | |||
42b8f7bdab | |||
c90f044dac | |||
5f2cb90bc6 | |||
537ad2fe7d | |||
e7621bec0f | |||
e3acba5859 | |||
d7086074e8 | |||
04e6c43da7 | |||
73bfb5211b | |||
4a78b656da | |||
776fd099f3 | |||
bdcd98f4a7 | |||
01417f958a | |||
412d5df06e | |||
3e35461e04 | |||
1edec28d86 | |||
99a7e9e1d7 | |||
24eef153cb | |||
3f09cf566b | |||
29318591c0 | |||
d434c9af16 | |||
9ce1dd6808 | |||
28347a0d7e | |||
5f9d090c13 | |||
1d4869beee | |||
565b68a5e2 | |||
285282f366 | |||
02456d6ba3 | |||
1d920a2e58 | |||
ba67920025 | |||
b7953ff0fc | |||
6b8e0f25d6 | |||
895299a4b3 | |||
2d7638a230 | |||
ab028ea475 | |||
9157ac09ed | |||
da7524438b | |||
c64c8ac6c0 | |||
d700bb9f02 | |||
2b6208565f | |||
6bc447b916 | |||
4632614ced | |||
01c5428fc4 | |||
591c045c20 | |||
1d7ea197f3 | |||
1d0d6a3a92 | |||
6a92e60a67 | |||
40395a1ff5 | |||
9ea3a6923d | |||
675a853e2e | |||
950786b117 | |||
626e1dba64 | |||
cbd1596af4 | |||
6ea510c36e | |||
1b835cb657 | |||
b4f24f90da | |||
e4a18a5c99 | |||
02d06c464c | |||
cec2474295 |
1
.node-version
Normal file
1
.node-version
Normal file
@ -0,0 +1 @@
|
||||
16.18.1
|
@ -1,6 +1,7 @@
|
||||
{
|
||||
"plugins": ["stylelint-selector-bem-pattern", "stylelint-scss"],
|
||||
"extends": ["stylelint-config-recommended", "stylelint-config-sass-guidelines", "stylelint-config-prettier"],
|
||||
"plugins": ["stylelint-selector-bem-pattern"],
|
||||
"extends": ["stylelint-config-sass-guidelines", "stylelint-config-prettier"],
|
||||
"customSyntax": "postcss-scss",
|
||||
"rules": {
|
||||
"selector-class-pattern": null,
|
||||
"selector-no-qualifying-type": [
|
||||
@ -9,10 +10,7 @@
|
||||
"ignore": ["attribute", "class"]
|
||||
}
|
||||
],
|
||||
"string-no-newline": null,
|
||||
"indentation": 2,
|
||||
"string-quotes": "single",
|
||||
"max-nesting-depth": 2,
|
||||
"max-nesting-depth": 4,
|
||||
"plugin/selector-bem-pattern": {
|
||||
"preset": "bem",
|
||||
"componentName": "(([a-z0-9]+(?!-$)-?)+)",
|
||||
|
@ -1,6 +0,0 @@
|
||||
language: node_js
|
||||
node_js: lts/*
|
||||
|
||||
script:
|
||||
- npm run lint
|
||||
- npm run build
|
73
CHANGELOG.md
73
CHANGELOG.md
@ -1,3 +1,50 @@
|
||||
### v3.7.3
|
||||
|
||||
- Fix: force nowrap in progress tooltips (related: #2549) (thanks @raad-altaie!)
|
||||
- Feat(i18n): Make captions autodetect text direction (#2540) (thanks @ebraminio!)
|
||||
- Fix: fixed menu border radius bug (#2548) (thanks @raad-altaie!)
|
||||
- Chore: navigator.platform is deprecated (#2530) (thanks @stamat!)
|
||||
- Feat: Added configurable property to elements for re-use (#2489) (thanks @NoirHusky!)
|
||||
- Docs: Replace example video ID with one that still works (#2518) (thanks @luvejo!)
|
||||
- Fix: Improve accessibility on control buttons with aria-pressed (#2523) (thanks @emilkarl!)
|
||||
- Fix: Fix for calc() in newer Dart Sass versions (#2519) (thanks @ckhicks!)
|
||||
- Fix: simplify logic for isFunction assertion method
|
||||
- Chore: update types to include string for controls
|
||||
- Chore: upgrade packages
|
||||
- Chore: use `.node-version` instead of `.nvmrc`
|
||||
|
||||
### v3.7.2
|
||||
|
||||
- Fix: Add `@babel/plugin-proposal-optional-chaining` to transform optional chaining in build output
|
||||
|
||||
### v3.7.1
|
||||
|
||||
- Feat: Minor styling improvements to the preview thumbnails (🚨 Requires a SCSS/CSS update 🚨)
|
||||
- Fix: Fix invalid CSS @charset rule in Sass files (thanks @Hashen110!)
|
||||
- Chore: Replace deprecated KeyboardEvent `keyCode` references to use `key` instead (thanks @Hashen110!)
|
||||
- Various other code clean up and typo fixes (thanks @Hashen110!)
|
||||
|
||||
## v3.7.0
|
||||
|
||||
- Feat: Add markers support (🚨 Requires a SCSS/CSS update 🚨) (thanks @ForeverSc and @fengshuo!)
|
||||
- Feat: Add support for MediaMetadata (thanks @Hashen110!)
|
||||
- Fix: Pass this context to captions.setup (fixes #2352) (thanks @WilliamMHerring, @willherring and @zenyr!)
|
||||
- Fix: Modify vimeo parseHash to use non-named capture groups (fixes #2396) (thanks @fekle!)
|
||||
- Fix: Replace deprecated String.prototype.substr() (thanks @CommanderRoot!)
|
||||
- Docs: Update speed option default to match the source (thanks @ozgurg!)
|
||||
- Docs: SASS → Sass (thanks @toastal!)
|
||||
|
||||
### 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
|
||||
@ -5,7 +52,7 @@
|
||||
|
||||
### v3.6.9
|
||||
|
||||
- Fix: SASS issue with division (thanks @ROL4ND909 and @le0pard)
|
||||
- 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)
|
||||
@ -66,7 +113,7 @@
|
||||
- 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 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
|
||||
|
||||
### v3.6.2
|
||||
@ -111,7 +158,7 @@
|
||||
### v3.5.8
|
||||
|
||||
- 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
|
||||
- Remove all Vimeo controls for Pro & Premium accounts
|
||||
- Improve thumbnail size calculations when size is set per css (thanks @ydylla)
|
||||
@ -126,7 +173,7 @@
|
||||
- Accessibility tweak for the play button (thanks @lunika)
|
||||
- Fix for ads configuration (thanks @SoftCreatR)
|
||||
- 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)
|
||||
- Fix being unable to unmute autoplayed video on iOS (thanks @sumanbh)
|
||||
- Fixed Plyr container not resizing responsively (thanks @shravan2x)
|
||||
@ -160,7 +207,7 @@ _Note:_ This update contains CSS changes.
|
||||
### v3.5.4
|
||||
|
||||
- Added: Set download URL via new setter
|
||||
- Improvement: The order of the `controls` option now effects the order in the DOM - i.e. you can re-order the controls - Note: this may break any custom CSS you have setup. Please see the changes in the PR to the default SASS
|
||||
- Improvement: The order of the `controls` option now effects the order in the DOM - i.e. you can re-order the controls - Note: this may break any custom CSS you have setup. Please see the changes in the PR to the default Sass
|
||||
- Fixed issue with empty controls and preview thumbs
|
||||
- Fixed issue with setGutter call (from Sentry)
|
||||
- Fixed issue with initial selected speed not working
|
||||
@ -523,7 +570,7 @@ This is a massive release. A _mostly_ complete rewrite in ES6. What started out
|
||||
|
||||
### Other stuff
|
||||
|
||||
- Now using SASS exclusively. Sorry, LESS folk it just made sense to maintain one method as SASS is what the cool kids use. It may come back if we work out an automated way to convert the SASS
|
||||
- Now using Sass exclusively. Sorry, LESS folk it just made sense to maintain one method as Sass is what the cool kids use. It may come back if we work out an automated way to convert the Sass
|
||||
- Moved to ES6. All the rage these days. You'll need to look at polyfills. The demo uses [polyfill.io](https://polyfill.io)
|
||||
- Added basic looping support
|
||||
- Added an aspect ratio option for those that can't leave the 90s and want 4:3
|
||||
@ -756,7 +803,7 @@ And some other changes and bug fixes:
|
||||
|
||||
## v1.7.0
|
||||
|
||||
- SASS cleanup (fixes #265)
|
||||
- Sass cleanup (fixes #265)
|
||||
- Docs tidy up to help quick start (fixes #253)
|
||||
- Fix for issues with data attribute options passing (fixes #257)
|
||||
- **_(Important)_** Removed the requirement for a wrapper div to setup Plyr and removed the dependency on the `plyr` classname as a JS hook. By default it will now look for `<video>`, `<audio>` and `[data-type]` elements. If you are just calling `setup()` with a `<div class="plyr">` you may want to give it a good test after upgrading. You can probably remove the wrapper div. The reason behind this is to make setup easier for newcomers and prevent the styling being used on unsupported players (because the plyr classname was used as a CSS and JS hook - which isn't ideal)
|
||||
@ -878,7 +925,7 @@ And some other changes and bug fixes:
|
||||
### v1.5.18
|
||||
|
||||
- Added 'ready' event for initial setup complete or source change occurs
|
||||
- Fixed SASS stylesheet references to transparentize
|
||||
- Fixed Sass stylesheet references to transparentize
|
||||
- Added default font stack to controls
|
||||
- Docs fixes inc controls HTML (fixes #180)
|
||||
|
||||
@ -915,7 +962,7 @@ And some other changes and bug fixes:
|
||||
|
||||
- iOS embed bug fixes (fixes #166)
|
||||
- Hide IE/Edge <input type='range'> tooltip (since we have a styled one) (fixes #160)
|
||||
- SASS bug fix for default values (fixes #158)
|
||||
- Sass bug fix for default values (fixes #158)
|
||||
|
||||
### v1.5.9
|
||||
|
||||
@ -937,7 +984,7 @@ And some other changes and bug fixes:
|
||||
### v1.5.6
|
||||
|
||||
- Seek tooltip (option for tooltips changed, please check docs)
|
||||
- SASS compile error fixes (fixes #148)
|
||||
- Sass compile error fixes (fixes #148)
|
||||
- Fullscreen fixes for controls not always hiding/showing (fixes #149)
|
||||
- Screen reader icon fixes (title was being read twice due to the tooltip/hidden label)
|
||||
|
||||
@ -1014,7 +1061,7 @@ And some other changes and bug fixes:
|
||||
|
||||
### v1.2.6
|
||||
|
||||
- SASS updates and fixes (cheers @ChristianPV)
|
||||
- Sass updates and fixes (cheers @ChristianPV)
|
||||
|
||||
### v1.2.5
|
||||
|
||||
@ -1129,7 +1176,7 @@ And some other changes and bug fixes:
|
||||
|
||||
### v1.0.26
|
||||
|
||||
- Fixes for SASS (cheers @brunowego)
|
||||
- Fixes for Sass (cheers @brunowego)
|
||||
- Indentation reset to 4 spaces
|
||||
|
||||
### v1.0.25
|
||||
@ -1174,7 +1221,7 @@ And some other changes and bug fixes:
|
||||
|
||||
### v1.0.17
|
||||
|
||||
- SASS support added (thanks to @brunowego)
|
||||
- Sass support added (thanks to @brunowego)
|
||||
- Docs completely separated to avoid any confusion
|
||||
- New gulp tasks (will add more documentation for this)
|
||||
|
||||
|
54
CONTROLS.md
54
CONTROLS.md
@ -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:
|
||||
|
||||
- `Array` of options (this builds the default controls based on your choices)
|
||||
- `Element` with the controls
|
||||
- `String` containing the desired HTML
|
||||
- `false` (or empty string or array) to disable all controls
|
||||
- `Function` that will be executed and should return one of the above
|
||||
- `Array` of options (this builds the default controls based on your choices)
|
||||
- `Element` with the controls
|
||||
- `String` containing the desired HTML
|
||||
- `false` (or empty string or array) to disable all controls
|
||||
- `Function` that will be executed and should return one of the above
|
||||
|
||||
## 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
|
||||
controls: [
|
||||
'play-large', // The large play button in the center
|
||||
'restart', // Restart playback
|
||||
'rewind', // Rewind by the seek time (default 10 seconds)
|
||||
'play', // Play/pause playback
|
||||
'fast-forward', // Fast forward by the seek time (default 10 seconds)
|
||||
'progress', // The progress bar and scrubber for playback and buffering
|
||||
'current-time', // The current time of playback
|
||||
'duration', // The full duration of the media
|
||||
'mute', // Toggle mute
|
||||
'volume', // Volume control
|
||||
'captions', // Toggle captions
|
||||
'settings', // Settings menu
|
||||
'pip', // Picture-in-picture (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
|
||||
'fullscreen', // Toggle fullscreen
|
||||
'play-large', // The large play button in the center
|
||||
'restart', // Restart playback
|
||||
'rewind', // Rewind by the seek time (default 10 seconds)
|
||||
'play', // Play/pause playback
|
||||
'fast-forward', // Fast forward by the seek time (default 10 seconds)
|
||||
'progress', // The progress bar and scrubber for playback and buffering
|
||||
'current-time', // The current time of playback
|
||||
'duration', // The full duration of the media
|
||||
'mute', // Toggle mute
|
||||
'volume', // Volume control
|
||||
'captions', // Toggle captions
|
||||
'settings', // Settings menu
|
||||
'pip', // Picture-in-picture (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
|
||||
'fullscreen', // Toggle fullscreen
|
||||
];
|
||||
```
|
||||
|
||||
### 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
|
||||
|
||||
@ -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:
|
||||
|
||||
- `{id}` - the dynamically generated ID for the player (for form controls)
|
||||
- `{seektime}` - the seek time specified in options for fast forward and rewind
|
||||
- `{title}` - the title of your media, if specified
|
||||
- `{id}` - the dynamically generated ID for the player (for form controls)
|
||||
- `{seektime}` - the seek time specified in options for fast forward and rewind
|
||||
- `{title}` - the title of your media, if specified
|
||||
|
||||
### Limitations
|
||||
|
||||
- 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
|
||||
- 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
|
||||
|
||||
### Example
|
||||
|
||||
|
141
README.md
141
README.md
@ -1,3 +1,6 @@
|
||||
| 🎉 | [Plyr is merging into Vidstack](https://github.com/sampotts/plyr/issues/2408) | 🎉 |
|
||||
| :-: | :---------------------------------------------------------------------------: | :-- |
|
||||
|
||||
Plyr is a simple, lightweight, accessible and customizable HTML5, YouTube and Vimeo media player that supports [_modern_](#browser-support) browsers.
|
||||
|
||||
[Checkout the demo](https://plyr.io) - [Donate](#donate) - [Slack](https://bit.ly/plyr--chat)
|
||||
@ -27,7 +30,7 @@ Plyr is a simple, lightweight, accessible and customizable HTML5, YouTube and Vi
|
||||
- 🌎 **i18n support** - support for internationalization of controls
|
||||
- 👌 **[Preview thumbnails](#preview-thumbnails)** - support for displaying preview thumbnails
|
||||
- 🤟 **No frameworks** - written in "vanilla" ES6 JavaScript, no jQuery required
|
||||
- 💁♀️ **SASS** - to include in your build processes
|
||||
- 💁♀️ **Sass** - to include in your build processes
|
||||
|
||||
### Demos
|
||||
|
||||
@ -131,21 +134,21 @@ Alternatively you can include the `plyr.js` script before the closing `</body>`
|
||||
|
||||
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
|
||||
<script src="https://cdn.plyr.io/3.6.10/plyr.js"></script>
|
||||
<script src="https://cdn.plyr.io/3.7.3/plyr.js"></script>
|
||||
```
|
||||
|
||||
...or...
|
||||
|
||||
```html
|
||||
<script src="https://cdn.plyr.io/3.6.10/plyr.polyfilled.js"></script>
|
||||
<script src="https://cdn.plyr.io/3.7.3/plyr.polyfilled.js"></script>
|
||||
```
|
||||
|
||||
## CSS
|
||||
|
||||
Include the `plyr.css` stylsheet into your `<head>`.
|
||||
Include the `plyr.css` stylesheet into your `<head>`.
|
||||
|
||||
```html
|
||||
<link rel="stylesheet" href="path/to/plyr.css" />
|
||||
@ -154,13 +157,13 @@ Include the `plyr.css` stylsheet into your `<head>`.
|
||||
If you want to use our CDN (provided by [Fastly](https://www.fastly.com/)) for the default CSS, you can use the following:
|
||||
|
||||
```html
|
||||
<link rel="stylesheet" href="https://cdn.plyr.io/3.6.10/plyr.css" />
|
||||
<link rel="stylesheet" href="https://cdn.plyr.io/3.7.3/plyr.css" />
|
||||
```
|
||||
|
||||
## SVG Sprite
|
||||
|
||||
The SVG sprite is loaded automatically from our CDN (provided by [Fastly](https://www.fastly.com/)). To change this, see the [options](#options) below. For
|
||||
reference, the CDN hosted SVG sprite can be found at `https://cdn.plyr.io/3.6.10/plyr.svg`.
|
||||
reference, the CDN hosted SVG sprite can be found at `https://cdn.plyr.io/3.7.3/plyr.svg`.
|
||||
|
||||
# Ads
|
||||
|
||||
@ -184,43 +187,43 @@ Here's a list of the properties and what they are used for:
|
||||
|
||||
| Name | Description | Default / Fallback |
|
||||
| ---------------------------------------------- | ------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
|
||||
| `--plyr-color-main` | The primary UI color. |  `#00b3ff` |
|
||||
| `--plyr-video-background` | The background color of video and poster wrappers for using alpha channel videos and poster images. | `rgba(0, 0, 0, 1)` |
|
||||
| `--plyr-color-main` | The primary UI color. |  `#00b3ff` |
|
||||
| `--plyr-video-background` | The background color of video and poster wrappers for using alpha channel videos and poster images. | `rgba(0, 0, 0, 1)` |
|
||||
| `--plyr-tab-focus-color` | The color used for the dotted outline when an element is `:focus-visible` (equivalent) keyboard focus. | `--plyr-color-main` |
|
||||
| `--plyr-badge-background` | The background color for badges in the menu. |  `#4a5464` |
|
||||
| `--plyr-badge-text-color` | The text color for badges. |  `#ffffff` |
|
||||
| `--plyr-badge-background` | The background color for badges in the menu. |  `#4a5464` |
|
||||
| `--plyr-badge-text-color` | The text color for badges. |  `#ffffff` |
|
||||
| `--plyr-badge-border-radius` | The border radius used for badges. | `2px` |
|
||||
| `--plyr-tab-focus-color` | The color used to highlight tab (keyboard) focus. | `--plyr-color-main` |
|
||||
| `--plyr-captions-background` | The color for the background of captions. | `rgba(0, 0, 0, 0.8)` |
|
||||
| `--plyr-captions-text-color` | The color used for the captions text. |  `#ffffff` |
|
||||
| `--plyr-captions-text-color` | The color used for the captions text. |  `#ffffff` |
|
||||
| `--plyr-control-icon-size` | The size of the icons used in the controls. | `18px` |
|
||||
| `--plyr-control-spacing` | The space between controls (sometimes used in a multiple - e.g. `10px / 2 = 5px`). | `10px` |
|
||||
| `--plyr-control-padding` | The padding inside controls. | `--plyr-control-spacing * 0.7` (`7px`) |
|
||||
| `--plyr-control-radius` | The border radius used on controls. | `3px` |
|
||||
| `--plyr-control-toggle-checked-background` | The background color used for checked menu items. | `--plyr-color-main` |
|
||||
| `--plyr-video-controls-background` | The background for the video controls. | `linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.75))` |
|
||||
| `--plyr-video-control-color` | The text/icon color for video controls. |  `#ffffff` |
|
||||
| `--plyr-video-control-color-hover` | The text/icon color used when video controls are `:hover`, `:focus` and `:focus-visible` (equivalent). |  `#ffffff` |
|
||||
| `--plyr-video-control-color` | The text/icon color for video controls. |  `#ffffff` |
|
||||
| `--plyr-video-control-color-hover` | The text/icon color used when video controls are `:hover`, `:focus` and `:focus-visible` (equivalent). |  `#ffffff` |
|
||||
| `--plyr-video-control-background-hover` | The background color used when video controls are `:hover`, `:focus` and `:focus-visible` (equivalent). | `--plyr-color-main` |
|
||||
| `--plyr-audio-controls-background` | The background for the audio controls. |  `#ffffff` |
|
||||
| `--plyr-audio-control-color` | The text/icon color for audio controls. |  `#4a5464` |
|
||||
| `--plyr-audio-control-color-hover` | The text/icon color used when audio controls are `:hover`, `:focus` and `:focus-visible` (equivalent). |  `#ffffff` |
|
||||
| `--plyr-audio-controls-background` | The background for the audio controls. |  `#ffffff` |
|
||||
| `--plyr-audio-control-color` | The text/icon color for audio controls. |  `#4a5464` |
|
||||
| `--plyr-audio-control-color-hover` | The text/icon color used when audio controls are `:hover`, `:focus` and `:focus-visible` (equivalent). |  `#ffffff` |
|
||||
| `--plyr-audio-control-background-hover` | The background color used when video controls are `:hover`, `:focus` and `:focus-visible` (equivalent). | `--plyr-color-main` |
|
||||
| `--plyr-menu-background` | The background color for menus. | `rgba(255, 255, 255, 0.9)` |
|
||||
| `--plyr-menu-color` | The text/icon color for menu items. |  `#4a5464` |
|
||||
| `--plyr-menu-color` | The text/icon color for menu items. |  `#4a5464` |
|
||||
| `--plyr-menu-shadow` | The shadow used on menus. | `0 1px 2px rgba(0, 0, 0, 0.15)` |
|
||||
| `--plyr-menu-radius` | The border radius on the menu. | `4px` |
|
||||
| `--plyr-menu-arrow-size` | The size of the arrow on the bottom of the menu. | `6px` |
|
||||
| `--plyr-menu-item-arrow-color` | The color of the arrows in the menu. |  `#728197` |
|
||||
| `--plyr-menu-item-arrow-color` | The color of the arrows in the menu. |  `#728197` |
|
||||
| `--plyr-menu-item-arrow-size` | The size of the arrows in the menu. | `4px` |
|
||||
| `--plyr-menu-border-color` | The border color for the bottom of the back button in the top of the sub menu pages. |  `#dcdfe5` |
|
||||
| `--plyr-menu-border-shadow-color` | The shadow below the border of the back button in the top of the sub menu pages. |  `#ffffff` |
|
||||
| `--plyr-menu-border-color` | The border color for the bottom of the back button in the top of the sub menu pages. |  `#dcdfe5` |
|
||||
| `--plyr-menu-border-shadow-color` | The shadow below the border of the back button in the top of the sub menu pages. |  `#ffffff` |
|
||||
| `--plyr-progress-loading-size` | The size of the stripes in the loading state in the scrubber. | `25px` |
|
||||
| `--plyr-progress-loading-background` | The background color on the loading state in the scrubber. | `rgba(35, 40, 47, 0.6)` |
|
||||
| `--plyr-video-progress-buffered-background` | The fill color for the buffer indication in the scrubber for video. | `rgba(255, 255, 255, 0.25)` |
|
||||
| `--plyr-audio-progress-buffered-background` | The fill color for the buffer indication in the scrubber for audio. | `rgba(193, 200, 209, 0.6)` |
|
||||
| `--plyr-range-thumb-height` | The height of the scrubber handle/thumb. | `13px` |
|
||||
| `--plyr-range-thumb-background` | The background of the scrubber handle/thumb. |  `#ffffff` |
|
||||
| `--plyr-range-thumb-background` | The background of the scrubber handle/thumb. |  `#ffffff` |
|
||||
| `--plyr-range-thumb-shadow` | The shadow of the scrubber handle/thumb. | `0 1px 1px rgba(215, 26, 18, 0.15), 0 0 0 1px rgba(215, 26, 18, 0.2)` |
|
||||
| `--plyr-range-thumb-active-shadow-width` | The width of the shadow when the scrubber handle/thumb is `:active` (pressed). | `3px` |
|
||||
| `--plyr-range-track-height` | The height of the scrubber/progress track. | `5px` |
|
||||
@ -230,7 +233,7 @@ Here's a list of the properties and what they are used for:
|
||||
| `--plyr-audio-range-track-background` | The background of the scrubber/progress. | `--plyr-video-progress-buffered-background` |
|
||||
| `--plyr-audio-range-thumb-active-shadow-color` | The color of the shadow when the audio scrubber handle/thumb is `:active` (pressed). | `rgba(215, 26, 18, 0.1)` |
|
||||
| `--plyr-tooltip-background` | The background color for tooltips. | `rgba(255, 255, 255, 0.9)` |
|
||||
| `--plyr-tooltip-color` | The text color for tooltips. |  `#4a5464` |
|
||||
| `--plyr-tooltip-color` | The text color for tooltips. |  `#4a5464` |
|
||||
| `--plyr-tooltip-padding` | The padding for tooltips. | `calc(var(--plyr-control-spacing) / 2))` |
|
||||
| `--plyr-tooltip-arrow-size` | The size of the arrow under tooltips. | `4px` |
|
||||
| `--plyr-tooltip-radius` | The border radius on tooltips. | `3px` |
|
||||
@ -267,14 +270,12 @@ You can set them in your CSS for all players:
|
||||
...or in your HTML:
|
||||
|
||||
```html
|
||||
<video class="player" style="--plyr-color-main: #1ac266;">
|
||||
...
|
||||
</video>
|
||||
<video class="player" style="--plyr-color-main: #1ac266;">...</video>
|
||||
```
|
||||
|
||||
### SASS
|
||||
### Sass
|
||||
|
||||
You can use `plyr.scss` file included in `/src/sass` as part of your build and change variables to suit your design. The SASS requires you to
|
||||
You can use `plyr.scss` file included in `/src/sass` as part of your build and change variables to suit your design. The Sass requires you to
|
||||
use [autoprefixer](https://www.npmjs.com/package/gulp-autoprefixer) (you should be already!) as all declarations use the W3C definitions.
|
||||
|
||||
The HTML markup uses the BEM methodology with `plyr` as the block, e.g. `.plyr__controls`. You can change the class hooks in the options to match any custom CSS
|
||||
@ -344,7 +345,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:
|
||||
|
||||
```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:
|
||||
@ -400,11 +401,11 @@ 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. |
|
||||
| `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. |
|
||||
| `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. |
|
||||
| `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. |
|
||||
| `speed` | Object | `{ selected: 1, options: [0.5, 0.75, 1, 1.25, 1.5, 1.75, 2] }` | `selected`: The default speed for playback. `options`: The speed options to display in the UI. YouTube and Vimeo will ignore any options outside of the 0.5-2 range, so options outside of this range will be hidden automatically. |
|
||||
| `speed` | Object | `{ selected: 1, options: [0.5, 0.75, 1, 1.25, 1.5, 1.75, 2, 4] }` | `selected`: The default speed for playback. `options`: The speed options to display in the UI. YouTube and Vimeo will ignore any options outside of the 0.5-2 range, so options outside of this range will be hidden automatically. |
|
||||
| `quality` | Object | `{ default: 576, options: [4320, 2880, 2160, 1440, 1080, 720, 576, 480, 360, 240] }` | `default` is the default quality level (if it exists in your sources). `options` are the options to display. This is used to filter the available sources. |
|
||||
| `loop` | Object | `{ active: false }` | `active`: Whether to loop the current video. If the `loop` attribute is present on a `<video>` or `<audio>` element, this will be automatically set to true This is an object to support future functionality. |
|
||||
| `ads` | Object | `{ enabled: false, publisherId: '', tagUrl: '' }` | `enabled`: Whether to enable advertisements. `publisherId`: Your unique [vi.ai](https://vi.ai/publisher-video-monetization/?aid=plyrio) publisher ID. `tagUrl` is a URL for a custom VAST tag if you're not using Vi. |
|
||||
@ -412,6 +413,8 @@ Note the single quotes encapsulating the JSON and double quotes on the object ke
|
||||
| `vimeo` | Object | `{ byline: false, portrait: false, title: false, speed: true, transparent: false }` | See [Vimeo embed options](https://github.com/vimeo/player.js/#embed-options). Some are set automatically based on other config options, namely: `loop`, `autoplay`, `muted`, `gesture`, `playsinline` |
|
||||
| `youtube` | Object | `{ noCookie: false, rel: 0, showinfo: 0, iv_load_policy: 3, modestbranding: 1 }` | See [YouTube embed options](https://developers.google.com/youtube/player_parameters#Parameters). The only custom option is `noCookie` to use an alternative to YouTube that doesn't use cookies (useful for GDPR, etc). Some are set automatically based on other config options, namely: `autoplay`, `hl`, `controls`, `disablekb`, `playsinline`, `cc_load_policy`, `cc_lang_pref`, `widget_referrer` |
|
||||
| `previewThumbnails` | Object | `{ enabled: false, src: '' }` | `enabled`: Whether to enable the preview thumbnails (they must be generated by you). `src` must be either a string or an array of strings representing URLs for the VTT files containing the image URL(s). Learn more about [preview thumbnails](#preview-thumbnails) below. |
|
||||
| `mediaMetadata` | Object | `{ title: '', artist: '', album: '', artwork: [] }` | The [MediaMetadata](https://developer.mozilla.org/en-US/docs/Web/API/MediaMetadata) interface of the Media Session API allows a web page to provide rich media metadata for display in a platform UI. |
|
||||
| `markers` | Object | `{ enabled: false, points: [] }` | `enabled`: Whether to enable markers. `points` is an array of `{ time: number; label: string; }` objects where `time` represents the marker position in seconds and `label` is the HTML string to be displayed. |
|
||||
|
||||
1. Vimeo only
|
||||
2. Autoplay is generally not recommended as it is seen as a negative user experience. It is also disabled in many browsers. Before raising issues, do your homework. More info can be found here:
|
||||
@ -437,7 +440,7 @@ const player = new Plyr('#player', {
|
||||
You can also access the object through any events:
|
||||
|
||||
```javascript
|
||||
element.addEventListener('ready', event => {
|
||||
element.addEventListener('ready', (event) => {
|
||||
const player = event.detail.plyr;
|
||||
});
|
||||
```
|
||||
@ -451,29 +454,29 @@ player.play(); // Start playback
|
||||
player.fullscreen.enter(); // Enter fullscreen
|
||||
```
|
||||
|
||||
| Method | Parameters | Description |
|
||||
| -------------------------- | ---------------- | ---------------------------------------------------------------------------------------------------------- |
|
||||
| `play()`¹ | - | Start playback. |
|
||||
| `pause()` | - | Pause playback. |
|
||||
| `togglePlay(toggle)`¹ | Boolean | Toggle playback, if no parameters are passed, it will toggle based on current status. |
|
||||
| `stop()` | - | Stop playback and reset to start. |
|
||||
| `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. |
|
||||
| `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. |
|
||||
| `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. |
|
||||
| `fullscreen.enter()` | - | Enter fullscreen. If fullscreen is not supported, a fallback "full window/viewport" is used instead. |
|
||||
| `fullscreen.exit()` | - | Exit fullscreen. |
|
||||
| `fullscreen.toggle()` | - | Toggle fullscreen. |
|
||||
| `airplay()` | - | Trigger the airplay dialog on supported devices. |
|
||||
| `setPreviewThumbnails(source: PreviewThumbnailsOptions)` | - | Sets the preview thubmnails for the current source. |
|
||||
| `toggleControls(toggle)` | Boolean | Toggle the controls (video only). Takes optional truthy value to force it on/off. |
|
||||
| `on(event, function)` | String, Function | Add an event listener for the specified event. |
|
||||
| `once(event, function)` | String, Function | Add an event listener for the specified event once. |
|
||||
| `off(event, function)` | String, Function | Remove an event listener for the specified event. |
|
||||
| `supports(type)` | String | Check support for a mime type. |
|
||||
| `destroy()` | - | Destroy the instance and garbage collect any elements. |
|
||||
| Method | Parameters | Description |
|
||||
| -------------------------------------------------------- | ---------------- | ---------------------------------------------------------------------------------------------------------- |
|
||||
| `play()`¹ | - | Start playback. |
|
||||
| `pause()` | - | Pause playback. |
|
||||
| `togglePlay(toggle)`¹ | Boolean | Toggle playback, if no parameters are passed, it will toggle based on current status. |
|
||||
| `stop()` | - | Stop playback and reset to start. |
|
||||
| `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. |
|
||||
| `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. |
|
||||
| `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. |
|
||||
| `fullscreen.enter()` | - | Enter fullscreen. If fullscreen is not supported, a fallback "full window/viewport" is used instead. |
|
||||
| `fullscreen.exit()` | - | Exit fullscreen. |
|
||||
| `fullscreen.toggle()` | - | Toggle fullscreen. |
|
||||
| `airplay()` | - | Trigger the airplay dialog on supported devices. |
|
||||
| `setPreviewThumbnails(source: PreviewThumbnailsOptions)` | - | Sets the preview thumbnails for the current source. |
|
||||
| `toggleControls(toggle)` | Boolean | Toggle the controls (video only). Takes optional truthy value to force it on/off. |
|
||||
| `on(event, function)` | String, Function | Add an event listener for the specified event. |
|
||||
| `once(event, function)` | String, Function | Add an event listener for the specified event once. |
|
||||
| `off(event, function)` | String, Function | Remove an event listener for the specified event. |
|
||||
| `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.
|
||||
|
||||
@ -514,7 +517,7 @@ player.fullscreen.active; // false;
|
||||
| `loop` | ✓ | ✓ | Gets or sets the current loop state of the player. The setter accepts a boolean. |
|
||||
| `source` | ✓ | ✓ | Gets or sets the current source for the player. The setter accepts an object. See [source setter](#the-source-setter) below for examples. |
|
||||
| `poster` | ✓ | ✓ | Gets or sets the current poster image for the player. The setter accepts a string; the URL for the updated poster image. |
|
||||
| `previewThumbnails` | ✓ | ✓ | Gets or sets the current preview Thubmnail source for the player. The setter accepts a string |
|
||||
| `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. |
|
||||
| `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. |
|
||||
@ -610,7 +613,7 @@ player.source = {
|
||||
type: 'video',
|
||||
sources: [
|
||||
{
|
||||
src: '143418951',
|
||||
src: '76979871',
|
||||
provider: 'vimeo',
|
||||
},
|
||||
],
|
||||
@ -637,7 +640,7 @@ reference to the instance, you can use the `on()` API method or `addEventListene
|
||||
property. Here's an example:
|
||||
|
||||
```javascript
|
||||
player.on('ready', event => {
|
||||
player.on('ready', (event) => {
|
||||
const instance = event.detail.plyr;
|
||||
});
|
||||
```
|
||||
@ -784,16 +787,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:
|
||||
|
||||
| Type | Maintainer | Link |
|
||||
| --------- | ------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| Neos | Jon Uhlmann ([@jonnitto](https://github.com/jonnitto)) | [https://packagist.org/packages/jonnitto/plyr](https://packagist.org/packages/jonnitto/plyr) |
|
||||
| Kirby | Dominik Pschenitschni ([@dpschen](https://github.com/dpschen)) | [https://github.com/dpschen/kirby-plyrtag](https://github.com/dpschen/kirby-plyrtag) |
|
||||
| REDAXO | FriendsOfRedaxo / skerbis ([@skerbis](https://friendsofredaxo.github.io)) | [https://github.com/FriendsOfREDAXO/plyr](https://github.com/FriendsOfREDAXO/plyr) |
|
||||
| svelte-plyr | Ben Woodward / benwoodward ([@benwoodward](https://github.com/benwoodward)) | [https://github.com/benwoodward/svelte-plyr](https://github.com/benwoodward/svelte-plyr) |
|
||||
| Type | Maintainer | Link |
|
||||
| ----------- | --------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| Neos | Jon Uhlmann ([@jonnitto](https://github.com/jonnitto)) | [https://packagist.org/packages/jonnitto/plyr](https://packagist.org/packages/jonnitto/plyr) |
|
||||
| Kirby | Dominik Pschenitschni ([@dpschen](https://github.com/dpschen)) | [https://github.com/dpschen/kirby-plyrtag](https://github.com/dpschen/kirby-plyrtag) |
|
||||
| REDAXO | FriendsOfRedaxo / skerbis ([@skerbis](https://friendsofredaxo.github.io)) | [https://github.com/FriendsOfREDAXO/plyr](https://github.com/FriendsOfREDAXO/plyr) |
|
||||
| svelte-plyr | Ben Woodward / benwoodward ([@benwoodward](https://github.com/benwoodward)) | [https://github.com/benwoodward/svelte-plyr](https://github.com/benwoodward/svelte-plyr) |
|
||||
|
||||
# Issues
|
||||
|
||||
@ -842,6 +845,8 @@ Plyr costs money to run, not only my time. I donate my time for free as I enjoy
|
||||
- [pressakey.com | Blog-Magazin für Videospiele](https://pressakey.com)
|
||||
- [STROLLÿN: Work with a View](https://strollyn.com)
|
||||
- [CFDA Runway360](https://runway360.cfda.com/)
|
||||
- [NKLAV | Filmmaker](https://nklav.com)
|
||||
- [GDI.JS.ORG - Google Drive Index](https://gitlab.com/GoogleDriveIndex/Google-Drive-Index)
|
||||
|
||||
If you want to be added to the list, open a pull request. It'd be awesome to see how you're using Plyr 😎
|
||||
|
||||
|
40
cspell.json
Normal file
40
cspell.json
Normal file
@ -0,0 +1,40 @@
|
||||
{
|
||||
"version": "0.2",
|
||||
"ignorePaths": [
|
||||
"package.json",
|
||||
"dist/*",
|
||||
"demo/node_modules/*"
|
||||
],
|
||||
"dictionaryDefinitions": [],
|
||||
"dictionaries": [],
|
||||
"words": [
|
||||
"autopause",
|
||||
"autoplay",
|
||||
"bote",
|
||||
"cfda",
|
||||
"classname",
|
||||
"digbmx",
|
||||
"fastly",
|
||||
"fullscreen",
|
||||
"gordita",
|
||||
"loadjs",
|
||||
"magazin",
|
||||
"menuitemradio",
|
||||
"noupe",
|
||||
"otransitionend",
|
||||
"playsinline",
|
||||
"plyr",
|
||||
"rutheneum",
|
||||
"seektime",
|
||||
"selz",
|
||||
"sparkk",
|
||||
"srclang",
|
||||
"strol",
|
||||
"stylelint",
|
||||
"unmute",
|
||||
"videospiele",
|
||||
"xywh"
|
||||
],
|
||||
"ignoreWords": [],
|
||||
"import": []
|
||||
}
|
@ -17,9 +17,10 @@ import toggleClass from './toggle-class';
|
||||
|
||||
(() => {
|
||||
const production = 'plyr.io';
|
||||
const isProduction = window.location.host.includes(production);
|
||||
|
||||
// Sentry for demo site (https://plyr.io) only
|
||||
if (window.location.host === production) {
|
||||
if (isProduction) {
|
||||
Sentry.init({
|
||||
dsn: 'https://d4ad9866ad834437a4754e23937071e4@sentry.io/305555',
|
||||
whitelistUrls: [production].map((d) => new RegExp(`https://(([a-z0-9])+(.))*${d}`)),
|
||||
@ -53,10 +54,10 @@ import toggleClass from './toggle-class';
|
||||
captions: {
|
||||
active: true,
|
||||
},
|
||||
ads: {
|
||||
enabled: window.location.host.includes(production),
|
||||
/* ads: {
|
||||
enabled: isProduction,
|
||||
publisherId: '918848828995742',
|
||||
},
|
||||
}, */
|
||||
previewThumbnails: {
|
||||
enabled: true,
|
||||
src: ['https://cdn.plyr.io/static/demo/thumbs/100p.vtt', 'https://cdn.plyr.io/static/demo/thumbs/240p.vtt'],
|
||||
@ -65,6 +66,34 @@ import toggleClass from './toggle-class';
|
||||
// Prevent Vimeo blocking plyr.io demo site
|
||||
referrerPolicy: 'no-referrer',
|
||||
},
|
||||
mediaMetadata: {
|
||||
title: 'View From A Blue Moon',
|
||||
album: 'Sports',
|
||||
artist: 'Brainfarm',
|
||||
artwork: [
|
||||
{
|
||||
src: 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.jpg',
|
||||
type: 'image/jpeg',
|
||||
},
|
||||
],
|
||||
},
|
||||
markers: {
|
||||
enabled: true,
|
||||
points: [
|
||||
{
|
||||
time: 10,
|
||||
label: 'first marker',
|
||||
},
|
||||
{
|
||||
time: 40,
|
||||
label: 'second marker',
|
||||
},
|
||||
{
|
||||
time: 120,
|
||||
label: '<strong>third</strong> marker',
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
// Expose for tinkering in the console
|
||||
|
@ -13,7 +13,7 @@ document.addEventListener('focusout', (event) => {
|
||||
|
||||
// Add classname to tabbed elements
|
||||
document.addEventListener('keydown', (event) => {
|
||||
if (event.keyCode !== 9) {
|
||||
if (event.key !== 'Tab') {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,11 @@
|
||||
@charset "UTF-8";
|
||||
|
||||
// ==========================================================================
|
||||
// Plyr.io Demo Page
|
||||
// ==========================================================================
|
||||
@charset 'UTF-8';
|
||||
|
||||
@import '../../../../src/sass/lib/css-vars';
|
||||
|
||||
$css-vars-use-native: true;
|
||||
|
||||
// Settings
|
||||
|
@ -1,7 +1,8 @@
|
||||
@charset "UTF-8";
|
||||
|
||||
// ==========================================================================
|
||||
// Plyr.io Error Page
|
||||
// ==========================================================================
|
||||
@charset 'UTF-8';
|
||||
|
||||
// Settings
|
||||
@import '../settings/colors';
|
||||
|
@ -45,7 +45,7 @@
|
||||
}
|
||||
|
||||
&.tab-focus {
|
||||
@include tab-focus();
|
||||
@include tab-focus;
|
||||
}
|
||||
|
||||
&:active {
|
||||
@ -64,7 +64,7 @@
|
||||
|
||||
// Count bubble
|
||||
.button__count {
|
||||
animation: fadein 0.2s ease;
|
||||
animation: fade-in 0.2s ease;
|
||||
background: $color-button-count-background;
|
||||
color: $color-button-count-text;
|
||||
margin-left: ($spacing-base * 0.75);
|
||||
|
@ -7,7 +7,7 @@ header {
|
||||
text-align: center;
|
||||
|
||||
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;
|
||||
font-weight: $font-weight-light;
|
||||
opacity: 0.5;
|
||||
|
@ -5,7 +5,7 @@
|
||||
// Make a <button> look like an <a>
|
||||
button.faux-link {
|
||||
@extend a; // stylelint-disable-line
|
||||
@include cancel-button-styles();
|
||||
@include cancel-button-styles;
|
||||
}
|
||||
|
||||
// Links
|
||||
@ -39,7 +39,7 @@ a {
|
||||
}
|
||||
|
||||
&.tab-focus {
|
||||
@include tab-focus();
|
||||
@include tab-focus;
|
||||
}
|
||||
|
||||
&.no-border::after {
|
||||
|
@ -3,23 +3,26 @@
|
||||
// ==========================================================================
|
||||
|
||||
// Fade
|
||||
@keyframes fadein {
|
||||
@keyframes fade-in {
|
||||
0% {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
100% {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes shrinkHide {
|
||||
@keyframes shrink-hide {
|
||||
0% {
|
||||
opacity: 0.5;
|
||||
width: 38px;
|
||||
}
|
||||
|
||||
20% {
|
||||
width: 45px;
|
||||
}
|
||||
|
||||
100% {
|
||||
opacity: 0;
|
||||
width: 0;
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
@font-face {
|
||||
font-display: swap;
|
||||
font-family: 'Gordita';
|
||||
font-family: Gordita;
|
||||
font-style: normal;
|
||||
font-weight: $font-weight-light;
|
||||
src: url('https://cdn.plyr.io/static/fonts/gordita-light.woff2') format('woff2'),
|
||||
@ -13,7 +13,7 @@
|
||||
|
||||
@font-face {
|
||||
font-display: swap;
|
||||
font-family: 'Gordita';
|
||||
font-family: Gordita;
|
||||
font-style: normal;
|
||||
font-weight: $font-weight-regular;
|
||||
src: url('https://cdn.plyr.io/static/fonts/gordita-regular.woff2') format('woff2'),
|
||||
@ -22,7 +22,7 @@
|
||||
|
||||
@font-face {
|
||||
font-display: swap;
|
||||
font-family: 'Gordita';
|
||||
font-family: Gordita;
|
||||
font-style: normal;
|
||||
font-weight: $font-weight-medium;
|
||||
src: url('https://cdn.plyr.io/static/fonts/gordita-medium.woff2') format('woff2'),
|
||||
@ -31,7 +31,7 @@
|
||||
|
||||
@font-face {
|
||||
font-display: swap;
|
||||
font-family: 'Gordita';
|
||||
font-family: Gordita;
|
||||
font-style: normal;
|
||||
font-weight: $font-weight-bold;
|
||||
src: url('https://cdn.plyr.io/static/fonts/gordita-bold.woff2') format('woff2'),
|
||||
@ -40,7 +40,7 @@
|
||||
|
||||
@font-face {
|
||||
font-display: swap;
|
||||
font-family: 'Gordita';
|
||||
font-family: Gordita;
|
||||
font-style: normal;
|
||||
font-weight: $font-weight-black;
|
||||
src: url('https://cdn.plyr.io/static/fonts/gordita-black.woff2') format('woff2'),
|
||||
|
@ -18,7 +18,7 @@
|
||||
position: relative;
|
||||
text-align: inherit;
|
||||
text-shadow: inherit;
|
||||
-moz-user-select: text; // stylelint-disable-line
|
||||
user-select: text;
|
||||
vertical-align: baseline;
|
||||
width: auto;
|
||||
}
|
||||
|
17
demo/src/sass/lib/normalize.scss
vendored
17
demo/src/sass/lib/normalize.scss
vendored
@ -11,8 +11,7 @@
|
||||
|
||||
html {
|
||||
line-height: 1.15; /* 1 */
|
||||
-ms-text-size-adjust: 100%; /* 2 */
|
||||
-webkit-text-size-adjust: 100%; /* 2 */
|
||||
text-size-adjust: 100%; /* 2 */
|
||||
}
|
||||
|
||||
/* Sections
|
||||
@ -89,7 +88,7 @@ hr {
|
||||
*/
|
||||
|
||||
pre {
|
||||
font-family: monospace, monospace; /* 1 */
|
||||
font-family: monospace; /* 1 */
|
||||
font-size: 1em; /* 2 */
|
||||
}
|
||||
|
||||
@ -103,7 +102,7 @@ pre {
|
||||
|
||||
a {
|
||||
background-color: transparent; /* 1 */
|
||||
-webkit-text-decoration-skip: objects; /* 2 */
|
||||
text-decoration-skip: objects; /* 2 */
|
||||
}
|
||||
|
||||
/**
|
||||
@ -112,7 +111,7 @@ a {
|
||||
*/
|
||||
|
||||
abbr[title] {
|
||||
border-bottom: none; /* 1 */
|
||||
border-bottom: 0; /* 1 */
|
||||
text-decoration: underline; /* 2 */
|
||||
text-decoration: underline dotted; /* 2 */
|
||||
}
|
||||
@ -281,7 +280,7 @@ button,
|
||||
html [type='button'],
|
||||
[type='reset'],
|
||||
[type='submit'] {
|
||||
-webkit-appearance: button; /* 2 */
|
||||
appearance: button; /* 2 */
|
||||
}
|
||||
|
||||
/**
|
||||
@ -375,7 +374,7 @@ textarea {
|
||||
*/
|
||||
|
||||
[type='search'] {
|
||||
-webkit-appearance: textfield; /* 1 */
|
||||
appearance: textfield; /* 1 */
|
||||
outline-offset: -2px; /* 2 */
|
||||
}
|
||||
|
||||
@ -385,7 +384,7 @@ textarea {
|
||||
|
||||
[type='search']::-webkit-search-cancel-button,
|
||||
[type='search']::-webkit-search-decoration {
|
||||
-webkit-appearance: none;
|
||||
appearance: none;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -394,7 +393,7 @@ textarea {
|
||||
*/
|
||||
|
||||
::-webkit-file-upload-button {
|
||||
-webkit-appearance: button; /* 1 */
|
||||
appearance: button; /* 1 */
|
||||
font: inherit; /* 2 */
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
// ==========================================================================
|
||||
|
||||
// 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-700: lighten($color-gray-800, 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%);
|
||||
|
||||
// Branding
|
||||
$color-brand-primary: hsl(198, 100%, 50%);
|
||||
$color-brand-primary: hsl(198deg 100% 50%);
|
||||
|
||||
// Text
|
||||
$color-text: $color-gray-700;
|
||||
@ -28,13 +28,13 @@ $color-twitter: #4baaf4;
|
||||
$color-link: $color-brand-primary;
|
||||
|
||||
// Background
|
||||
$color-background-from: hsl(198, 100%, 94%);
|
||||
$color-background-to: hsl(198, 100%, 98%);
|
||||
$color-background-from: hsl(198deg 100% 94%);
|
||||
$color-background-to: hsl(198deg 100% 98%);
|
||||
|
||||
// Buttons
|
||||
$color-button-background: $color-brand-primary;
|
||||
$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-text: $color-gray-600;
|
||||
|
||||
|
@ -4,18 +4,14 @@
|
||||
|
||||
$font-sans-serif: 'Gordita', 'Avenir', 'Helvetica Neue', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji',
|
||||
'Segoe UI Symbol';
|
||||
|
||||
$font-size-base: 15;
|
||||
$font-size-small: 13;
|
||||
$font-size-large: 18;
|
||||
$font-size-h1: 64;
|
||||
|
||||
$font-weight-light: 300;
|
||||
$font-weight-regular: 400;
|
||||
$font-weight-medium: 500;
|
||||
$font-weight-bold: 600;
|
||||
$font-weight-black: 900;
|
||||
|
||||
$line-height-base: 1.75;
|
||||
|
||||
$letter-spacing-headings: -0.025em;
|
||||
|
@ -8,8 +8,9 @@ html {
|
||||
}
|
||||
|
||||
body {
|
||||
@include font-smoothing();
|
||||
@include font-smoothing;
|
||||
@include font-size($font-size-base);
|
||||
|
||||
color: $color-text;
|
||||
font-family: $font-sans-serif;
|
||||
font-weight: $font-weight-medium;
|
||||
@ -30,5 +31,6 @@ small {
|
||||
|
||||
small {
|
||||
@include font-size($font-size-small);
|
||||
|
||||
display: block;
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
h1 {
|
||||
@include font-size($font-size-h1);
|
||||
|
||||
color: $color-headings;
|
||||
font-weight: $font-weight-bold;
|
||||
letter-spacing: $letter-spacing-headings;
|
||||
|
71
package.json
71
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "plyr",
|
||||
"version": "3.6.10",
|
||||
"version": "3.7.3",
|
||||
"description": "A simple, accessible and customizable HTML5, YouTube and Vimeo media player",
|
||||
"homepage": "https://plyr.io",
|
||||
"author": "Sam Potts <sam@potts.es>",
|
||||
@ -31,67 +31,68 @@
|
||||
"browserslist": "> 1%",
|
||||
"scripts": {
|
||||
"build": "gulp build",
|
||||
"lint": "eslint src/js && npm run-script remark",
|
||||
"lint:fix": "eslint --fix src/js",
|
||||
"lint": "eslint src/js && npm run remark && stylelint **/*.scss",
|
||||
"lint:fix": "eslint --fix src/js && stylelint **/*.scss --fix",
|
||||
"remark": "remark -f --use 'validate-links=repository:\"sampotts/plyr\"' '{,!(node_modules),.?**/}*.md'",
|
||||
"deploy": "yarn lint && gulp version && gulp build && gulp deploy",
|
||||
"format": "prettier --write \"./{src,demo/src}/**/*.{js,scss}\"",
|
||||
"spellcheck": "cspell \"**/*.{js,md,scss,json}\" --no-must-find-files",
|
||||
"start": "gulp"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.13.15",
|
||||
"@babel/plugin-proposal-class-properties": "^7.13.0",
|
||||
"@babel/preset-env": "^7.13.15",
|
||||
"@babel/core": "^7.20.2",
|
||||
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
||||
"@babel/plugin-proposal-optional-chaining": "^7.18.9",
|
||||
"@babel/preset-env": "^7.20.2",
|
||||
"@sampotts/eslint-config": "1.1.7",
|
||||
"autoprefixer": "^10.2.5",
|
||||
"aws-sdk": "^2.888.0",
|
||||
"autoprefixer": "^10.4.13",
|
||||
"aws-sdk": "^2.1256.0",
|
||||
"babel-eslint": "^10.1.0",
|
||||
"browser-sync": "^2.26.14",
|
||||
"colorette": "2.0.12",
|
||||
"cssnano": "^5.0.1",
|
||||
"del": "^6.0.0",
|
||||
"browser-sync": "^2.27.10",
|
||||
"colorette": "2.0.19",
|
||||
"cspell": "^6.14.2",
|
||||
"cssnano": "^5.1.14",
|
||||
"del": "^6.1.1",
|
||||
"eslint": "^7.23.0",
|
||||
"fancy-log": "^1.3.3",
|
||||
"fancy-log": "^2.0.0",
|
||||
"git-branch": "^2.0.1",
|
||||
"gulp": "^4.0.2",
|
||||
"gulp-awspublish": "^4.1.2",
|
||||
"gulp-awspublish": "^6.0.2",
|
||||
"gulp-better-rollup": "^4.0.1",
|
||||
"gulp-filter": "^6.0.0",
|
||||
"gulp-filter": "^7.0.0",
|
||||
"gulp-header": "^2.0.9",
|
||||
"gulp-hub": "^4.2.0",
|
||||
"gulp-if": "^3.0.0",
|
||||
"gulp-imagemin": "^7.1.0",
|
||||
"gulp-open": "^3.0.1",
|
||||
"gulp-plumber": "^1.2.1",
|
||||
"gulp-postcss": "^9.0.0",
|
||||
"gulp-postcss": "^9.0.1",
|
||||
"gulp-rename": "^2.0.0",
|
||||
"gulp-replace": "^1.0.0",
|
||||
"gulp-sass": "^5.0.0",
|
||||
"gulp-size": "^3.0.0",
|
||||
"gulp-replace": "^1.1.3",
|
||||
"gulp-sass": "^5.1.0",
|
||||
"gulp-size": "^4.0.1",
|
||||
"gulp-sourcemaps": "^3.0.0",
|
||||
"gulp-svgstore": "^7.0.1",
|
||||
"gulp-terser": "^2.0.1",
|
||||
"postcss": "^8.2.10",
|
||||
"postcss-custom-properties": "^11.0.0",
|
||||
"gulp-svgstore": "^9.0.0",
|
||||
"gulp-terser": "^2.1.0",
|
||||
"postcss": "^8.4.19",
|
||||
"postcss-custom-properties": "^12.1.9",
|
||||
"postcss-scss": "^4.0.5",
|
||||
"prettier-eslint": "^12.0.0",
|
||||
"prettier-stylelint": "^0.4.2",
|
||||
"remark-cli": "^9.0.0",
|
||||
"remark-validate-links": "^10.0.4",
|
||||
"rollup": "^2.45.2",
|
||||
"remark-cli": "^11.0.0",
|
||||
"remark-validate-links": "^12.1.0",
|
||||
"rollup": "^3.3.0",
|
||||
"rollup-plugin-babel": "^4.4.0",
|
||||
"rollup-plugin-commonjs": "^10.1.0",
|
||||
"rollup-plugin-node-resolve": "^5.2.0",
|
||||
"sass": "^1.42.1",
|
||||
"stylelint": "^13.12.0",
|
||||
"stylelint-config-prettier": "^8.0.2",
|
||||
"stylelint-config-recommended": "^4.0.0",
|
||||
"stylelint-config-sass-guidelines": "^8.0.0",
|
||||
"stylelint-order": "^4.1.0",
|
||||
"stylelint-scss": "^3.19.0",
|
||||
"stylelint-selector-bem-pattern": "^2.1.0"
|
||||
"sass": "^1.56.1",
|
||||
"stylelint": "^14.15.0",
|
||||
"stylelint-config-prettier": "^9.0.4",
|
||||
"stylelint-config-sass-guidelines": "^9.0.1",
|
||||
"stylelint-selector-bem-pattern": "^2.1.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"core-js": "^3.10.1",
|
||||
"core-js": "^3.26.1",
|
||||
"custom-event-polyfill": "^1.0.7",
|
||||
"loadjs": "^4.2.0",
|
||||
"rangetouch": "^2.0.1",
|
||||
|
@ -12,7 +12,9 @@
|
||||
|
||||
// Linting
|
||||
"stylelint.enable": true,
|
||||
"stylelint.validate": ["css", "scss"],
|
||||
"css.validate": false,
|
||||
"less.validate": false,
|
||||
"scss.validate": false,
|
||||
"javascript.validate.enable": false,
|
||||
|
||||
|
@ -47,6 +47,7 @@ const captions = {
|
||||
// Inject the container
|
||||
if (!is.element(this.elements.captions)) {
|
||||
this.elements.captions = createElement('div', getAttributesFromSelector(this.config.selectors.captions));
|
||||
this.elements.captions.setAttribute('dir', 'auto');
|
||||
|
||||
insertAfter(this.elements.captions, this.elements.wrapper);
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ const defaults = {
|
||||
// Sprite (for icons)
|
||||
loadSprite: true,
|
||||
iconPrefix: 'plyr',
|
||||
iconUrl: 'https://cdn.plyr.io/3.6.10/plyr.svg',
|
||||
iconUrl: 'https://cdn.plyr.io/3.7.3/plyr.svg',
|
||||
|
||||
// Blank video (used to prevent errors on source change)
|
||||
blankVideo: 'https://cdn.plyr.io/static/blank.mp4',
|
||||
@ -350,6 +350,7 @@ const defaults = {
|
||||
hover: 'plyr--hover',
|
||||
tooltip: 'plyr__tooltip',
|
||||
cues: 'plyr__cues',
|
||||
marker: 'plyr__progress__marker',
|
||||
hidden: 'plyr__sr-only',
|
||||
hideControls: 'plyr--hide-controls',
|
||||
isIos: 'plyr--is-ios',
|
||||
@ -441,6 +442,20 @@ const defaults = {
|
||||
customControls: true,
|
||||
noCookie: false, // Whether to use an alternative version of YouTube without cookies
|
||||
},
|
||||
|
||||
// Media Metadata
|
||||
mediaMetadata: {
|
||||
title: '',
|
||||
artist: '',
|
||||
album: '',
|
||||
artwork: [],
|
||||
},
|
||||
|
||||
// Markers
|
||||
markers: {
|
||||
enabled: false,
|
||||
points: [],
|
||||
},
|
||||
};
|
||||
|
||||
export default defaults;
|
||||
|
140
src/js/controls.js
vendored
140
src/js/controls.js
vendored
@ -404,7 +404,7 @@ const controls = {
|
||||
'keydown keyup',
|
||||
(event) => {
|
||||
// We only care about space and ⬆️ ⬇️️ ➡️
|
||||
if (![32, 38, 39, 40].includes(event.which)) {
|
||||
if (!['Space', 'ArrowUp', 'ArrowDown', 'ArrowRight'].includes(event.key)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -420,13 +420,13 @@ const controls = {
|
||||
const isRadioButton = matches(menuItem, '[role="menuitemradio"]');
|
||||
|
||||
// Show the respective menu
|
||||
if (!isRadioButton && [32, 39].includes(event.which)) {
|
||||
if (!isRadioButton && ['Space', 'ArrowRight'].includes(event.key)) {
|
||||
controls.showMenuPanel.call(this, type, true);
|
||||
} else {
|
||||
let target;
|
||||
|
||||
if (event.which !== 32) {
|
||||
if (event.which === 40 || (isRadioButton && event.which === 39)) {
|
||||
if (event.key !== 'Space') {
|
||||
if (event.key === 'ArrowDown' || (isRadioButton && event.key === 'ArrowRight')) {
|
||||
target = menuItem.nextElementSibling;
|
||||
|
||||
if (!is.element(target)) {
|
||||
@ -450,9 +450,7 @@ const controls = {
|
||||
// Enter will fire a `click` event but we still need to manage focus
|
||||
// So we bind to keyup which fires after and set focus here
|
||||
on.call(this, menuItem, 'keyup', (event) => {
|
||||
if (event.which !== 13) {
|
||||
return;
|
||||
}
|
||||
if (event.key !== 'Return') return;
|
||||
|
||||
controls.focusFirstMenuItem.call(this, null, true);
|
||||
});
|
||||
@ -484,7 +482,7 @@ const controls = {
|
||||
|
||||
menuItem.appendChild(flex);
|
||||
|
||||
// Replicate radio button behaviour
|
||||
// Replicate radio button behavior
|
||||
Object.defineProperty(menuItem, 'checked', {
|
||||
enumerable: true,
|
||||
get() {
|
||||
@ -506,7 +504,7 @@ const controls = {
|
||||
menuItem,
|
||||
'click keyup',
|
||||
(event) => {
|
||||
if (is.keyboardEvent(event) && event.which !== 32) {
|
||||
if (is.keyboardEvent(event) && event.key !== 'Space') {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -698,8 +696,9 @@ const controls = {
|
||||
return;
|
||||
}
|
||||
|
||||
const tipElement = this.elements.display.seekTooltip;
|
||||
const visible = `${this.config.classNames.tooltip}--visible`;
|
||||
const toggle = (show) => toggleClass(this.elements.display.seekTooltip, visible, show);
|
||||
const toggle = (show) => toggleClass(tipElement, visible, show);
|
||||
|
||||
// Hide on touch
|
||||
if (this.touch) {
|
||||
@ -713,8 +712,8 @@ const controls = {
|
||||
|
||||
if (is.event(event)) {
|
||||
percent = (100 / clientRect.width) * (event.pageX - clientRect.left);
|
||||
} else if (hasClass(this.elements.display.seekTooltip, visible)) {
|
||||
percent = parseFloat(this.elements.display.seekTooltip.style.left, 10);
|
||||
} else if (hasClass(tipElement, visible)) {
|
||||
percent = parseFloat(tipElement.style.left, 10);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
@ -726,11 +725,21 @@ const controls = {
|
||||
percent = 100;
|
||||
}
|
||||
|
||||
const time = (this.duration / 100) * percent;
|
||||
|
||||
// Display the time a click would seek to
|
||||
controls.updateTimeDisplay.call(this, this.elements.display.seekTooltip, (this.duration / 100) * percent);
|
||||
tipElement.innerText = controls.formatTime(time);
|
||||
|
||||
// Get marker point for time
|
||||
const point = this.config.markers?.points?.find(({ time: t }) => t === Math.round(time));
|
||||
|
||||
// Append the point label to the tooltip
|
||||
if (point) {
|
||||
tipElement.insertAdjacentHTML('afterbegin', `${point.label}<br>`);
|
||||
}
|
||||
|
||||
// Set position
|
||||
this.elements.display.seekTooltip.style.left = `${percent}%`;
|
||||
tipElement.style.left = `${percent}%`;
|
||||
|
||||
// Show/hide the tooltip
|
||||
// If the event is a moues in/out and percentage is inside bounds
|
||||
@ -796,6 +805,10 @@ const controls = {
|
||||
controls.updateTimeDisplay.call(this, this.elements.display.duration, this.duration);
|
||||
}
|
||||
|
||||
if (this.config.markers.enabled) {
|
||||
controls.setMarkers.call(this);
|
||||
}
|
||||
|
||||
// Update the tooltip (if visible)
|
||||
controls.updateSeekTooltip.call(this);
|
||||
},
|
||||
@ -1124,7 +1137,7 @@ const controls = {
|
||||
|
||||
if (is.boolean(input)) {
|
||||
show = input;
|
||||
} else if (is.keyboardEvent(input) && input.which === 27) {
|
||||
} else if (is.keyboardEvent(input) && input.key === 'Escape') {
|
||||
show = false;
|
||||
} else if (is.event(input)) {
|
||||
// If Plyr is in a shadowDOM, the event target is set to the component, instead of the
|
||||
@ -1512,10 +1525,7 @@ const controls = {
|
||||
pane,
|
||||
'keydown',
|
||||
(event) => {
|
||||
// We only care about <-
|
||||
if (event.which !== 37) {
|
||||
return;
|
||||
}
|
||||
if (event.key !== 'ArrowLeft') return;
|
||||
|
||||
// Prevent seek
|
||||
event.preventDefault();
|
||||
@ -1705,13 +1715,17 @@ const controls = {
|
||||
if (!is.empty(this.elements.buttons)) {
|
||||
const addProperty = (button) => {
|
||||
const className = this.config.classNames.controlPressed;
|
||||
button.setAttribute('aria-pressed', 'false');
|
||||
|
||||
Object.defineProperty(button, 'pressed', {
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
get() {
|
||||
return hasClass(button, className);
|
||||
},
|
||||
set(pressed = false) {
|
||||
toggleClass(button, className, pressed);
|
||||
button.setAttribute('aria-pressed', pressed ? 'true' : 'false');
|
||||
},
|
||||
});
|
||||
};
|
||||
@ -1745,6 +1759,94 @@ const controls = {
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// Set media metadata
|
||||
setMediaMetadata() {
|
||||
try {
|
||||
if ('mediaSession' in navigator) {
|
||||
navigator.mediaSession.metadata = new window.MediaMetadata({
|
||||
title: this.config.mediaMetadata.title,
|
||||
artist: this.config.mediaMetadata.artist,
|
||||
album: this.config.mediaMetadata.album,
|
||||
artwork: this.config.mediaMetadata.artwork,
|
||||
});
|
||||
}
|
||||
} catch (_) {
|
||||
// Do nothing
|
||||
}
|
||||
},
|
||||
|
||||
// Add markers
|
||||
setMarkers() {
|
||||
if (!this.duration || this.elements.markers) return;
|
||||
|
||||
// Get valid points
|
||||
const points = this.config.markers?.points?.filter(({ time }) => time > 0 && time < this.duration);
|
||||
if (!points?.length) return;
|
||||
|
||||
const containerFragment = document.createDocumentFragment();
|
||||
const pointsFragment = document.createDocumentFragment();
|
||||
let tipElement = null;
|
||||
const tipVisible = `${this.config.classNames.tooltip}--visible`;
|
||||
const toggleTip = (show) => toggleClass(tipElement, tipVisible, show);
|
||||
|
||||
// Inject markers to progress container
|
||||
points.forEach((point) => {
|
||||
const markerElement = createElement(
|
||||
'span',
|
||||
{
|
||||
class: this.config.classNames.marker,
|
||||
},
|
||||
'',
|
||||
);
|
||||
|
||||
const left = `${(point.time / this.duration) * 100}%`;
|
||||
|
||||
if (tipElement) {
|
||||
// Show on hover
|
||||
markerElement.addEventListener('mouseenter', () => {
|
||||
if (point.label) return;
|
||||
tipElement.style.left = left;
|
||||
tipElement.innerHTML = point.label;
|
||||
toggleTip(true);
|
||||
});
|
||||
|
||||
// Hide on leave
|
||||
markerElement.addEventListener('mouseleave', () => {
|
||||
toggleTip(false);
|
||||
});
|
||||
}
|
||||
|
||||
markerElement.addEventListener('click', () => {
|
||||
this.currentTime = point.time;
|
||||
});
|
||||
|
||||
markerElement.style.left = left;
|
||||
pointsFragment.appendChild(markerElement);
|
||||
});
|
||||
|
||||
containerFragment.appendChild(pointsFragment);
|
||||
|
||||
// Inject a tooltip if needed
|
||||
if (!this.config.tooltips.seek) {
|
||||
tipElement = createElement(
|
||||
'span',
|
||||
{
|
||||
class: this.config.classNames.tooltip,
|
||||
},
|
||||
'',
|
||||
);
|
||||
|
||||
containerFragment.appendChild(tipElement);
|
||||
}
|
||||
|
||||
this.elements.markers = {
|
||||
points: pointsFragment,
|
||||
tip: tipElement,
|
||||
};
|
||||
|
||||
this.elements.progress.appendChild(containerFragment);
|
||||
},
|
||||
};
|
||||
|
||||
export default controls;
|
||||
|
@ -207,7 +207,7 @@ class Fullscreen {
|
||||
// Trap focus inside container
|
||||
trapFocus = (event) => {
|
||||
// Bail if iOS, not active, not the tab key
|
||||
if (browser.isIos || !this.active || event.key !== 'Tab' || event.keyCode !== 9) {
|
||||
if (browser.isIos || !this.active || event.key !== 'Tab') {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -29,25 +29,25 @@ class Listeners {
|
||||
handleKey(event) {
|
||||
const { player } = this;
|
||||
const { elements } = player;
|
||||
const code = event.keyCode ? event.keyCode : event.which;
|
||||
const pressed = event.type === 'keydown';
|
||||
const repeat = pressed && code === this.lastKey;
|
||||
const { key, type, altKey, ctrlKey, metaKey, shiftKey } = event;
|
||||
const pressed = type === 'keydown';
|
||||
const repeat = pressed && key === this.lastKey;
|
||||
|
||||
// Bail if a modifier key is set
|
||||
if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) {
|
||||
if (altKey || ctrlKey || metaKey || shiftKey) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If the event is bubbled from the media element
|
||||
// Firefox doesn't get the keycode for whatever reason
|
||||
if (!is.number(code)) {
|
||||
// Firefox doesn't get the key for whatever reason
|
||||
if (!key) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Seek by the number keys
|
||||
const seekByKey = () => {
|
||||
// Seek by increment
|
||||
const seekByIncrement = (increment) => {
|
||||
// Divide the max duration into 10th's and times by the number value
|
||||
player.currentTime = (player.duration / 10) * (code - 48);
|
||||
player.currentTime = (player.duration / 10) * increment;
|
||||
};
|
||||
|
||||
// Handle the key on keydown
|
||||
@ -65,113 +65,114 @@ class Listeners {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.which === 32 && matches(focused, 'button, [role^="menuitem"]')) {
|
||||
if (event.key === 'Space' && matches(focused, 'button, [role^="menuitem"]')) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Which keycodes should we prevent default
|
||||
const preventDefault = [32, 37, 38, 39, 40, 48, 49, 50, 51, 52, 53, 54, 56, 57, 67, 70, 73, 75, 76, 77, 79];
|
||||
// Which keys should we prevent default
|
||||
const preventDefault = [
|
||||
'Space',
|
||||
'ArrowLeft',
|
||||
'ArrowUp',
|
||||
'ArrowRight',
|
||||
'ArrowDown',
|
||||
|
||||
// If the code is found prevent default (e.g. prevent scrolling for arrows)
|
||||
if (preventDefault.includes(code)) {
|
||||
'0',
|
||||
'1',
|
||||
'2',
|
||||
'3',
|
||||
'4',
|
||||
'5',
|
||||
'6',
|
||||
'7',
|
||||
'8',
|
||||
'9',
|
||||
|
||||
'c',
|
||||
'f',
|
||||
'k',
|
||||
'l',
|
||||
'm',
|
||||
];
|
||||
|
||||
// If the key is found prevent default (e.g. prevent scrolling for arrows)
|
||||
if (preventDefault.includes(key)) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}
|
||||
|
||||
switch (code) {
|
||||
case 48:
|
||||
case 49:
|
||||
case 50:
|
||||
case 51:
|
||||
case 52:
|
||||
case 53:
|
||||
case 54:
|
||||
case 55:
|
||||
case 56:
|
||||
case 57:
|
||||
// 0-9
|
||||
switch (key) {
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
if (!repeat) {
|
||||
seekByKey();
|
||||
seekByIncrement(parseInt(key, 10));
|
||||
}
|
||||
break;
|
||||
|
||||
case 32:
|
||||
case 75:
|
||||
// Space and K key
|
||||
case 'Space':
|
||||
case 'k':
|
||||
if (!repeat) {
|
||||
silencePromise(player.togglePlay());
|
||||
}
|
||||
break;
|
||||
|
||||
case 38:
|
||||
// Arrow up
|
||||
case 'ArrowUp':
|
||||
player.increaseVolume(0.1);
|
||||
break;
|
||||
|
||||
case 40:
|
||||
// Arrow down
|
||||
case 'ArrowDown':
|
||||
player.decreaseVolume(0.1);
|
||||
break;
|
||||
|
||||
case 77:
|
||||
// M key
|
||||
case 'm':
|
||||
if (!repeat) {
|
||||
player.muted = !player.muted;
|
||||
}
|
||||
break;
|
||||
|
||||
case 39:
|
||||
// Arrow forward
|
||||
case 'ArrowRight':
|
||||
player.forward();
|
||||
break;
|
||||
|
||||
case 37:
|
||||
// Arrow back
|
||||
case 'ArrowLeft':
|
||||
player.rewind();
|
||||
break;
|
||||
|
||||
case 70:
|
||||
// F key
|
||||
case 'f':
|
||||
player.fullscreen.toggle();
|
||||
break;
|
||||
|
||||
case 67:
|
||||
// C key
|
||||
case 'c':
|
||||
if (!repeat) {
|
||||
player.toggleCaptions();
|
||||
}
|
||||
break;
|
||||
|
||||
case 76:
|
||||
// L key
|
||||
case 'l':
|
||||
player.loop = !player.loop;
|
||||
break;
|
||||
|
||||
/* case 73:
|
||||
this.setLoop('start');
|
||||
break;
|
||||
|
||||
case 76:
|
||||
this.setLoop();
|
||||
break;
|
||||
|
||||
case 79:
|
||||
this.setLoop('end');
|
||||
break; */
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Escape is handle natively when in full screen
|
||||
// So we only need to worry about non native
|
||||
if (code === 27 && !player.fullscreen.usingNative && player.fullscreen.active) {
|
||||
if (key === 'Escape' && !player.fullscreen.usingNative && player.fullscreen.active) {
|
||||
player.fullscreen.toggle();
|
||||
}
|
||||
|
||||
// Store last code for next cycle
|
||||
this.lastKey = code;
|
||||
// Store last key for next cycle
|
||||
this.lastKey = key;
|
||||
} else {
|
||||
this.lastKey = null;
|
||||
}
|
||||
@ -196,17 +197,18 @@ class Listeners {
|
||||
setTabFocus = (event) => {
|
||||
const { player } = this;
|
||||
const { elements } = player;
|
||||
const { key, type, timeStamp } = event;
|
||||
|
||||
clearTimeout(this.focusTimer);
|
||||
|
||||
// Ignore any key other than tab
|
||||
if (event.type === 'keydown' && event.which !== 9) {
|
||||
if (type === 'keydown' && key !== 'Tab') {
|
||||
return;
|
||||
}
|
||||
|
||||
// Store reference to event timeStamp
|
||||
if (event.type === 'keydown') {
|
||||
this.lastKeyDown = event.timeStamp;
|
||||
if (type === 'keydown') {
|
||||
this.lastKeyDown = timeStamp;
|
||||
}
|
||||
|
||||
// Remove current classes
|
||||
@ -217,10 +219,10 @@ class Listeners {
|
||||
};
|
||||
|
||||
// Determine if a key was pressed to trigger this event
|
||||
const wasKeyDown = event.timeStamp - this.lastKeyDown <= 20;
|
||||
const wasKeyDown = timeStamp - this.lastKeyDown <= 20;
|
||||
|
||||
// Ignore focus events if a key was pressed prior
|
||||
if (event.type === 'focus' && !wasKeyDown) {
|
||||
if (type === 'focus' && !wasKeyDown) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -229,7 +231,7 @@ class Listeners {
|
||||
|
||||
// Delay the adding of classname until the focus has changed
|
||||
// This event fires before the focusin event
|
||||
if (event.type !== 'focusout') {
|
||||
if (type !== 'focusout') {
|
||||
this.focusTimer = setTimeout(() => {
|
||||
const focused = document.activeElement;
|
||||
|
||||
@ -661,15 +663,12 @@ class Listeners {
|
||||
elements.buttons.settings,
|
||||
'keyup',
|
||||
(event) => {
|
||||
const code = event.which;
|
||||
|
||||
// We only care about space and return
|
||||
if (![13, 32].includes(code)) {
|
||||
if (!['Space', 'Enter'].includes(event.key)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Because return triggers a click anyway, all we need to do is set focus
|
||||
if (code === 13) {
|
||||
if (event.key === 'Enter') {
|
||||
controls.focusFirstMenuItem.call(player, null, true);
|
||||
return;
|
||||
}
|
||||
@ -689,7 +688,7 @@ class Listeners {
|
||||
|
||||
// Escape closes menu
|
||||
this.bind(elements.settings.menu, 'keydown', (event) => {
|
||||
if (event.which === 27) {
|
||||
if (event.key === 'Escape') {
|
||||
controls.toggleMenu.call(player, event);
|
||||
}
|
||||
});
|
||||
@ -704,10 +703,9 @@ class Listeners {
|
||||
// Pause while seeking
|
||||
this.bind(elements.inputs.seek, 'mousedown mouseup keydown keyup touchstart touchend', (event) => {
|
||||
const seek = event.currentTarget;
|
||||
const code = event.keyCode ? event.keyCode : event.which;
|
||||
const attribute = 'play-on-seeked';
|
||||
|
||||
if (is.keyboardEvent(event) && code !== 39 && code !== 37) {
|
||||
if (is.keyboardEvent(event) && !['ArrowLeft', 'ArrowRight'].includes(event.key)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -883,7 +881,7 @@ class Listeners {
|
||||
elements.inputs.volume,
|
||||
'wheel',
|
||||
(event) => {
|
||||
// Detect "natural" scroll - suppored on OS X Safari only
|
||||
// Detect "natural" scroll - supported on OS X Safari only
|
||||
// Other browsers on OS X will be inverted until support improves
|
||||
const inverted = event.webkitDirectionInvertedFromDevice;
|
||||
// Get delta from event. Invert if `inverted` is true
|
||||
|
@ -240,7 +240,7 @@ class Ads {
|
||||
|
||||
/**
|
||||
* This method is called whenever the ads are ready inside the AdDisplayContainer
|
||||
* @param {Event} adsManagerLoadedEvent
|
||||
* @param {Event} event - adsManagerLoadedEvent
|
||||
*/
|
||||
onAdsManagerLoaded = (event) => {
|
||||
// Load could occur after a source change (race condition)
|
||||
@ -581,6 +581,7 @@ class Ads {
|
||||
/**
|
||||
* Handles callbacks after an ad event was invoked
|
||||
* @param {String} event - Event type
|
||||
* @param args
|
||||
*/
|
||||
trigger = (event, ...args) => {
|
||||
const handlers = this.events[event];
|
||||
|
@ -2,6 +2,7 @@ import { createElement } from '../utils/elements';
|
||||
import { once } from '../utils/events';
|
||||
import fetch from '../utils/fetch';
|
||||
import is from '../utils/is';
|
||||
import { clamp } from '../utils/numbers';
|
||||
import { formatTime } from '../utils/time';
|
||||
|
||||
// Arg: vttDataString example: "WEBVTT\n\n1\n00:00:05.000 --> 00:00:10.000\n1080p-00001.jpg"
|
||||
@ -109,9 +110,7 @@ class PreviewThumbnails {
|
||||
this.player.elements.display.seekTooltip.hidden = this.enabled;
|
||||
}
|
||||
|
||||
if (!this.enabled) {
|
||||
return;
|
||||
}
|
||||
if (!this.enabled) return;
|
||||
|
||||
this.getThumbnails().then(() => {
|
||||
if (!this.enabled) {
|
||||
@ -205,18 +204,12 @@ class PreviewThumbnails {
|
||||
};
|
||||
|
||||
startMove = (event) => {
|
||||
if (!this.loaded) {
|
||||
return;
|
||||
}
|
||||
if (!this.loaded) return;
|
||||
|
||||
if (!is.event(event) || !['touchmove', 'mousemove'].includes(event.type)) {
|
||||
return;
|
||||
}
|
||||
if (!is.event(event) || !['touchmove', 'mousemove'].includes(event.type)) return;
|
||||
|
||||
// Wait until media has a duration
|
||||
if (!this.player.media.duration) {
|
||||
return;
|
||||
}
|
||||
if (!this.player.media.duration) return;
|
||||
|
||||
if (event.type === 'touchmove') {
|
||||
// Calculate seek hover position as approx video seconds
|
||||
@ -241,6 +234,15 @@ class PreviewThumbnails {
|
||||
|
||||
// Set time text inside image container
|
||||
this.elements.thumb.time.innerText = formatTime(this.seekTime);
|
||||
|
||||
// Get marker point for time
|
||||
const point = this.player.config.markers?.points?.find(({ time: t }) => t === Math.round(this.seekTime));
|
||||
|
||||
// Append the point label to the tooltip
|
||||
if (point) {
|
||||
// this.elements.thumb.time.innerText.concat('\n');
|
||||
this.elements.thumb.time.insertAdjacentHTML('afterbegin', `${point.label}<br>`);
|
||||
}
|
||||
}
|
||||
|
||||
// Download and show image
|
||||
@ -326,7 +328,7 @@ class PreviewThumbnails {
|
||||
this.elements.thumb.time = createElement('span', {}, '00:00');
|
||||
timeContainer.appendChild(this.elements.thumb.time);
|
||||
|
||||
this.elements.thumb.container.appendChild(timeContainer);
|
||||
this.elements.thumb.imageContainer.appendChild(timeContainer);
|
||||
|
||||
// Inject the whole thumb
|
||||
if (is.element(this.player.elements.progress)) {
|
||||
@ -382,7 +384,7 @@ class PreviewThumbnails {
|
||||
}
|
||||
});
|
||||
|
||||
// Only proceed if either thumbnum or thumbfilename has changed
|
||||
// Only proceed if either thumb num or thumbfilename has changed
|
||||
if (thumbNum !== this.showingThumb) {
|
||||
this.showingThumb = thumbNum;
|
||||
this.loadImage(qualityIndex);
|
||||
@ -553,11 +555,7 @@ class PreviewThumbnails {
|
||||
};
|
||||
|
||||
get currentImageContainer() {
|
||||
if (this.mouseDown) {
|
||||
return this.elements.scrubbing.container;
|
||||
}
|
||||
|
||||
return this.elements.thumb.imageContainer;
|
||||
return this.mouseDown ? this.elements.scrubbing.container : this.elements.thumb.imageContainer;
|
||||
}
|
||||
|
||||
get usingSprites() {
|
||||
@ -590,11 +588,7 @@ class PreviewThumbnails {
|
||||
}
|
||||
|
||||
get currentImageElement() {
|
||||
if (this.mouseDown) {
|
||||
return this.currentScrubbingImageElement;
|
||||
}
|
||||
|
||||
return this.currentThumbnailImageElement;
|
||||
return this.mouseDown ? this.currentScrubbingImageElement : this.currentThumbnailImageElement;
|
||||
}
|
||||
|
||||
set currentImageElement(element) {
|
||||
@ -634,46 +628,39 @@ class PreviewThumbnails {
|
||||
|
||||
// Set the size to be about a quarter of the size of video. Unless option dynamicSize === false, in which case it needs to be set in CSS
|
||||
setThumbContainerSizeAndPos = () => {
|
||||
const { imageContainer } = this.elements.thumb;
|
||||
|
||||
if (!this.sizeSpecifiedInCSS) {
|
||||
const thumbWidth = Math.floor(this.thumbContainerHeight * this.thumbAspectRatio);
|
||||
this.elements.thumb.imageContainer.style.height = `${this.thumbContainerHeight}px`;
|
||||
this.elements.thumb.imageContainer.style.width = `${thumbWidth}px`;
|
||||
} else if (
|
||||
this.elements.thumb.imageContainer.clientHeight > 20 &&
|
||||
this.elements.thumb.imageContainer.clientWidth < 20
|
||||
) {
|
||||
const thumbWidth = Math.floor(this.elements.thumb.imageContainer.clientHeight * this.thumbAspectRatio);
|
||||
this.elements.thumb.imageContainer.style.width = `${thumbWidth}px`;
|
||||
} else if (
|
||||
this.elements.thumb.imageContainer.clientHeight < 20 &&
|
||||
this.elements.thumb.imageContainer.clientWidth > 20
|
||||
) {
|
||||
const thumbHeight = Math.floor(this.elements.thumb.imageContainer.clientWidth / this.thumbAspectRatio);
|
||||
this.elements.thumb.imageContainer.style.height = `${thumbHeight}px`;
|
||||
imageContainer.style.height = `${this.thumbContainerHeight}px`;
|
||||
imageContainer.style.width = `${thumbWidth}px`;
|
||||
} else if (imageContainer.clientHeight > 20 && imageContainer.clientWidth < 20) {
|
||||
const thumbWidth = Math.floor(imageContainer.clientHeight * this.thumbAspectRatio);
|
||||
imageContainer.style.width = `${thumbWidth}px`;
|
||||
} else if (imageContainer.clientHeight < 20 && imageContainer.clientWidth > 20) {
|
||||
const thumbHeight = Math.floor(imageContainer.clientWidth / this.thumbAspectRatio);
|
||||
imageContainer.style.height = `${thumbHeight}px`;
|
||||
}
|
||||
|
||||
this.setThumbContainerPos();
|
||||
};
|
||||
|
||||
setThumbContainerPos = () => {
|
||||
const seekbarRect = this.player.elements.progress.getBoundingClientRect();
|
||||
const plyrRect = this.player.elements.container.getBoundingClientRect();
|
||||
const scrubberRect = this.player.elements.progress.getBoundingClientRect();
|
||||
const containerRect = this.player.elements.container.getBoundingClientRect();
|
||||
const { container } = this.elements.thumb;
|
||||
// Find the lowest and highest desired left-position, so we don't slide out the side of the video container
|
||||
const minVal = plyrRect.left - seekbarRect.left + 10;
|
||||
const maxVal = plyrRect.right - seekbarRect.left - container.clientWidth - 10;
|
||||
const min = containerRect.left - scrubberRect.left + 10;
|
||||
const max = containerRect.right - scrubberRect.left - container.clientWidth - 10;
|
||||
// Set preview container position to: mousepos, minus seekbar.left, minus half of previewContainer.clientWidth
|
||||
let previewPos = this.mousePosX - seekbarRect.left - container.clientWidth / 2;
|
||||
const position = this.mousePosX - scrubberRect.left - container.clientWidth / 2;
|
||||
const clamped = clamp(position, min, max);
|
||||
|
||||
if (previewPos < minVal) {
|
||||
previewPos = minVal;
|
||||
}
|
||||
// Move the popover position
|
||||
container.style.left = `${clamped}px`;
|
||||
|
||||
if (previewPos > maxVal) {
|
||||
previewPos = maxVal;
|
||||
}
|
||||
|
||||
container.style.left = `${previewPos}px`;
|
||||
// The arrow can follow the cursor
|
||||
container.style.setProperty('--preview-arrow-offset', `${position - clamped}px`);
|
||||
};
|
||||
|
||||
// Can't use 100% width, in case the video is a different aspect ratio to the video container
|
||||
@ -688,9 +675,7 @@ class PreviewThumbnails {
|
||||
|
||||
// Sprites need to be offset to the correct location
|
||||
setImageSizeAndOffset = (previewImage, frame) => {
|
||||
if (!this.usingSprites) {
|
||||
return;
|
||||
}
|
||||
if (!this.usingSprites) return;
|
||||
|
||||
// Find difference between height and preview container height
|
||||
const multiplier = this.thumbContainerHeight / frame.h;
|
||||
|
@ -35,12 +35,12 @@ function parseHash(url) {
|
||||
* - [https://player.]vimeo.com/video/{id}?h={hash}[¶ms]
|
||||
* - [https://player.]vimeo.com/video/{id}?[params]&h={hash}
|
||||
* - video/{id}/{hash}
|
||||
* If matched, the hash is available in the named group `hash`
|
||||
* If matched, the hash is available in capture group 4
|
||||
*/
|
||||
const regex = /^.*(?:vimeo.com\/|video\/)(?:\d+)(?:\?.*&*h=|\/)+(?<hash>[\d,a-f]+)/;
|
||||
const regex = /^.*(vimeo.com\/|video\/)(\d+)(\?.*&*h=|\/)+([\d,a-f]+)/;
|
||||
const found = url.match(regex);
|
||||
|
||||
return found ? found.groups.hash : null;
|
||||
return found && found.length === 5 ? found[4] : null;
|
||||
}
|
||||
|
||||
// Set playback state and trigger change (only on actual change)
|
||||
|
45
src/js/plyr.d.ts
vendored
45
src/js/plyr.d.ts
vendored
@ -212,7 +212,7 @@ declare class Plyr {
|
||||
airplay(): void;
|
||||
|
||||
/**
|
||||
* Sets the preview thubmnails for the current source.
|
||||
* Sets the preview thumbnails for the current source.
|
||||
*/
|
||||
setPreviewThumbnails(source: Plyr.PreviewThumbnailsOptions): void;
|
||||
|
||||
@ -272,8 +272,8 @@ declare namespace Plyr {
|
||||
controlsshown: PlyrEvent;
|
||||
ready: PlyrEvent;
|
||||
};
|
||||
// For retrocompatibility, we keep StandadEvent
|
||||
type StandadEvent = keyof Plyr.StandardEventMap;
|
||||
// For retrocompatibility, we keep StandardEvent
|
||||
type StandardEvent = keyof Plyr.StandardEventMap;
|
||||
type Html5EventMap = {
|
||||
loadstart: PlyrEvent;
|
||||
loadeddata: PlyrEvent;
|
||||
@ -341,7 +341,7 @@ declare namespace Plyr {
|
||||
* id (the unique id for the player), seektime (the seektime step in seconds), and title (the media title). See CONTROLS.md for more info on how the html needs to be structured.
|
||||
* Defaults to ['play-large', 'play', 'progress', 'current-time', 'mute', 'volume', 'captions', 'settings', 'pip', 'airplay', 'fullscreen']
|
||||
*/
|
||||
controls?: string[] | ((id: string, seektime: number, title: string) => unknown) | Element;
|
||||
controls?: string | string[] | ((id: string, seektime: number, title: string) => unknown) | Element;
|
||||
|
||||
/**
|
||||
* If you're using the default controls are used then you can specify which settings to show in the menu
|
||||
@ -459,7 +459,7 @@ declare namespace Plyr {
|
||||
* Allows binding of event listeners to the controls before the default handlers. See the defaults.js for available listeners.
|
||||
* If your handler prevents default on the event (event.preventDefault()), the default handler will not fire.
|
||||
*/
|
||||
listeners?: {[key: string]: (error: PlyrEvent) => void};
|
||||
listeners?: { [key: string]: (error: PlyrEvent) => void };
|
||||
|
||||
/**
|
||||
* active: Toggles if captions should be active by default. language: Sets the default language to load (if available). 'auto' uses the browser language.
|
||||
@ -518,6 +518,16 @@ declare namespace Plyr {
|
||||
* Preview Thumbnails Options.
|
||||
*/
|
||||
previewThumbnails?: PreviewThumbnailsOptions;
|
||||
|
||||
/**
|
||||
* Media Metadata Options.
|
||||
*/
|
||||
mediaMetadata?: MediaMetadataOptions;
|
||||
|
||||
/**
|
||||
* Markers Options
|
||||
*/
|
||||
markers?: MarkersOptions;
|
||||
}
|
||||
|
||||
interface QualityOptions {
|
||||
@ -576,6 +586,29 @@ declare namespace Plyr {
|
||||
src?: string | string[];
|
||||
}
|
||||
|
||||
interface MediaMetadataArtwork {
|
||||
src: string;
|
||||
sizes?: string;
|
||||
type: string;
|
||||
}
|
||||
|
||||
interface MediaMetadataOptions {
|
||||
title?: string;
|
||||
artist?: string;
|
||||
album?: string;
|
||||
artwork?: MediaMetadataArtwork[];
|
||||
}
|
||||
|
||||
interface MarkersPoints {
|
||||
time: number;
|
||||
label: string;
|
||||
}
|
||||
|
||||
interface MarkersOptions {
|
||||
enabled: boolean;
|
||||
points: MarkersPoints[];
|
||||
}
|
||||
|
||||
export interface Elements {
|
||||
buttons: {
|
||||
airplay?: HTMLButtonElement;
|
||||
@ -667,7 +700,7 @@ declare namespace Plyr {
|
||||
}
|
||||
|
||||
interface PlyrEvent extends CustomEvent {
|
||||
readonly detail: {readonly plyr: Plyr};
|
||||
readonly detail: { readonly plyr: Plyr };
|
||||
}
|
||||
|
||||
enum YoutubeState {
|
||||
|
@ -1,6 +1,6 @@
|
||||
// ==========================================================================
|
||||
// Plyr
|
||||
// plyr.js v3.6.10
|
||||
// plyr.js v3.7.3
|
||||
// https://github.com/sampotts/plyr
|
||||
// License: The MIT License (MIT)
|
||||
// ==========================================================================
|
||||
@ -649,7 +649,7 @@ class Plyr {
|
||||
|
||||
/**
|
||||
* Set playback speed
|
||||
* @param {Number} speed - the speed of playback (0.5-2.0)
|
||||
* @param {Number} input - the speed of playback (0.5-2.0)
|
||||
*/
|
||||
set speed(input) {
|
||||
let speed = null;
|
||||
@ -933,8 +933,7 @@ class Plyr {
|
||||
* @param {Boolean} input - Whether to autoplay or not
|
||||
*/
|
||||
set autoplay(input) {
|
||||
const toggle = is.boolean(input) ? input : this.config.autoplay;
|
||||
this.config.autoplay = toggle;
|
||||
this.config.autoplay = is.boolean(input) ? input : this.config.autoplay;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -954,11 +953,11 @@ class Plyr {
|
||||
|
||||
/**
|
||||
* Set the caption track by index
|
||||
* @param {Number} - Caption index
|
||||
* @param {Number} input - Caption index
|
||||
*/
|
||||
set currentTrack(input) {
|
||||
captions.set.call(this, input, false);
|
||||
captions.setup();
|
||||
captions.setup.call(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -972,7 +971,7 @@ class Plyr {
|
||||
/**
|
||||
* Set the wanted language for captions
|
||||
* Since tracks can be added later it won't update the actual caption track until there is a matching track
|
||||
* @param {String} - Two character ISO language code (e.g. EN, FR, PT, etc)
|
||||
* @param {String} input - Two character ISO language code (e.g. EN, FR, PT, etc)
|
||||
*/
|
||||
set language(input) {
|
||||
captions.setLanguage.call(this, input, false);
|
||||
|
@ -1,6 +1,6 @@
|
||||
// ==========================================================================
|
||||
// Plyr Polyfilled Build
|
||||
// plyr.js v3.6.10
|
||||
// plyr.js v3.7.3
|
||||
// https://github.com/sampotts/plyr
|
||||
// License: The MIT License (MIT)
|
||||
// ==========================================================================
|
||||
|
@ -38,6 +38,9 @@ const support = {
|
||||
// Picture-in-picture support
|
||||
// Safari & Chrome only currently
|
||||
pip: (() => {
|
||||
// While iPhone's support picture-in-picture for some apps, seemingly Safari isn't one of them
|
||||
// It will throw the following error when trying to enter picture-in-picture
|
||||
// `NotSupportedError: The Picture-in-Picture mode is not supported.`
|
||||
if (browser.isIPhone) {
|
||||
return false;
|
||||
}
|
||||
|
@ -125,6 +125,11 @@ const ui = {
|
||||
if (this.config.duration) {
|
||||
controls.durationUpdate.call(this);
|
||||
}
|
||||
|
||||
// Media metadata
|
||||
if (this.config.mediaMetadata) {
|
||||
controls.setMediaMetadata.call(this);
|
||||
}
|
||||
},
|
||||
|
||||
// Setup aria attribute for play and iframe title
|
||||
|
@ -5,12 +5,10 @@
|
||||
|
||||
const browser = {
|
||||
isIE: Boolean(window.document.documentMode),
|
||||
isEdge: window.navigator.userAgent.includes('Edge'),
|
||||
isWebkit: 'WebkitAppearance' in document.documentElement.style && !/Edge/.test(navigator.userAgent),
|
||||
isIPhone: /(iPhone|iPod)/gi.test(navigator.platform),
|
||||
isIos:
|
||||
(navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1) ||
|
||||
/(iPad|iPhone|iPod)/gi.test(navigator.platform),
|
||||
isEdge: /Edge/g.test(navigator.userAgent),
|
||||
isWebkit: 'WebkitAppearance' in document.documentElement.style && !/Edge/g.test(navigator.userAgent),
|
||||
isIPhone: /iPhone|iPod/gi.test(navigator.userAgent) && navigator.maxTouchPoints > 1,
|
||||
isIos: /iPad|iPhone|iPod/gi.test(navigator.userAgent) && navigator.maxTouchPoints > 1,
|
||||
};
|
||||
|
||||
export default browser;
|
||||
|
@ -9,7 +9,7 @@ const isObject = (input) => getConstructor(input) === Object;
|
||||
const isNumber = (input) => getConstructor(input) === Number && !Number.isNaN(input);
|
||||
const isString = (input) => getConstructor(input) === String;
|
||||
const isBoolean = (input) => getConstructor(input) === Boolean;
|
||||
const isFunction = (input) => getConstructor(input) === Function;
|
||||
const isFunction = (input) => typeof input === 'function';
|
||||
const isArray = (input) => Array.isArray(input);
|
||||
const isWeakMap = (input) => instanceOf(input, WeakMap);
|
||||
const isNodeList = (input) => instanceOf(input, NodeList);
|
||||
|
@ -7,7 +7,7 @@
|
||||
* @param {Number} input
|
||||
* @param {Number} min The lower boundary of the output range
|
||||
* @param {Number} max The upper boundary of the output range
|
||||
* @returns A number in the range [min, max]
|
||||
* @returns A number within the bounds of min and max
|
||||
* @type Number
|
||||
*/
|
||||
export function clamp(input = 0, min = 0, max = 255) {
|
||||
|
@ -11,9 +11,7 @@ export function generateId(prefix) {
|
||||
|
||||
// Format string
|
||||
export function format(input, ...args) {
|
||||
if (is.empty(input)) {
|
||||
return input;
|
||||
}
|
||||
if (is.empty(input)) return input;
|
||||
|
||||
return input.toString().replace(/{(\d+)}/g, (match, i) => args[i].toString());
|
||||
}
|
||||
@ -27,13 +25,13 @@ export function getPercentage(current, max) {
|
||||
return ((current / max) * 100).toFixed(2);
|
||||
}
|
||||
|
||||
// Replace all occurances of a string in a string
|
||||
// Replace all occurrences of a string in a string
|
||||
export const replaceAll = (input = '', find = '', replace = '') =>
|
||||
input.replace(new RegExp(find.toString().replace(/([.*+?^=!:${}()|[\]/\\])/g, '\\$1'), 'g'), replace.toString());
|
||||
|
||||
// Convert to title case
|
||||
export const toTitleCase = (input = '') =>
|
||||
input.toString().replace(/\w\S*/g, (text) => text.charAt(0).toUpperCase() + text.substr(1).toLowerCase());
|
||||
input.toString().replace(/\w\S*/g, (text) => text.charAt(0).toUpperCase() + text.slice(1).toLowerCase());
|
||||
|
||||
// Convert string to pascalCase
|
||||
export function toPascalCase(input = '') {
|
||||
|
@ -5,6 +5,7 @@
|
||||
// Base
|
||||
.plyr {
|
||||
@include plyr-font-smoothing($plyr-font-smoothing);
|
||||
|
||||
align-items: center;
|
||||
direction: ltr;
|
||||
display: flex;
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
// Tab focus
|
||||
&.plyr__tab-focus {
|
||||
@include plyr-tab-focus();
|
||||
@include plyr-tab-focus;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,6 +56,7 @@
|
||||
.plyr [data-plyr='fullscreen'] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.plyr--captions-enabled [data-plyr='captions'],
|
||||
.plyr--pip-supported [data-plyr='pip'],
|
||||
.plyr--airplay-supported [data-plyr='airplay'],
|
||||
|
@ -10,6 +10,7 @@
|
||||
.plyr__control svg {
|
||||
transition: transform 0.3s ease;
|
||||
}
|
||||
|
||||
.plyr__control[aria-expanded='true'] {
|
||||
svg {
|
||||
transform: rotate(90deg);
|
||||
@ -25,7 +26,7 @@
|
||||
&__container {
|
||||
animation: plyr-popup 0.2s ease;
|
||||
background: $plyr-menu-background;
|
||||
border-radius: 4px;
|
||||
border-radius: $plyr-menu-radius;
|
||||
bottom: 100%;
|
||||
box-shadow: $plyr-menu-shadow;
|
||||
color: $plyr-menu-color;
|
||||
@ -73,10 +74,7 @@
|
||||
color: $plyr-menu-color;
|
||||
display: flex;
|
||||
font-size: $plyr-font-size-menu;
|
||||
padding-bottom: 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);
|
||||
padding: calc(#{$plyr-control-padding} / 1.5) calc(#{$plyr-control-padding} * 1.5);
|
||||
user-select: none;
|
||||
width: 100%;
|
||||
|
||||
@ -176,6 +174,7 @@
|
||||
&::before {
|
||||
background: $plyr-control-toggle-checked-background;
|
||||
}
|
||||
|
||||
&::after {
|
||||
opacity: 1;
|
||||
transform: translateY(-50%) scale(1);
|
||||
@ -193,7 +192,7 @@
|
||||
align-items: center;
|
||||
display: flex;
|
||||
margin-left: auto;
|
||||
margin-right: calc((#{$plyr-control-padding} - 2) * -1);
|
||||
margin-right: calc((#{$plyr-control-padding} - 2px) * -1);
|
||||
overflow: hidden;
|
||||
padding-left: calc(#{$plyr-control-padding} * 3.5);
|
||||
pointer-events: none;
|
||||
|
@ -24,8 +24,9 @@ $plyr-progress-offset: $plyr-range-thumb-height;
|
||||
|
||||
// Seek tooltip to show time
|
||||
.plyr__tooltip {
|
||||
font-size: $plyr-font-size-time;
|
||||
left: 0;
|
||||
max-width: 120px;
|
||||
overflow-wrap: break-word;
|
||||
}
|
||||
}
|
||||
|
||||
@ -92,3 +93,15 @@ $plyr-progress-offset: $plyr-range-thumb-height;
|
||||
.plyr--audio.plyr--loading .plyr__progress__buffer {
|
||||
background-color: $plyr-audio-progress-buffered-background;
|
||||
}
|
||||
|
||||
// Markers
|
||||
.plyr__progress__marker {
|
||||
background-color: $plyr-progress-marker-background;
|
||||
border-radius: 1px;
|
||||
height: $plyr-range-track-height;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
width: $plyr-progress-marker-width;
|
||||
z-index: 3;
|
||||
}
|
||||
|
@ -3,10 +3,11 @@
|
||||
// --------------------------------------------------------------
|
||||
|
||||
.plyr--full-ui input[type='range'] {
|
||||
-webkit-appearance: none; /* stylelint-disable-line */
|
||||
appearance: none;
|
||||
background: transparent;
|
||||
border: 0;
|
||||
border-radius: calc(#{$plyr-range-thumb-height} * 2);
|
||||
|
||||
// `color` property is used in JS to populate lower fill for WebKit
|
||||
color: $plyr-range-fill-background;
|
||||
display: block;
|
||||
@ -18,23 +19,25 @@
|
||||
width: 100%;
|
||||
|
||||
&::-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%));
|
||||
}
|
||||
|
||||
&::-webkit-slider-thumb {
|
||||
@include plyr-range-thumb();
|
||||
-webkit-appearance: none; /* stylelint-disable-line */
|
||||
@include plyr-range-thumb;
|
||||
|
||||
appearance: none;
|
||||
margin-top: calc(((#{$plyr-range-thumb-height} - #{$plyr-range-track-height}) / 2) * -1);
|
||||
}
|
||||
|
||||
// Mozilla
|
||||
&::-moz-range-track {
|
||||
@include plyr-range-track();
|
||||
@include plyr-range-track;
|
||||
}
|
||||
|
||||
&::-moz-range-thumb {
|
||||
@include plyr-range-thumb();
|
||||
@include plyr-range-thumb;
|
||||
}
|
||||
|
||||
&::-moz-range-progress {
|
||||
@ -45,22 +48,24 @@
|
||||
|
||||
// Microsoft
|
||||
&::-ms-track {
|
||||
@include plyr-range-track();
|
||||
@include plyr-range-track;
|
||||
|
||||
color: transparent;
|
||||
}
|
||||
|
||||
&::-ms-fill-upper {
|
||||
@include plyr-range-track();
|
||||
@include plyr-range-track;
|
||||
}
|
||||
|
||||
&::-ms-fill-lower {
|
||||
@include plyr-range-track();
|
||||
@include plyr-range-track;
|
||||
|
||||
background: currentColor;
|
||||
}
|
||||
|
||||
&::-ms-thumb {
|
||||
@include plyr-range-thumb();
|
||||
@include plyr-range-thumb;
|
||||
|
||||
// For some reason, Edge uses the -webkit margin above
|
||||
margin-top: 0;
|
||||
}
|
||||
@ -70,25 +75,25 @@
|
||||
}
|
||||
|
||||
// Focus styles
|
||||
&:focus {
|
||||
outline: 0;
|
||||
}
|
||||
|
||||
&::-moz-focus-outer {
|
||||
border: 0;
|
||||
}
|
||||
|
||||
&:focus {
|
||||
outline: 0;
|
||||
}
|
||||
|
||||
&.plyr__tab-focus {
|
||||
&::-webkit-slider-runnable-track {
|
||||
@include plyr-tab-focus();
|
||||
@include plyr-tab-focus;
|
||||
}
|
||||
|
||||
&::-moz-range-track {
|
||||
@include plyr-tab-focus();
|
||||
@include plyr-tab-focus;
|
||||
}
|
||||
|
||||
&::-ms-track {
|
||||
@include plyr-tab-focus();
|
||||
@include plyr-tab-focus;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
/* stylelint-disable selector-max-compound-selectors */
|
||||
// --------------------------------------------------------------
|
||||
// Tooltips
|
||||
// --------------------------------------------------------------
|
||||
|
@ -1,5 +1,8 @@
|
||||
// Downloaded from https://github.com/malyw/css-vars (and modified)
|
||||
|
||||
@use 'sass:list';
|
||||
@use 'sass:map';
|
||||
|
||||
// global map to be filled via variables
|
||||
$css-vars: ();
|
||||
|
||||
@ -21,36 +24,35 @@ $css-vars-use-native: false !default;
|
||||
|
||||
///
|
||||
// Emulates var() CSS native function behavior
|
||||
//
|
||||
// $args[0] {String} "--" + variable name
|
||||
// [$args[1]] Optional default value if variable is not assigned yet
|
||||
//
|
||||
// E.G.:
|
||||
// color: var(--main-color);
|
||||
// background: var(--main-background, green);
|
||||
///
|
||||
@function var($args...) {
|
||||
// CHECK PARAMS
|
||||
@if (length($args) ==0) {
|
||||
@if length($args) == 0 {
|
||||
@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 '--'";
|
||||
}
|
||||
|
||||
// PROCESS
|
||||
$var-name: nth($args, 1);
|
||||
$var-value: map-get($css-vars, $var-name);
|
||||
$var-name: list.nth($args, 1);
|
||||
$var-value: map.get($css-vars, $var-name);
|
||||
|
||||
@if ($css-vars-use-native) {
|
||||
@if $css-vars-use-native {
|
||||
// CSS variables
|
||||
// Native CSS: don't process function in case of native
|
||||
@return unquote('var(' + $args + ')');
|
||||
} @else {
|
||||
@if ($var-value == null) {
|
||||
@if not $var-value {
|
||||
// variable is not provided so far
|
||||
@if (length($args) == 2) {
|
||||
$var-value: nth($args, 2);
|
||||
@if length($args) == 2 {
|
||||
$var-value: list.nth($args, 2);
|
||||
}
|
||||
}
|
||||
|
||||
@ -60,7 +62,7 @@ $css-vars-use-native: false !default;
|
||||
}
|
||||
|
||||
///
|
||||
// SASS mixin to provide variables
|
||||
// Sass mixin to provide variables
|
||||
// E.G.:
|
||||
// @include css-vars((
|
||||
// --color: rebeccapurple,
|
||||
@ -70,20 +72,21 @@ $css-vars-use-native: false !default;
|
||||
///
|
||||
@mixin css-vars($var-map: null) {
|
||||
// CHECK PARAMS
|
||||
@if ($var-map == null) {
|
||||
@if not $var-map {
|
||||
@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)}';
|
||||
}
|
||||
|
||||
// PROCESS
|
||||
@if ($css-vars-use-native) {
|
||||
@if $css-vars-use-native {
|
||||
// CSS variables
|
||||
// Native CSS: assign CSS custom properties to the global scope
|
||||
@at-root :root {
|
||||
@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
|
||||
} @else {
|
||||
#{$var-name}: #{$var-value};
|
||||
|
@ -5,10 +5,8 @@
|
||||
// Nicer focus styles
|
||||
// ---------------------------------------
|
||||
@mixin plyr-tab-focus($color: $plyr-tab-focus-color) {
|
||||
outline-color: $color;
|
||||
outline: $color dotted 3px;
|
||||
outline-offset: 2px;
|
||||
outline-style: dotted;
|
||||
outline-width: 3px;
|
||||
}
|
||||
|
||||
// Font smoothing
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Advertisements
|
||||
// ==========================================================================
|
||||
|
||||
@use 'sass:list';
|
||||
|
||||
.plyr__ads {
|
||||
border-radius: inherit;
|
||||
bottom: 0;
|
||||
@ -49,10 +47,10 @@
|
||||
display: block;
|
||||
height: $plyr-range-track-height;
|
||||
left: 0;
|
||||
margin: -(list.slash($plyr-range-track-height, 2)) 0 0;
|
||||
opacity: 0.8;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
width: 3px;
|
||||
z-index: 3; // Between progress and thumb
|
||||
}
|
||||
|
@ -6,12 +6,12 @@
|
||||
|
||||
.plyr__preview-thumb {
|
||||
background-color: $plyr-preview-background;
|
||||
border-radius: 3px;
|
||||
border-radius: $plyr-preview-radius;
|
||||
bottom: 100%;
|
||||
box-shadow: $plyr-preview-shadow;
|
||||
margin-bottom: calc(#{$plyr-preview-padding} * 2);
|
||||
opacity: 0;
|
||||
padding: $plyr-preview-radius;
|
||||
padding: 3px;
|
||||
pointer-events: none;
|
||||
position: absolute;
|
||||
transform: translate(0, 10px) scale(0.8);
|
||||
@ -32,7 +32,7 @@
|
||||
bottom: calc(#{$plyr-preview-arrow-size} * -1);
|
||||
content: '';
|
||||
height: 0;
|
||||
left: 50%;
|
||||
left: calc(50% + var(--preview-arrow-offset));
|
||||
position: absolute;
|
||||
transform: translateX(-50%);
|
||||
width: 0;
|
||||
@ -46,32 +46,45 @@
|
||||
position: relative;
|
||||
z-index: 0;
|
||||
|
||||
img {
|
||||
height: 100%; // Non sprite images are 100%. Sprites will have their size applied by JavaScript
|
||||
img,
|
||||
&::after {
|
||||
height: 100%;
|
||||
left: 0;
|
||||
max-height: none;
|
||||
max-width: none;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
&::after {
|
||||
border-radius: inherit;
|
||||
box-shadow: inset 0 0 0 1px rgba(#000, 15%);
|
||||
content: '';
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
img {
|
||||
// Non sprite images are 100%. Sprites will have their size applied by JavaScript
|
||||
max-height: none;
|
||||
max-width: none;
|
||||
}
|
||||
}
|
||||
|
||||
// Seek time text
|
||||
&__time-container {
|
||||
bottom: $plyr-preview-time-bottom-offset;
|
||||
background: $plyr-preview-time-container-background;
|
||||
border-bottom-left-radius: calc(#{$plyr-preview-radius} - 1px);
|
||||
border-bottom-right-radius: calc(#{$plyr-preview-radius} - 1px);
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
line-height: 1.1;
|
||||
padding: $plyr-preview-time-container-padding;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
white-space: nowrap;
|
||||
z-index: 3;
|
||||
|
||||
span {
|
||||
background-color: $plyr-preview-time-background;
|
||||
border-radius: calc(#{$plyr-preview-radius} - 1px);
|
||||
color: $plyr-preview-time-color;
|
||||
font-size: $plyr-preview-time-font-size;
|
||||
padding: $plyr-preview-time-padding;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,8 +8,10 @@ $plyr-preview-radius: $plyr-tooltip-radius !default;
|
||||
$plyr-preview-shadow: $plyr-tooltip-shadow !default;
|
||||
$plyr-preview-arrow-size: $plyr-tooltip-arrow-size !default;
|
||||
$plyr-preview-image-background: $plyr-color-gray-200 !default;
|
||||
$plyr-preview-time-font-size: $plyr-font-size-time !default;
|
||||
$plyr-preview-time-padding: 3px 6px !default;
|
||||
$plyr-preview-time-background: rgba(0, 0, 0, 0.55);
|
||||
$plyr-preview-time-container-background: var(
|
||||
--plyr-video-controls-background,
|
||||
linear-gradient(rgba(#000, 0), rgba(#000, 0.75))
|
||||
) !default;
|
||||
$plyr-preview-time-container-padding: 20px 6px 6px !default;
|
||||
$plyr-preview-time-color: #fff;
|
||||
$plyr-preview-time-bottom-offset: 6px;
|
||||
$plyr-preview-time-font-size: $plyr-font-size-time !default;
|
||||
|
@ -1,18 +1,19 @@
|
||||
@charset "UTF-8";
|
||||
|
||||
// ==========================================================================
|
||||
// Plyr styles
|
||||
// https://github.com/sampotts/plyr
|
||||
// TODO: Review use of BEM classnames
|
||||
// ==========================================================================
|
||||
@charset 'UTF-8';
|
||||
|
||||
@import 'lib/css-vars';
|
||||
|
||||
$css-vars-use-native: true;
|
||||
|
||||
@import 'settings/breakpoints';
|
||||
@import 'settings/colors';
|
||||
@import 'settings/cosmetics';
|
||||
@import 'settings/type';
|
||||
|
||||
@import 'settings/badges';
|
||||
@import 'settings/captions';
|
||||
@import 'settings/controls';
|
||||
@ -21,13 +22,10 @@ $css-vars-use-native: true;
|
||||
@import 'settings/progress';
|
||||
@import 'settings/sliders';
|
||||
@import 'settings/tooltips';
|
||||
|
||||
@import 'lib/animation';
|
||||
@import 'lib/functions';
|
||||
@import 'lib/mixins';
|
||||
|
||||
@import 'base';
|
||||
|
||||
@import 'components/badges';
|
||||
@import 'components/captions';
|
||||
@import 'components/control';
|
||||
@ -39,14 +37,10 @@ $css-vars-use-native: true;
|
||||
@import 'components/tooltips';
|
||||
@import 'components/progress';
|
||||
@import 'components/volume';
|
||||
|
||||
@import 'types/audio';
|
||||
@import 'types/video';
|
||||
|
||||
@import 'states/fullscreen';
|
||||
|
||||
@import 'plugins/ads';
|
||||
@import 'plugins/preview-thumbnails/index';
|
||||
|
||||
@import 'utils/animation';
|
||||
@import 'utils/hidden';
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
$plyr-captions-background: var(--plyr-captions-background, rgba(#000, 0.8)) !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-small: $plyr-font-size-small !default;
|
||||
$plyr-font-size-captions-medium: $plyr-font-size-large !default;
|
||||
|
@ -2,17 +2,17 @@
|
||||
// Colors
|
||||
// ==========================================================================
|
||||
|
||||
$plyr-color-main: var(--plyr-color-main, hsl(198, 100%, 50%)) !default;
|
||||
$plyr-video-background: var(--plyr-video-background, rgba(0,0,0,1)) !default;
|
||||
$plyr-color-main: var(--plyr-color-main, hsl(198deg 100% 50%)) !default;
|
||||
$plyr-video-background: var(--plyr-video-background, rgb(0 0 0 / 100%)) !default;
|
||||
|
||||
// Grayscale
|
||||
$plyr-color-gray-900: hsl(216, 15%, 16%) !default;
|
||||
$plyr-color-gray-800: hsl(216, 15%, 25%) !default;
|
||||
$plyr-color-gray-700: hsl(216, 15%, 34%) !default;
|
||||
$plyr-color-gray-600: hsl(216, 15%, 43%) !default;
|
||||
$plyr-color-gray-500: hsl(216, 15%, 52%) !default;
|
||||
$plyr-color-gray-400: hsl(216, 15%, 61%) !default;
|
||||
$plyr-color-gray-300: hsl(216, 15%, 70%) !default;
|
||||
$plyr-color-gray-200: hsl(216, 15%, 79%) !default;
|
||||
$plyr-color-gray-100: hsl(216, 15%, 88%) !default;
|
||||
$plyr-color-gray-50: hsl(216, 15%, 97%) !default;
|
||||
$plyr-color-gray-900: hsl(216deg 15% 16%) !default;
|
||||
$plyr-color-gray-800: hsl(216deg 15% 25%) !default;
|
||||
$plyr-color-gray-700: hsl(216deg 15% 34%) !default;
|
||||
$plyr-color-gray-600: hsl(216deg 15% 43%) !default;
|
||||
$plyr-color-gray-500: hsl(216deg 15% 52%) !default;
|
||||
$plyr-color-gray-400: hsl(216deg 15% 61%) !default;
|
||||
$plyr-color-gray-300: hsl(216deg 15% 70%) !default;
|
||||
$plyr-color-gray-200: hsl(216deg 15% 79%) !default;
|
||||
$plyr-color-gray-100: hsl(216deg 15% 88%) !default;
|
||||
$plyr-color-gray-50: hsl(216deg 15% 97%) !default;
|
||||
|
@ -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: var(--plyr-control-padding, $plyr-control-padding) !default;
|
||||
$plyr-control-radius: var(--plyr-control-radius, 3px) !default;
|
||||
|
||||
$plyr-control-toggle-checked-background: var(
|
||||
--plyr-control-toggle-checked-background,
|
||||
var(--plyr-color-main, $plyr-color-main)
|
||||
) !default;
|
||||
|
||||
$plyr-video-controls-background: var(
|
||||
--plyr-video-controls-background,
|
||||
linear-gradient(rgba(#000, 0), rgba(#000, 0.75))
|
||||
@ -23,7 +21,6 @@ $plyr-video-control-background-hover: var(
|
||||
--plyr-video-control-background-hover,
|
||||
var(--plyr-color-main, $plyr-color-main)
|
||||
) !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-hover: var(--plyr-audio-control-color-hover, #fff) !default;
|
||||
|
@ -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-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-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-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;
|
||||
|
@ -6,6 +6,10 @@
|
||||
$plyr-progress-loading-size: var(--plyr-progress-loading-size, 25px) !default;
|
||||
$plyr-progress-loading-background: var(--plyr-progress-loading-background, rgba($plyr-color-gray-900, 0.6)) !default;
|
||||
|
||||
// Markers
|
||||
$plyr-progress-marker-background: var(--plyr-progress-marker-background, #fff) !default;
|
||||
$plyr-progress-marker-width: var(--plyr-progress-marker-width, 3px) !default;
|
||||
|
||||
// Buffered
|
||||
$plyr-video-progress-buffered-background: var(--plyr-video-progress-buffered-background, rgba(#fff, 0.25)) !default;
|
||||
$plyr-audio-progress-buffered-background: var(
|
||||
|
@ -29,7 +29,6 @@ $plyr-video-range-thumb-active-shadow-color: var(
|
||||
--plyr-audio-range-thumb-active-shadow-color,
|
||||
rgba(#fff, 0.5)
|
||||
) !default;
|
||||
|
||||
$plyr-audio-range-track-background: var(
|
||||
--plyr-audio-range-track-background,
|
||||
$plyr-audio-progress-buffered-background
|
||||
|
@ -7,5 +7,5 @@ $plyr-tooltip-color: var(--plyr-tooltip-color, $plyr-color-gray-700) !default;
|
||||
$plyr-tooltip-padding: calc(#{$plyr-control-spacing} / 2);
|
||||
$plyr-tooltip-padding: var(--plyr-tooltip-padding, $plyr-tooltip-padding) !default;
|
||||
$plyr-tooltip-arrow-size: var(--plyr-tooltip-arrow-size, 4px) !default;
|
||||
$plyr-tooltip-radius: var(--plyr-tooltip-radius, 3px) !default;
|
||||
$plyr-tooltip-radius: var(--plyr-tooltip-radius, 5px) !default;
|
||||
$plyr-tooltip-shadow: var(--plyr-tooltip-shadow, 0 1px 2px rgba(0, 0, 0, 0.15)) !default;
|
||||
|
@ -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-large: var(--plyr-font-size-large, 18px) !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-menu: var(--plyr-font-size-menu, $plyr-font-size-small) !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-bold: var(--plyr-font-weight-bold, 600) !default;
|
||||
|
||||
$plyr-line-height: var(--plyr-line-height, 1.7) !default;
|
||||
|
||||
$plyr-font-smoothing: var(--plyr-font-smoothing, false) !default;
|
||||
|
@ -3,27 +3,13 @@
|
||||
// --------------------------------------------------------------
|
||||
|
||||
.plyr:fullscreen {
|
||||
@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();
|
||||
@include plyr-fullscreen-active;
|
||||
}
|
||||
|
||||
// Fallback for unsupported browsers
|
||||
.plyr--fullscreen-fallback {
|
||||
@include plyr-fullscreen-active();
|
||||
@include plyr-fullscreen-active;
|
||||
|
||||
bottom: 0;
|
||||
display: block;
|
||||
left: 0;
|
||||
|
@ -51,6 +51,7 @@ $embed-padding: (math.div(100, 16) * 9);
|
||||
.plyr--full-ui .plyr__video-embed > .plyr__video-embed__container {
|
||||
$height: 240;
|
||||
$offset: to-percentage(math.div($height - $embed-padding, math.div($height, 50)));
|
||||
|
||||
padding-bottom: to-percentage($height);
|
||||
position: relative;
|
||||
transform: translateY(-$offset);
|
||||
|
@ -118,7 +118,7 @@ Object.entries(build.js).forEach(([filename, entry]) => {
|
||||
},
|
||||
],
|
||||
],
|
||||
plugins: ['@babel/plugin-proposal-class-properties'],
|
||||
plugins: ['@babel/plugin-proposal-class-properties', '@babel/plugin-proposal-optional-chaining'],
|
||||
babelrc: false,
|
||||
exclude: [/\/core-js\//],
|
||||
}),
|
||||
|
Reference in New Issue
Block a user