Compare commits
136 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
0c9759455c | ||
|
ae59c117b5 | ||
|
8da1a78342 | ||
|
747c5f5f31 | ||
|
39c6049850 | ||
|
0202e8efb0 | ||
|
e17d0220c0 | ||
|
aa4eaec742 | ||
|
851c39d44e | ||
|
f012a7df36 | ||
|
b8c40ead0a | ||
|
874bb8d3e8 | ||
|
2b3e483b36 | ||
|
69ef4ec827 | ||
|
d6cc19f2d8 | ||
|
d67eea5942 | ||
|
c4a566dbff | ||
|
185bb4c7cc | ||
|
d9161212ff | ||
|
ed0b901d11 | ||
|
62436d8e8e | ||
|
5731245f4f | ||
|
41e2454bd2 | ||
|
9248e322fc | ||
|
fa634a1bbb | ||
|
f7d2938f42 | ||
|
7c88b58a1a | ||
|
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 | ||
|
0acf228dcd | ||
|
91b19baf44 | ||
|
990d636019 | ||
|
b9c792b377 | ||
|
1b835cb657 | ||
|
d9f9dc770b | ||
|
dca2ff8cfd | ||
|
cf8e9341f2 | ||
|
5d1d247491 | ||
|
fbf4d27cd4 | ||
|
e0b70d53cd | ||
|
9f7725cec1 | ||
|
720cddff21 | ||
|
1c33098c42 | ||
|
b256c102e8 | ||
|
a3716fc491 | ||
|
14e276a11d | ||
|
fc85a63af4 | ||
|
f016a367b5 | ||
|
d41a90f0dd | ||
|
b4f24f90da | ||
|
9d751f4265 | ||
|
ff2c224254 | ||
|
1135b1acac | ||
|
30ffb30a97 | ||
|
e4a18a5c99 | ||
|
d1a10386c0 | ||
|
4d6ac4ade1 | ||
|
c2bfe489ea | ||
|
882952bba6 | ||
|
784f36921b | ||
|
b7dbdc133e | ||
|
02d06c464c | ||
|
cec2474295 | ||
|
6caa2f3fed | ||
|
3a01837561 | ||
|
ba4bdb335a |
1
.node-version
Normal file
1
.node-version
Normal file
@ -0,0 +1 @@
|
|||||||
|
19.7.0
|
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"plugins": ["stylelint-selector-bem-pattern", "stylelint-scss"],
|
"plugins": ["stylelint-selector-bem-pattern"],
|
||||||
"extends": ["stylelint-config-recommended", "stylelint-config-sass-guidelines", "stylelint-config-prettier"],
|
"extends": ["stylelint-config-sass-guidelines", "stylelint-config-prettier"],
|
||||||
|
"customSyntax": "postcss-scss",
|
||||||
"rules": {
|
"rules": {
|
||||||
"selector-class-pattern": null,
|
"selector-class-pattern": null,
|
||||||
"selector-no-qualifying-type": [
|
"selector-no-qualifying-type": [
|
||||||
@ -9,10 +10,7 @@
|
|||||||
"ignore": ["attribute", "class"]
|
"ignore": ["attribute", "class"]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"string-no-newline": null,
|
"max-nesting-depth": 4,
|
||||||
"indentation": 2,
|
|
||||||
"string-quotes": "single",
|
|
||||||
"max-nesting-depth": 2,
|
|
||||||
"plugin/selector-bem-pattern": {
|
"plugin/selector-bem-pattern": {
|
||||||
"preset": "bem",
|
"preset": "bem",
|
||||||
"componentName": "(([a-z0-9]+(?!-$)-?)+)",
|
"componentName": "(([a-z0-9]+(?!-$)-?)+)",
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
language: node_js
|
|
||||||
node_js: lts/*
|
|
||||||
|
|
||||||
script:
|
|
||||||
- npm run lint
|
|
||||||
- npm run build
|
|
132
CHANGELOG.md
132
CHANGELOG.md
@ -1,3 +1,99 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
### v3.7.8
|
||||||
|
|
||||||
|
- Feat: Minor demo style tweaks
|
||||||
|
- Fix: Minor style fixes related to backgrounds and border radii (🚨 Requires a SCSS/CSS update 🚨)
|
||||||
|
|
||||||
|
### v3.7.7
|
||||||
|
|
||||||
|
- Fix (Accessibility): Don’t set tabindex on parent container
|
||||||
|
- Fix (Accessibility): Add `role="timer"` to time elements
|
||||||
|
- Fix (Accessibility): Leverage native `:focus-visible` in CSS, instead of a custom solution (🚨 Requires a SCSS/CSS update 🚨)
|
||||||
|
|
||||||
|
### v3.7.6
|
||||||
|
|
||||||
|
- Fix: Revert postinstall script
|
||||||
|
|
||||||
|
### v3.7.5
|
||||||
|
|
||||||
|
- Fix: Replace `pnpm` with `npm` in scripts to fix build issues
|
||||||
|
|
||||||
|
### v3.7.4
|
||||||
|
|
||||||
|
- Fix: Fixed event key with space (thanks @royeden!)
|
||||||
|
- Fix: Changing Vimeo function call from `setVolume` to `setMuted` to fix iOS issue (issue #2624) (thanks @HandreMelo and Andre Fernandes Cristofolini Melo!)
|
||||||
|
- Fix: Call preview-thumbnails listeners() function on load (thanks @mogzol!)
|
||||||
|
- Fix: Fullscreen improvements for iOS & iPadOS
|
||||||
|
- Feat: Remove need for iOS-specific styling (please update [volume.scss](https://github.com/sampotts/plyr/blob/master/src/sass/components/volume.scss))
|
||||||
|
|
||||||
|
### 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
|
||||||
|
- Chore: Clean up demo
|
||||||
|
|
||||||
|
### v3.6.9
|
||||||
|
|
||||||
|
- Fix: Sass issue with division (thanks @ROL4ND909 and @le0pard)
|
||||||
|
- Fix: Captions when switching sources (thanks @zexingguo)
|
||||||
|
- Fix: Icons loading within iframes (thanks @ajgagnon)
|
||||||
|
- Chore: Update TypeScript types (thanks @Jackie1210 and @AntLevin)
|
||||||
|
- Fix: iOS fullscreen centering (thanks @hemratna)
|
||||||
|
- Feat: Added getter and setter for preview thumbnails (thanks @Benny739)
|
||||||
|
- Fix: Change fullscreen element to player rootnode (thanks @Walter van den Houten)
|
||||||
|
- Fix: Fixed errors when Plyr instance is destroyed before constructor setTimeout() functions execute (thanks @emilis-ideait)
|
||||||
|
- Fix: Invalid CSS selector syntax (thanks @BjornBrandewallNaviga)
|
||||||
|
- Fix: Video height issues
|
||||||
|
- Feat: Improve support for Vimeo private videos (thanks @Frosch)
|
||||||
|
- Fix: YouTube duration issues (thanks @liesahead)
|
||||||
|
|
||||||
### v3.6.8
|
### v3.6.8
|
||||||
|
|
||||||
- Typings: add FullscreenOptions.container to typing files (thanks @MeguminSama!)
|
- Typings: add FullscreenOptions.container to typing files (thanks @MeguminSama!)
|
||||||
@ -46,7 +142,7 @@
|
|||||||
- Fix "A `ReferenceError: _classCallCheck is not defined` error has occurred." error (thanks @hex-ci)
|
- Fix "A `ReferenceError: _classCallCheck is not defined` error has occurred." error (thanks @hex-ci)
|
||||||
- Fix issue with CSS custom property check (thanks @syedhusain-appspace)
|
- Fix issue with CSS custom property check (thanks @syedhusain-appspace)
|
||||||
- Fix for slow loading videos not autoplaying (thanks @DanielHuntleySBG)
|
- Fix for slow loading videos not autoplaying (thanks @DanielHuntleySBG)
|
||||||
- Fix for betwork requests are not cancelled after the player is destroyed (thanks @DanielHuntleySBG)
|
- Fix for network requests are not cancelled after the player is destroyed (thanks @DanielHuntleySBG)
|
||||||
- Added option to disable custom controls for YouTube and Vimeo
|
- Added option to disable custom controls for YouTube and Vimeo
|
||||||
|
|
||||||
### v3.6.2
|
### v3.6.2
|
||||||
@ -91,7 +187,7 @@
|
|||||||
### v3.5.8
|
### v3.5.8
|
||||||
|
|
||||||
- Added `flex-direction` property to fix some issues introduced in v3.5.7 when using custom CSS
|
- Added `flex-direction` property to fix some issues introduced in v3.5.7 when using custom CSS
|
||||||
- Cleaned up the organisation of some of the SCSS files (should not effect CSS output)
|
- Cleaned up the organization of some of the SCSS files (should not effect CSS output)
|
||||||
- Added `referrerPolicy` option for Vimeo to prevent an issue present in the demo site
|
- Added `referrerPolicy` option for Vimeo to prevent an issue present in the demo site
|
||||||
- Remove all Vimeo controls for Pro & Premium accounts
|
- Remove all Vimeo controls for Pro & Premium accounts
|
||||||
- Improve thumbnail size calculations when size is set per css (thanks @ydylla)
|
- Improve thumbnail size calculations when size is set per css (thanks @ydylla)
|
||||||
@ -106,7 +202,7 @@
|
|||||||
- Accessibility tweak for the play button (thanks @lunika)
|
- Accessibility tweak for the play button (thanks @lunika)
|
||||||
- Fix for ads configuration (thanks @SoftCreatR)
|
- Fix for ads configuration (thanks @SoftCreatR)
|
||||||
- Fix handling listener return value (thanks @taion)
|
- Fix handling listener return value (thanks @taion)
|
||||||
- Added localisation key for PIP (picture-in-picture) (thanks @lmislm)
|
- Added localization key for PIP (picture-in-picture) (thanks @lmislm)
|
||||||
- Preserve viewBox attribute in SVG sprite symbols (thanks @bseib)
|
- Preserve viewBox attribute in SVG sprite symbols (thanks @bseib)
|
||||||
- Fix being unable to unmute autoplayed video on iOS (thanks @sumanbh)
|
- Fix being unable to unmute autoplayed video on iOS (thanks @sumanbh)
|
||||||
- Fixed Plyr container not resizing responsively (thanks @shravan2x)
|
- Fixed Plyr container not resizing responsively (thanks @shravan2x)
|
||||||
@ -140,7 +236,7 @@ _Note:_ This update contains CSS changes.
|
|||||||
### v3.5.4
|
### v3.5.4
|
||||||
|
|
||||||
- Added: Set download URL via new setter
|
- 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 empty controls and preview thumbs
|
||||||
- Fixed issue with setGutter call (from Sentry)
|
- Fixed issue with setGutter call (from Sentry)
|
||||||
- Fixed issue with initial selected speed not working
|
- Fixed issue with initial selected speed not working
|
||||||
@ -503,7 +599,7 @@ This is a massive release. A _mostly_ complete rewrite in ES6. What started out
|
|||||||
|
|
||||||
### Other stuff
|
### 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)
|
- 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 basic looping support
|
||||||
- Added an aspect ratio option for those that can't leave the 90s and want 4:3
|
- Added an aspect ratio option for those that can't leave the 90s and want 4:3
|
||||||
@ -563,10 +659,10 @@ Because we're using the fancy new ES6 syntax, you will need to polyfill for vint
|
|||||||
|
|
||||||
- Vimeo controls fix (fixes #697)
|
- Vimeo controls fix (fixes #697)
|
||||||
- SVG4everybody compatibility fix
|
- SVG4everybody compatibility fix
|
||||||
- Allow Plyr.setup event listeners to be set up as separate event listeners (https://github.com/sampotts/plyr/pull/703)
|
- Allow Plyr.setup event listeners to be set up as separate event listeners (<https://github.com/sampotts/plyr/pull/703>)
|
||||||
- Added title to the layer html template (for custom controls) (https://github.com/sampotts/plyr/pull/649)
|
- Added title to the layer html template (for custom controls) (<https://github.com/sampotts/plyr/pull/649>)
|
||||||
- Target is null bug fix (https://github.com/sampotts/plyr/pull/617)
|
- Target is null bug fix (<https://github.com/sampotts/plyr/pull/617>)
|
||||||
- fix #684 memory leaks issues after destroy (https://github.com/sampotts/plyr/pull/700)
|
- fix #684 memory leaks issues after destroy (<https://github.com/sampotts/plyr/pull/700>)
|
||||||
|
|
||||||
### v2.0.16
|
### v2.0.16
|
||||||
|
|
||||||
@ -586,8 +682,8 @@ Because we're using the fancy new ES6 syntax, you will need to polyfill for vint
|
|||||||
|
|
||||||
### v2.0.12
|
### v2.0.12
|
||||||
|
|
||||||
- Ability to set custom `blankUrl` for source changes (https://github.com/sampotts/plyr/pull/504)
|
- Ability to set custom `blankUrl` for source changes (<https://github.com/sampotts/plyr/pull/504>)
|
||||||
- Ability to set caption button listener (https://github.com/sampotts/plyr/pull/468)
|
- Ability to set caption button listener (<https://github.com/sampotts/plyr/pull/468>)
|
||||||
|
|
||||||
### v2.0.11
|
### v2.0.11
|
||||||
|
|
||||||
@ -736,7 +832,7 @@ And some other changes and bug fixes:
|
|||||||
|
|
||||||
## v1.7.0
|
## v1.7.0
|
||||||
|
|
||||||
- SASS cleanup (fixes #265)
|
- Sass cleanup (fixes #265)
|
||||||
- Docs tidy up to help quick start (fixes #253)
|
- Docs tidy up to help quick start (fixes #253)
|
||||||
- Fix for issues with data attribute options passing (fixes #257)
|
- 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)
|
- **_(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)
|
||||||
@ -858,7 +954,7 @@ And some other changes and bug fixes:
|
|||||||
### v1.5.18
|
### v1.5.18
|
||||||
|
|
||||||
- Added 'ready' event for initial setup complete or source change occurs
|
- 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
|
- Added default font stack to controls
|
||||||
- Docs fixes inc controls HTML (fixes #180)
|
- Docs fixes inc controls HTML (fixes #180)
|
||||||
|
|
||||||
@ -895,7 +991,7 @@ And some other changes and bug fixes:
|
|||||||
|
|
||||||
- iOS embed bug fixes (fixes #166)
|
- iOS embed bug fixes (fixes #166)
|
||||||
- Hide IE/Edge <input type='range'> tooltip (since we have a styled one) (fixes #160)
|
- 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
|
### v1.5.9
|
||||||
|
|
||||||
@ -917,7 +1013,7 @@ And some other changes and bug fixes:
|
|||||||
### v1.5.6
|
### v1.5.6
|
||||||
|
|
||||||
- Seek tooltip (option for tooltips changed, please check docs)
|
- 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)
|
- 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)
|
- Screen reader icon fixes (title was being read twice due to the tooltip/hidden label)
|
||||||
|
|
||||||
@ -994,7 +1090,7 @@ And some other changes and bug fixes:
|
|||||||
|
|
||||||
### v1.2.6
|
### v1.2.6
|
||||||
|
|
||||||
- SASS updates and fixes (cheers @ChristianPV)
|
- Sass updates and fixes (cheers @ChristianPV)
|
||||||
|
|
||||||
### v1.2.5
|
### v1.2.5
|
||||||
|
|
||||||
@ -1109,7 +1205,7 @@ And some other changes and bug fixes:
|
|||||||
|
|
||||||
### v1.0.26
|
### v1.0.26
|
||||||
|
|
||||||
- Fixes for SASS (cheers @brunowego)
|
- Fixes for Sass (cheers @brunowego)
|
||||||
- Indentation reset to 4 spaces
|
- Indentation reset to 4 spaces
|
||||||
|
|
||||||
### v1.0.25
|
### v1.0.25
|
||||||
@ -1154,7 +1250,7 @@ And some other changes and bug fixes:
|
|||||||
|
|
||||||
### v1.0.17
|
### v1.0.17
|
||||||
|
|
||||||
- SASS support added (thanks to @brunowego)
|
- Sass support added (thanks to @brunowego)
|
||||||
- Docs completely separated to avoid any confusion
|
- Docs completely separated to avoid any confusion
|
||||||
- New gulp tasks (will add more documentation for this)
|
- New gulp tasks (will add more documentation for this)
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ controls: [
|
|||||||
|
|
||||||
### Internationalization using default controls
|
### Internationalization using default controls
|
||||||
|
|
||||||
You can provide an `i18n` object as one of your options when initialising the plugin which we be used when rendering the controls.
|
You can provide an `i18n` object as one of your options when initializing the plugin which we be used when rendering the controls.
|
||||||
|
|
||||||
#### Example
|
#### Example
|
||||||
|
|
||||||
|
172
README.md
172
README.md
@ -1,10 +1,13 @@
|
|||||||
|
| 🎉 | [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.
|
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)
|
[Checkout the demo](https://plyr.io) - [Donate](#donate) - [Slack](https://bit.ly/plyr--chat)
|
||||||
|
|
||||||
[](https://badge.fury.io/js/plyr) [](https://gitpod.io/#https://github.com/sampotts/plyr) [](https://opencollective.com/plyr)
|
[](https://badge.fury.io/js/plyr) [](https://gitpod.io/#https://github.com/sampotts/plyr) [](https://opencollective.com/plyr)
|
||||||
|
|
||||||
[](https://plyr.io)
|
[](https://plyr.io)
|
||||||
|
|
||||||
# Features
|
# Features
|
||||||
|
|
||||||
@ -27,9 +30,9 @@ Plyr is a simple, lightweight, accessible and customizable HTML5, YouTube and Vi
|
|||||||
- 🌎 **i18n support** - support for internationalization of controls
|
- 🌎 **i18n support** - support for internationalization of controls
|
||||||
- 👌 **[Preview thumbnails](#preview-thumbnails)** - support for displaying preview thumbnails
|
- 👌 **[Preview thumbnails](#preview-thumbnails)** - support for displaying preview thumbnails
|
||||||
- 🤟 **No frameworks** - written in "vanilla" ES6 JavaScript, no jQuery required
|
- 🤟 **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
|
## Demos
|
||||||
|
|
||||||
You can try Plyr in Codepen using our minimal templates: [HTML5 video](https://codepen.io/pen?template=bKeqpr), [HTML5 audio](https://codepen.io/pen?template=rKLywR), [YouTube](https://codepen.io/pen?template=GGqbbJ), [Vimeo](https://codepen.io/pen?template=bKeXNq). For Streaming we also have example integrations with: [Dash.js](https://codepen.io/pen?template=GRoogML), [Hls.js](https://codepen.io/pen?template=oyLKQb) and [Shaka Player](https://codepen.io/pen?template=ZRpzZO)
|
You can try Plyr in Codepen using our minimal templates: [HTML5 video](https://codepen.io/pen?template=bKeqpr), [HTML5 audio](https://codepen.io/pen?template=rKLywR), [YouTube](https://codepen.io/pen?template=GGqbbJ), [Vimeo](https://codepen.io/pen?template=bKeXNq). For Streaming we also have example integrations with: [Dash.js](https://codepen.io/pen?template=GRoogML), [Hls.js](https://codepen.io/pen?template=oyLKQb) and [Shaka Player](https://codepen.io/pen?template=ZRpzZO)
|
||||||
|
|
||||||
@ -114,7 +117,7 @@ Or the `<div>` non progressively enhanced method:
|
|||||||
|
|
||||||
You can use Plyr as an ES6 module as follows:
|
You can use Plyr as an ES6 module as follows:
|
||||||
|
|
||||||
```javascript
|
```js
|
||||||
import Plyr from 'plyr';
|
import Plyr from 'plyr';
|
||||||
|
|
||||||
const player = new Plyr('#player');
|
const player = new Plyr('#player');
|
||||||
@ -129,38 +132,46 @@ Alternatively you can include the `plyr.js` script before the closing `</body>`
|
|||||||
</script>
|
</script>
|
||||||
```
|
```
|
||||||
|
|
||||||
See [initialising](#initialising) for more information on advanced setups.
|
See [initialising](#initializing) 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 [Cloudflare](https://www.cloudflare.com/)) for the JavaScript. There's 2 versions; one with and one without [polyfills](#polyfills). My recommendation would be to manage polyfills separately as part of your application but to make life easier you can use the polyfilled build.
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<script src="https://cdn.plyr.io/3.6.8/plyr.js"></script>
|
<script src="https://cdn.plyr.io/3.7.8/plyr.js"></script>
|
||||||
```
|
```
|
||||||
|
|
||||||
...or...
|
...or...
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<script src="https://cdn.plyr.io/3.6.8/plyr.polyfilled.js"></script>
|
<script src="https://cdn.plyr.io/3.7.8/plyr.polyfilled.js"></script>
|
||||||
```
|
```
|
||||||
|
|
||||||
## CSS
|
## CSS
|
||||||
|
|
||||||
Include the `plyr.css` stylsheet into your `<head>`.
|
Include the `plyr.css` stylesheet into your `<head>`.
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<link rel="stylesheet" href="path/to/plyr.css" />
|
<link rel="stylesheet" href="path/to/plyr.css" />
|
||||||
```
|
```
|
||||||
|
|
||||||
If you want to use our CDN (provided by [Fastly](https://www.fastly.com/)) for the default CSS, you can use the following:
|
If you want to use our CDN (provided by [Cloudflare](https://www.cloudflare.com/)) for the default CSS, you can use the following:
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<link rel="stylesheet" href="https://cdn.plyr.io/3.6.8/plyr.css" />
|
<link rel="stylesheet" href="https://cdn.plyr.io/3.7.8/plyr.css" />
|
||||||
```
|
```
|
||||||
|
|
||||||
## SVG Sprite
|
## SVG Sprite
|
||||||
|
|
||||||
The SVG sprite is loaded automatically from our CDN (provided by [Fastly](https://www.fastly.com/)). To change this, see the [options](#options) below. For
|
The SVG sprite is loaded automatically from our CDN (provided by [Cloudflare](https://www.cloudflare.com/)). To change this, see the [options](#options) below. For
|
||||||
reference, the CDN hosted SVG sprite can be found at `https://cdn.plyr.io/3.6.8/plyr.svg`.
|
reference, the CDN hosted SVG sprite can be found at `https://cdn.plyr.io/3.7.8/plyr.svg`.
|
||||||
|
|
||||||
|
### Self hosting
|
||||||
|
|
||||||
|
If you don't want to create a build system to include Plyr as an npm module, you can use the pre-built files. You have a few options:
|
||||||
|
|
||||||
|
- Download the files from the CDN links above, they're already minified.
|
||||||
|
- Download the files from [unpkg](https://unpkg.com/browse/plyr/dist/) or similar services.
|
||||||
|
- Build the project yourself using `npm i && npm run build`, which installs the dependencies and spits out a build to `dist`.
|
||||||
|
|
||||||
# Ads
|
# Ads
|
||||||
|
|
||||||
@ -184,43 +195,42 @@ Here's a list of the properties and what they are used for:
|
|||||||
|
|
||||||
| Name | Description | Default / Fallback |
|
| Name | Description | Default / Fallback |
|
||||||
| ---------------------------------------------- | ------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
|
| ---------------------------------------------- | ------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
|
||||||
| `--plyr-color-main` | The primary UI color. |  `#00b3ff` |
|
| `--plyr-color-main` | The primary UI color. |  `#00b3ff` |
|
||||||
| `--plyr-video-background` | The background color of video and poster wrappers for using alpha channel videos and poster images. | `rgba(0, 0, 0, 1)` |
|
| `--plyr-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-focus-visible-color` | The color used for the focus styles when an element is `:focus-visible` (keyboard focused). | `--plyr-color-main` |
|
||||||
| `--plyr-badge-background` | The background color for badges in the menu. |  `#4a5464` |
|
| `--plyr-badge-background` | The background color for badges in the menu. |  `#4a5464` |
|
||||||
| `--plyr-badge-text-color` | The text color for badges. |  `#ffffff` |
|
| `--plyr-badge-text-color` | The text color for badges. |  `#ffffff` |
|
||||||
| `--plyr-badge-border-radius` | The border radius used for badges. | `2px` |
|
| `--plyr-badge-border-radius` | The border radius used for badges. | `2px` |
|
||||||
| `--plyr-tab-focus-color` | The color used to highlight tab (keyboard) focus. | `--plyr-color-main` |
|
|
||||||
| `--plyr-captions-background` | The color for the background of captions. | `rgba(0, 0, 0, 0.8)` |
|
| `--plyr-captions-background` | The color for the background of captions. | `rgba(0, 0, 0, 0.8)` |
|
||||||
| `--plyr-captions-text-color` | The color used for the captions text. |  `#ffffff` |
|
| `--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-icon-size` | The size of the icons used in the controls. | `18px` |
|
||||||
| `--plyr-control-spacing` | The space between controls (sometimes used in a multiple - e.g. `10px / 2 = 5px`). | `10px` |
|
| `--plyr-control-spacing` | The space between controls (sometimes used in a multiple - e.g. `10px / 2 = 5px`). | `10px` |
|
||||||
| `--plyr-control-padding` | The padding inside controls. | `--plyr-control-spacing * 0.7` (`7px`) |
|
| `--plyr-control-padding` | The padding inside controls. | `--plyr-control-spacing * 0.7` (`7px`) |
|
||||||
| `--plyr-control-radius` | The border radius used on controls. | `3px` |
|
| `--plyr-control-radius` | The border radius used on controls. | `3px` |
|
||||||
| `--plyr-control-toggle-checked-background` | The background color used for checked menu items. | `--plyr-color-main` |
|
| `--plyr-control-toggle-checked-background` | The background color used for checked menu items. | `--plyr-color-main` |
|
||||||
| `--plyr-video-controls-background` | The background for the video controls. | `linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.75))` |
|
| `--plyr-video-controls-background` | The background for the video controls. | `linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.75))` |
|
||||||
| `--plyr-video-control-color` | The text/icon color for video controls. |  `#ffffff` |
|
| `--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-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-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-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` | 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-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-audio-control-background-hover` | The background color used when video controls are `:hover`, `:focus` and `:focus-visible` (equivalent). | `--plyr-color-main` |
|
||||||
| `--plyr-menu-background` | The background color for menus. | `rgba(255, 255, 255, 0.9)` |
|
| `--plyr-menu-background` | The background color for menus. | `rgba(255, 255, 255, 0.9)` |
|
||||||
| `--plyr-menu-color` | The text/icon color for menu items. |  `#4a5464` |
|
| `--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-shadow` | The shadow used on menus. | `0 1px 2px rgba(0, 0, 0, 0.15)` |
|
||||||
| `--plyr-menu-radius` | The border radius on the menu. | `4px` |
|
| `--plyr-menu-radius` | The border radius on the menu. | `4px` |
|
||||||
| `--plyr-menu-arrow-size` | The size of the arrow on the bottom of the menu. | `6px` |
|
| `--plyr-menu-arrow-size` | The size of the arrow on the bottom of the menu. | `6px` |
|
||||||
| `--plyr-menu-item-arrow-color` | The color of the arrows in the menu. |  `#728197` |
|
| `--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-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-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-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-size` | The size of the stripes in the loading state in the scrubber. | `25px` |
|
||||||
| `--plyr-progress-loading-background` | The background color on the loading state in the scrubber. | `rgba(35, 40, 47, 0.6)` |
|
| `--plyr-progress-loading-background` | The background color on the loading state in the scrubber. | `rgba(35, 40, 47, 0.6)` |
|
||||||
| `--plyr-video-progress-buffered-background` | The fill color for the buffer indication in the scrubber for video. | `rgba(255, 255, 255, 0.25)` |
|
| `--plyr-video-progress-buffered-background` | The fill color for the buffer indication in the scrubber for video. | `rgba(255, 255, 255, 0.25)` |
|
||||||
| `--plyr-audio-progress-buffered-background` | The fill color for the buffer indication in the scrubber for audio. | `rgba(193, 200, 209, 0.6)` |
|
| `--plyr-audio-progress-buffered-background` | The fill color for the buffer indication in the scrubber for audio. | `rgba(193, 200, 209, 0.6)` |
|
||||||
| `--plyr-range-thumb-height` | The height of the scrubber handle/thumb. | `13px` |
|
| `--plyr-range-thumb-height` | The height of the scrubber handle/thumb. | `13px` |
|
||||||
| `--plyr-range-thumb-background` | The background of the scrubber handle/thumb. |  `#ffffff` |
|
| `--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-shadow` | The shadow of the scrubber handle/thumb. | `0 1px 1px rgba(215, 26, 18, 0.15), 0 0 0 1px rgba(215, 26, 18, 0.2)` |
|
||||||
| `--plyr-range-thumb-active-shadow-width` | The width of the shadow when the scrubber handle/thumb is `:active` (pressed). | `3px` |
|
| `--plyr-range-thumb-active-shadow-width` | The width of the shadow when the scrubber handle/thumb is `:active` (pressed). | `3px` |
|
||||||
| `--plyr-range-track-height` | The height of the scrubber/progress track. | `5px` |
|
| `--plyr-range-track-height` | The height of the scrubber/progress track. | `5px` |
|
||||||
@ -230,7 +240,7 @@ Here's a list of the properties and what they are used for:
|
|||||||
| `--plyr-audio-range-track-background` | The background of the scrubber/progress. | `--plyr-video-progress-buffered-background` |
|
| `--plyr-audio-range-track-background` | The background of the scrubber/progress. | `--plyr-video-progress-buffered-background` |
|
||||||
| `--plyr-audio-range-thumb-active-shadow-color` | The color of the shadow when the audio scrubber handle/thumb is `:active` (pressed). | `rgba(215, 26, 18, 0.1)` |
|
| `--plyr-audio-range-thumb-active-shadow-color` | The color of the shadow when the audio scrubber handle/thumb is `:active` (pressed). | `rgba(215, 26, 18, 0.1)` |
|
||||||
| `--plyr-tooltip-background` | The background color for tooltips. | `rgba(255, 255, 255, 0.9)` |
|
| `--plyr-tooltip-background` | The background color for tooltips. | `rgba(255, 255, 255, 0.9)` |
|
||||||
| `--plyr-tooltip-color` | The text color for tooltips. |  `#4a5464` |
|
| `--plyr-tooltip-color` | The text color for tooltips. |  `#4a5464` |
|
||||||
| `--plyr-tooltip-padding` | The padding for tooltips. | `calc(var(--plyr-control-spacing) / 2))` |
|
| `--plyr-tooltip-padding` | The padding for tooltips. | `calc(var(--plyr-control-spacing) / 2))` |
|
||||||
| `--plyr-tooltip-arrow-size` | The size of the arrow under tooltips. | `4px` |
|
| `--plyr-tooltip-arrow-size` | The size of the arrow under tooltips. | `4px` |
|
||||||
| `--plyr-tooltip-radius` | The border radius on tooltips. | `3px` |
|
| `--plyr-tooltip-radius` | The border radius on tooltips. | `3px` |
|
||||||
@ -267,14 +277,12 @@ You can set them in your CSS for all players:
|
|||||||
...or in your HTML:
|
...or in your HTML:
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<video class="player" style="--plyr-color-main: #1ac266;">
|
<video class="player" style="--plyr-color-main: #1ac266;">...</video>
|
||||||
...
|
|
||||||
</video>
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### SASS
|
### Sass
|
||||||
|
|
||||||
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.
|
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
|
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
|
||||||
@ -309,7 +317,7 @@ WebVTT captions are supported. To add a caption track, check the HTML example ab
|
|||||||
|
|
||||||
## JavaScript
|
## JavaScript
|
||||||
|
|
||||||
### Initialising
|
### Initializing
|
||||||
|
|
||||||
You can specify a range of arguments for the constructor to use:
|
You can specify a range of arguments for the constructor to use:
|
||||||
|
|
||||||
@ -323,17 +331,17 @@ _Note_: If a `NodeList`, `Array`, or jQuery object are passed, the first element
|
|||||||
|
|
||||||
Passing a CSS string selector that's compatible with [`querySelector`](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector):
|
Passing a CSS string selector that's compatible with [`querySelector`](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector):
|
||||||
|
|
||||||
```javascript
|
```js
|
||||||
const player = new Plyr('#player');
|
const player = new Plyr('#player');
|
||||||
```
|
```
|
||||||
|
|
||||||
Passing a [HTMLElement](https://developer.mozilla.org/en/docs/Web/API/HTMLElement):
|
Passing a [HTMLElement](https://developer.mozilla.org/en/docs/Web/API/HTMLElement):
|
||||||
|
|
||||||
```javascript
|
```js
|
||||||
const player = new Plyr(document.getElementById('player'));
|
const player = new Plyr(document.getElementById('player'));
|
||||||
```
|
```
|
||||||
|
|
||||||
```javascript
|
```js
|
||||||
const player = new Plyr(document.querySelector('.js-player'));
|
const player = new Plyr(document.querySelector('.js-player'));
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -343,13 +351,13 @@ The HTMLElement or string selector can be the target `<video>`, `<audio>`, or `<
|
|||||||
|
|
||||||
You have two choices here. You can either use a simple array loop to map the constructor:
|
You have two choices here. You can either use a simple array loop to map the constructor:
|
||||||
|
|
||||||
```javascript
|
```js
|
||||||
const players = Array.from(document.querySelectorAll('.js-player')).map(p => new Plyr(p));
|
const players = Array.from(document.querySelectorAll('.js-player')).map((p) => new Plyr(p));
|
||||||
```
|
```
|
||||||
|
|
||||||
...or use a static method where you can pass a [CSS string selector](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors), a [NodeList](https://developer.mozilla.org/en-US/docs/Web/API/NodeList), an [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) of [HTMLElement](https://developer.mozilla.org/en/docs/Web/API/HTMLElement), or a [JQuery](https://jquery.com) object:
|
...or use a static method where you can pass a [CSS string selector](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors), a [NodeList](https://developer.mozilla.org/en-US/docs/Web/API/NodeList), an [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) of [HTMLElement](https://developer.mozilla.org/en/docs/Web/API/HTMLElement), or a [JQuery](https://jquery.com) object:
|
||||||
|
|
||||||
```javascript
|
```js
|
||||||
const players = Plyr.setup('.js-player');
|
const players = Plyr.setup('.js-player');
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -359,7 +367,7 @@ Both options will also return an array of instances in the order of they were in
|
|||||||
|
|
||||||
The second argument for the constructor is the [options](#options) object:
|
The second argument for the constructor is the [options](#options) object:
|
||||||
|
|
||||||
```javascript
|
```js
|
||||||
const player = new Plyr('#player', {
|
const player = new Plyr('#player', {
|
||||||
title: 'Example Title',
|
title: 'Example Title',
|
||||||
});
|
});
|
||||||
@ -374,7 +382,7 @@ Options can be passed as an object to the constructor as above or as JSON in `da
|
|||||||
Note the single quotes encapsulating the JSON and double quotes on the object keys. Only string values need double quotes.
|
Note the single quotes encapsulating the JSON and double quotes on the object keys. Only string values need double quotes.
|
||||||
|
|
||||||
| Option | Type | Default | Description |
|
| Option | Type | Default | Description |
|
||||||
| -------------------- | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| -------------------- | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| `enabled` | Boolean | `true` | Completely disable Plyr. This would allow you to do a User Agent check or similar to programmatically enable or disable Plyr for a certain UA. Example below. |
|
| `enabled` | Boolean | `true` | Completely disable Plyr. This would allow you to do a User Agent check or similar to programmatically enable or disable Plyr for a certain UA. Example below. |
|
||||||
| `debug` | Boolean | `false` | Display debugging information in the console |
|
| `debug` | Boolean | `false` | Display debugging information in the console |
|
||||||
| `controls` | Array, Function or Element | `['play-large', 'play', 'progress', 'current-time', 'mute', 'volume', 'captions', 'settings', 'pip', 'airplay', 'fullscreen']` | If a function is passed, it is assumed your method will return either an element or HTML string for the controls. Three arguments will be passed to your function; `id` (the unique id for the player), `seektime` (the seektime step in seconds), and `title` (the media title). See [CONTROLS.md](CONTROLS.md) for more info on how the html needs to be structured. |
|
| `controls` | Array, Function or Element | `['play-large', 'play', 'progress', 'current-time', 'mute', 'volume', 'captions', 'settings', 'pip', 'airplay', 'fullscreen']` | If a function is passed, it is assumed your method will return either an element or HTML string for the controls. Three arguments will be passed to your function; `id` (the unique id for the player), `seektime` (the seektime step in seconds), and `title` (the media title). See [CONTROLS.md](CONTROLS.md) for more info on how the html needs to be structured. |
|
||||||
@ -386,6 +394,7 @@ Note the single quotes encapsulating the JSON and double quotes on the object ke
|
|||||||
| `blankVideo` | String | `https://cdn.plyr.io/static/blank.mp4` | Specify a URL or path to a blank video file used to properly cancel network requests. |
|
| `blankVideo` | String | `https://cdn.plyr.io/static/blank.mp4` | Specify a URL or path to a blank video file used to properly cancel network requests. |
|
||||||
| `autoplay`² | Boolean | `false` | Autoplay the media on load. If the `autoplay` attribute is present on a `<video>` or `<audio>` element, this will be automatically set to true. |
|
| `autoplay`² | Boolean | `false` | Autoplay the media on load. If the `autoplay` attribute is present on a `<video>` or `<audio>` element, this will be automatically set to true. |
|
||||||
| `autopause`¹ | Boolean | `true` | Only allow one player playing at once. |
|
| `autopause`¹ | Boolean | `true` | Only allow one player playing at once. |
|
||||||
|
| `playsinline`³ | Boolean | `true` | Allow inline playback on iOS. Note this has no effect on iPadOS. |
|
||||||
| `seekTime` | Number | `10` | The time, in seconds, to seek when a user hits fast forward or rewind. |
|
| `seekTime` | Number | `10` | The time, in seconds, to seek when a user hits fast forward or rewind. |
|
||||||
| `volume` | Number | `1` | A number, between 0 and 1, representing the initial volume of the player. |
|
| `volume` | Number | `1` | A number, between 0 and 1, representing the initial volume of the player. |
|
||||||
| `muted` | Boolean | `false` | Whether to start playback muted. If the `muted` attribute is present on a `<video>` or `<audio>` element, this will be automatically set to true. |
|
| `muted` | Boolean | `false` | Whether to start playback muted. If the `muted` attribute is present on a `<video>` or `<audio>` element, this will be automatically set to true. |
|
||||||
@ -400,11 +409,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. |
|
| `invertTime` | Boolean | `true` | Display the current time as a countdown rather than an incremental counter. |
|
||||||
| `toggleInvert` | Boolean | `true` | Allow users to click to toggle the above. |
|
| `toggleInvert` | Boolean | `true` | Allow users to click to toggle the above. |
|
||||||
| `listeners` | Object | `null` | Allows binding of event listeners to the controls before the default handlers. See the `defaults.js` for available listeners. If your handler prevents default on the event (`event.preventDefault()`), the default handler will not fire. |
|
| `listeners` | Object | `null` | Allows binding of event listeners to the controls before the default handlers. See the `defaults.js` for available listeners. If your handler prevents default on the event (`event.preventDefault()`), the default handler will not fire. |
|
||||||
| `captions` | Object | `{ active: false, language: 'auto', update: false }` | `active`: Toggles if captions should be active by default. `language`: Sets the default language to load (if available). 'auto' uses the browser language. `update`: Listen to changes to tracks and update menu. This is needed for some streaming libraries, but can result in unselectable language options). |
|
| `captions` | Object | `{ active: false, language: 'auto', update: false }` | `active`: Toggles if captions should be active by default. `language`: Sets the default language to load (if available). 'auto' uses the browser language. `update`: Listen to changes to tracks and update menu. This is needed for some streaming libraries, but can result in non-selectable language options). |
|
||||||
| `fullscreen` | Object | `{ enabled: true, fallback: true, iosNative: false, container: null }` | `enabled`: Toggles whether fullscreen should be enabled. `fallback`: Allow fallback to a full-window solution (`true`/`false`/`'force'`). `iosNative`: whether to use native iOS fullscreen when entering fullscreen (no custom controls). `container`: A selector for an ancestor of the player element, allows contextual content to remain visual in fullscreen mode. Non-ancestors are ignored. |
|
| `fullscreen` | Object | `{ enabled: true, fallback: true, iosNative: false, container: null }` | `enabled`: Toggles whether fullscreen should be enabled. `fallback`: Allow fallback to a full-window solution (`true`/`false`/`'force'`). `iosNative`: whether to use native iOS fullscreen when entering fullscreen (no custom controls) - note this has no effect on iPadOS. `container`: A selector for an ancestor of the player element, allows contextual content to remain visual in fullscreen mode. Non-ancestors are ignored. |
|
||||||
| `ratio` | String | `null` | Force an aspect ratio for all videos. The format is `'w:h'` - e.g. `'16:9'` or `'4:3'`. If this is not specified then the default for HTML5 and Vimeo is to use the native resolution of the video. As dimensions are not available from YouTube via SDK, 16:9 is forced as a sensible default. |
|
| `ratio` | String | `null` | Force an aspect ratio for all videos. The format is `'w:h'` - e.g. `'16:9'` or `'4:3'`. If this is not specified then the default for HTML5 and Vimeo is to use the native resolution of the video. As dimensions are not available from YouTube via SDK, 16:9 is forced as a sensible default. |
|
||||||
| `storage` | Object | `{ enabled: true, key: 'plyr' }` | `enabled`: Allow use of local storage to store user settings. `key`: The key name to use. |
|
| `storage` | Object | `{ enabled: true, key: 'plyr' }` | `enabled`: Allow use of local storage to store user settings. `key`: The key name to use. |
|
||||||
| `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. |
|
| `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. |
|
| `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. |
|
| `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,13 +421,20 @@ 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` |
|
| `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` |
|
| `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. |
|
| `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
|
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:
|
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:
|
||||||
|
|
||||||
- https://webkit.org/blog/6784/new-video-policies-for-ios/
|
- <https://webkit.org/blog/6784/new-video-policies-for-ios/>
|
||||||
- https://developers.google.com/web/updates/2017/09/autoplay-policy-changes
|
- <https://developers.google.com/web/updates/2017/09/autoplay-policy-changes>
|
||||||
- https://hacks.mozilla.org/2019/02/firefox-66-to-block-automatically-playing-audible-video-and-audio/
|
- <https://hacks.mozilla.org/2019/02/firefox-66-to-block-automatically-playing-audible-video-and-audio/>
|
||||||
|
|
||||||
|
3. YouTube does not support programatically toggling the native fullscreen player via it's API. This means on iOS you have two options, neither being perfect:
|
||||||
|
|
||||||
|
- Use the fallback/faux fullscreen option which covers the whole viewport (this is the default)
|
||||||
|
- Set `playsinline` to `false` and/or `fullscreen.iosNative` to `true` - either option hides the fullscreen toggle in the UI (because of the above API issue) and means iOS will play the video in it's native player.
|
||||||
|
|
||||||
# API
|
# API
|
||||||
|
|
||||||
@ -428,7 +444,7 @@ There are methods, setters and getters on a Plyr object.
|
|||||||
|
|
||||||
The easiest way to access the Plyr object is to set the return value from your call to the constructor to a variable. For example:
|
The easiest way to access the Plyr object is to set the return value from your call to the constructor to a variable. For example:
|
||||||
|
|
||||||
```javascript
|
```js
|
||||||
const player = new Plyr('#player', {
|
const player = new Plyr('#player', {
|
||||||
/* options */
|
/* options */
|
||||||
});
|
});
|
||||||
@ -436,8 +452,8 @@ const player = new Plyr('#player', {
|
|||||||
|
|
||||||
You can also access the object through any events:
|
You can also access the object through any events:
|
||||||
|
|
||||||
```javascript
|
```js
|
||||||
element.addEventListener('ready', event => {
|
element.addEventListener('ready', (event) => {
|
||||||
const player = event.detail.plyr;
|
const player = event.detail.plyr;
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
@ -446,13 +462,13 @@ element.addEventListener('ready', event => {
|
|||||||
|
|
||||||
Example method use:
|
Example method use:
|
||||||
|
|
||||||
```javascript
|
```js
|
||||||
player.play(); // Start playback
|
player.play(); // Start playback
|
||||||
player.fullscreen.enter(); // Enter fullscreen
|
player.fullscreen.enter(); // Enter fullscreen
|
||||||
```
|
```
|
||||||
|
|
||||||
| Method | Parameters | Description |
|
| Method | Parameters | Description |
|
||||||
| -------------------------- | ---------------- | ---------------------------------------------------------------------------------------------------------- |
|
| -------------------------------------------------------- | ---------------- | ---------------------------------------------------------------------------------------------------------- |
|
||||||
| `play()`¹ | - | Start playback. |
|
| `play()`¹ | - | Start playback. |
|
||||||
| `pause()` | - | Pause playback. |
|
| `pause()` | - | Pause playback. |
|
||||||
| `togglePlay(toggle)`¹ | Boolean | Toggle playback, if no parameters are passed, it will toggle based on current status. |
|
| `togglePlay(toggle)`¹ | Boolean | Toggle playback, if no parameters are passed, it will toggle based on current status. |
|
||||||
@ -467,6 +483,7 @@ player.fullscreen.enter(); // Enter fullscreen
|
|||||||
| `fullscreen.exit()` | - | Exit fullscreen. |
|
| `fullscreen.exit()` | - | Exit fullscreen. |
|
||||||
| `fullscreen.toggle()` | - | Toggle fullscreen. |
|
| `fullscreen.toggle()` | - | Toggle fullscreen. |
|
||||||
| `airplay()` | - | Trigger the airplay dialog on supported devices. |
|
| `airplay()` | - | Trigger the airplay dialog on supported devices. |
|
||||||
|
| `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. |
|
| `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. |
|
| `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. |
|
| `once(event, function)` | String, Function | Add an event listener for the specified event once. |
|
||||||
@ -480,14 +497,14 @@ player.fullscreen.enter(); // Enter fullscreen
|
|||||||
|
|
||||||
Example setters:
|
Example setters:
|
||||||
|
|
||||||
```javascript
|
```js
|
||||||
player.volume = 0.5; // Sets volume at 50%
|
player.volume = 0.5; // Sets volume at 50%
|
||||||
player.currentTime = 10; // Seeks to 10 seconds
|
player.currentTime = 10; // Seeks to 10 seconds
|
||||||
```
|
```
|
||||||
|
|
||||||
Example getters:
|
Example getters:
|
||||||
|
|
||||||
```javascript
|
```js
|
||||||
player.volume; // 0.5;
|
player.volume; // 0.5;
|
||||||
player.currentTime; // 10
|
player.currentTime; // 10
|
||||||
player.fullscreen.active; // false;
|
player.fullscreen.active; // false;
|
||||||
@ -513,6 +530,7 @@ player.fullscreen.active; // false;
|
|||||||
| `loop` | ✓ | ✓ | Gets or sets the current loop state of the player. The setter accepts a boolean. |
|
| `loop` | ✓ | ✓ | Gets or sets the current loop state of the player. The setter accepts a boolean. |
|
||||||
| `source` | ✓ | ✓ | Gets or sets the current source for the player. The setter accepts an object. See [source setter](#the-source-setter) below for examples. |
|
| `source` | ✓ | ✓ | Gets or sets the current source for the player. The setter accepts an object. See [source setter](#the-source-setter) below for examples. |
|
||||||
| `poster` | ✓ | ✓ | Gets or sets the current poster image for the player. The setter accepts a string; the URL for the updated poster image. |
|
| `poster` | ✓ | ✓ | Gets or sets the current poster image for the player. The setter accepts a string; the URL for the updated poster image. |
|
||||||
|
| `previewThumbnails` | ✓ | ✓ | Gets or sets the current preview thumbnail source for the player. The setter accepts a string |
|
||||||
| `autoplay` | ✓ | ✓ | Gets or sets the autoplay state of the player. The setter accepts a boolean. |
|
| `autoplay` | ✓ | ✓ | Gets or sets the autoplay state of the player. The setter accepts a boolean. |
|
||||||
| `currentTrack` | ✓ | ✓ | Gets or sets the caption track by index. `-1` means the track is missing or captions is not active |
|
| `currentTrack` | ✓ | ✓ | Gets or sets the caption track by index. `-1` means the track is missing or captions is not active |
|
||||||
| `language` | ✓ | ✓ | Gets or sets the preferred captions language for the player. The setter accepts an ISO two-letter language code. Support for the languages is dependent on the captions you include. If your captions don't have any language data, or if you have multiple tracks with the same language, you may want to use `currentTrack` instead. |
|
| `language` | ✓ | ✓ | Gets or sets the preferred captions language for the player. The setter accepts an ISO two-letter language code. Support for the languages is dependent on the captions you include. If your captions don't have any language data, or if you have multiple tracks with the same language, you may want to use `currentTrack` instead. |
|
||||||
@ -530,7 +548,7 @@ This allows changing the player source and type on the fly.
|
|||||||
|
|
||||||
Video example:
|
Video example:
|
||||||
|
|
||||||
```javascript
|
```js
|
||||||
player.source = {
|
player.source = {
|
||||||
type: 'video',
|
type: 'video',
|
||||||
title: 'Example title',
|
title: 'Example title',
|
||||||
@ -570,7 +588,7 @@ player.source = {
|
|||||||
|
|
||||||
Audio example:
|
Audio example:
|
||||||
|
|
||||||
```javascript
|
```js
|
||||||
player.source = {
|
player.source = {
|
||||||
type: 'audio',
|
type: 'audio',
|
||||||
title: 'Example title',
|
title: 'Example title',
|
||||||
@ -589,7 +607,7 @@ player.source = {
|
|||||||
|
|
||||||
YouTube example:
|
YouTube example:
|
||||||
|
|
||||||
```javascript
|
```js
|
||||||
player.source = {
|
player.source = {
|
||||||
type: 'video',
|
type: 'video',
|
||||||
sources: [
|
sources: [
|
||||||
@ -603,12 +621,12 @@ player.source = {
|
|||||||
|
|
||||||
Vimeo example
|
Vimeo example
|
||||||
|
|
||||||
```javascript
|
```js
|
||||||
player.source = {
|
player.source = {
|
||||||
type: 'video',
|
type: 'video',
|
||||||
sources: [
|
sources: [
|
||||||
{
|
{
|
||||||
src: '143418951',
|
src: '76979871',
|
||||||
provider: 'vimeo',
|
provider: 'vimeo',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@ -634,8 +652,8 @@ You can listen for events on the target element you setup Plyr on (see example u
|
|||||||
reference to the instance, you can use the `on()` API method or `addEventListener()`. Access to the API can be obtained this way through the `event.detail.plyr`
|
reference to the instance, you can use the `on()` API method or `addEventListener()`. Access to the API can be obtained this way through the `event.detail.plyr`
|
||||||
property. Here's an example:
|
property. Here's an example:
|
||||||
|
|
||||||
```javascript
|
```js
|
||||||
player.on('ready', event => {
|
player.on('ready', (event) => {
|
||||||
const instance = event.detail.plyr;
|
const instance = event.detail.plyr;
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
@ -756,21 +774,20 @@ Plyr uses ES6 which isn't supported in all browsers quite yet. This means some f
|
|||||||
|
|
||||||
You can use the static method to check for support. For example
|
You can use the static method to check for support. For example
|
||||||
|
|
||||||
```javascript
|
```js
|
||||||
const supported = Plyr.supported('video', 'html5', true);
|
const supported = Plyr.supported('video', 'html5');
|
||||||
```
|
```
|
||||||
|
|
||||||
The arguments are:
|
The arguments are:
|
||||||
|
|
||||||
- Media type (`audio` or `video`)
|
- Media type (`'audio' | 'video'`)
|
||||||
- Provider (`html5`, `youtube` or `vimeo`)
|
- Provider (`'html5' | 'youtube' | 'vimeo'`)
|
||||||
- Whether the player has the `playsinline` attribute (only applicable to iOS 10+)
|
|
||||||
|
|
||||||
## Disable support programmatically
|
## Disable support programmatically
|
||||||
|
|
||||||
The `enabled` option can be used to disable certain User Agents. For example, if you don't want to use Plyr for smartphones, you could use:
|
The `enabled` option can be used to disable certain User Agents. For example, if you don't want to use Plyr for smartphones, you could use:
|
||||||
|
|
||||||
```javascript
|
```js
|
||||||
{
|
{
|
||||||
enabled: !/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent);
|
enabled: !/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent);
|
||||||
}
|
}
|
||||||
@ -783,7 +800,7 @@ If a User Agent is disabled but supports `<video>` and `<audio>` natively, it wi
|
|||||||
Some awesome folks have made plugins for CMSs and Components for JavaScript frameworks:
|
Some awesome folks have made plugins for CMSs and Components for JavaScript frameworks:
|
||||||
|
|
||||||
| Type | Maintainer | Link |
|
| Type | Maintainer | Link |
|
||||||
| --------- | ------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- |
|
| ----------- | --------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- |
|
||||||
| WordPress | Brandon Lavigne ([@drrobotnik](https://github.com/drrobotnik)) | [https://wordpress.org/plugins/plyr/](https://wordpress.org/plugins/plyr/) |
|
| WordPress | Brandon Lavigne ([@drrobotnik](https://github.com/drrobotnik)) | [https://wordpress.org/plugins/plyr/](https://wordpress.org/plugins/plyr/) |
|
||||||
| Angular | Simon Bobrov ([@smnbbrv](https://github.com/smnbbrv)) | [https://github.com/smnbbrv/ngx-plyr](https://github.com/smnbbrv/ngx-plyr) |
|
| Angular | Simon Bobrov ([@smnbbrv](https://github.com/smnbbrv)) | [https://github.com/smnbbrv/ngx-plyr](https://github.com/smnbbrv/ngx-plyr) |
|
||||||
| React | Chintan Prajapati ([@chintan9](https://github.com/chintan9)) | [https://github.com/chintan9/plyr-react](https://github.com/chintan9/plyr-react) |
|
| React | Chintan Prajapati ([@chintan9](https://github.com/chintan9)) | [https://github.com/chintan9/plyr-react](https://github.com/chintan9/plyr-react) |
|
||||||
@ -791,7 +808,7 @@ Some awesome folks have made plugins for CMSs and Components for JavaScript fram
|
|||||||
| Neos | Jon Uhlmann ([@jonnitto](https://github.com/jonnitto)) | [https://packagist.org/packages/jonnitto/plyr](https://packagist.org/packages/jonnitto/plyr) |
|
| Neos | Jon Uhlmann ([@jonnitto](https://github.com/jonnitto)) | [https://packagist.org/packages/jonnitto/plyr](https://packagist.org/packages/jonnitto/plyr) |
|
||||||
| Kirby | Dominik Pschenitschni ([@dpschen](https://github.com/dpschen)) | [https://github.com/dpschen/kirby-plyrtag](https://github.com/dpschen/kirby-plyrtag) |
|
| Kirby | Dominik Pschenitschni ([@dpschen](https://github.com/dpschen)) | [https://github.com/dpschen/kirby-plyrtag](https://github.com/dpschen/kirby-plyrtag) |
|
||||||
| REDAXO | FriendsOfRedaxo / skerbis ([@skerbis](https://friendsofredaxo.github.io)) | [https://github.com/FriendsOfREDAXO/plyr](https://github.com/FriendsOfREDAXO/plyr) |
|
| REDAXO | FriendsOfRedaxo / skerbis ([@skerbis](https://friendsofredaxo.github.io)) | [https://github.com/FriendsOfREDAXO/plyr](https://github.com/FriendsOfREDAXO/plyr) |
|
||||||
| svelte-plyr | Ben Woodward / benwoodward ([@benwoodward](https://github.com/benwoodward)) | [https://github.com/benwoodward](https://github.com/benwoodward) |
|
| svelte-plyr | Ben Woodward / benwoodward ([@benwoodward](https://github.com/benwoodward)) | [https://github.com/benwoodward/svelte-plyr](https://github.com/benwoodward/svelte-plyr) |
|
||||||
|
|
||||||
# Issues
|
# Issues
|
||||||
|
|
||||||
@ -840,6 +857,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)
|
- [pressakey.com | Blog-Magazin für Videospiele](https://pressakey.com)
|
||||||
- [STROLLÿN: Work with a View](https://strollyn.com)
|
- [STROLLÿN: Work with a View](https://strollyn.com)
|
||||||
- [CFDA Runway360](https://runway360.cfda.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 😎
|
If you want to be added to the list, open a pull request. It'd be awesome to see how you're using Plyr 😎
|
||||||
|
|
||||||
@ -850,13 +869,8 @@ If you want to be added to the list, open a pull request. It'd be awesome to see
|
|||||||
|
|
||||||
# Thanks
|
# Thanks
|
||||||
|
|
||||||
[](https://www.fastly.com/)
|
- [Cloudflare](https://www.cloudflare.com/) and [Fastly](https://www.fastly.com/) for providing the CDN services.
|
||||||
|
- [Sentry](https://sentry.io/) for error logging service on the demo website.
|
||||||
Massive thanks to [Fastly](https://www.fastly.com/) for providing the CDN services.
|
|
||||||
|
|
||||||
[](https://sentry.io/)
|
|
||||||
|
|
||||||
Massive thanks to [Sentry](https://sentry.io/) for providing the logging services for the demo site.
|
|
||||||
|
|
||||||
## Contributors
|
## Contributors
|
||||||
|
|
||||||
|
36
cspell.json
Normal file
36
cspell.json
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2",
|
||||||
|
"ignorePaths": ["package.json", "dist/*", "demo/node_modules/*"],
|
||||||
|
"dictionaryDefinitions": [],
|
||||||
|
"dictionaries": ["en-gb", "softwareTerms", "html", "css", "typescript"],
|
||||||
|
"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": []
|
||||||
|
}
|
@ -66,53 +66,49 @@
|
|||||||
<h1>Pl<span>a</span>y<span>e</span>r</h1>
|
<h1>Pl<span>a</span>y<span>e</span>r</h1>
|
||||||
<p>
|
<p>
|
||||||
A simple, accessible and customisable media player for
|
A simple, accessible and customisable media player for
|
||||||
<button type="button" class="faux-link" data-source="video">
|
<button type="button" class="link" data-source="video">
|
||||||
<svg class="icon">
|
<svg class="icon">
|
||||||
<title>HTML5</title>
|
<title>HTML5</title>
|
||||||
<path
|
<path
|
||||||
d="M14.738.326C14.548.118 14.28 0 14 0H2c-.28 0-.55.118-.738.326S.98.81 1.004 1.09l1 11c.03.317.208.603.48.767l5 3c.16.095.338.143.516.143s.356-.048.515-.143l5-3c.273-.164.452-.45.48-.767l1-11c.026-.28-.067-.557-.257-.764zM12 4H6v2h6v5.72l-4 1.334-4-1.333V9h2v1.28l2 .666 2-.667V8H4V2h8v2z"
|
d="M14.738.326C14.548.118 14.28 0 14 0H2c-.28 0-.55.118-.738.326S.98.81 1.004 1.09l1 11c.03.317.208.603.48.767l5 3c.16.095.338.143.516.143s.356-.048.515-.143l5-3c.273-.164.452-.45.48-.767l1-11c.026-.28-.067-.557-.257-.764zM12 4H6v2h6v5.72l-4 1.334-4-1.333V9h2v1.28l2 .666 2-.667V8H4V2h8v2z"
|
||||||
></path></svg
|
></path>
|
||||||
>Video</button
|
</svg>
|
||||||
|
Video</button
|
||||||
>,
|
>,
|
||||||
<button type="button" class="faux-link" data-source="audio">
|
<button type="button" class="link" data-source="audio">
|
||||||
<svg class="icon">
|
<svg class="icon">
|
||||||
<title>HTML5</title>
|
<title>HTML5</title>
|
||||||
<path
|
<path
|
||||||
d="M14.738.326C14.548.118 14.28 0 14 0H2c-.28 0-.55.118-.738.326S.98.81 1.004 1.09l1 11c.03.317.208.603.48.767l5 3c.16.095.338.143.516.143s.356-.048.515-.143l5-3c.273-.164.452-.45.48-.767l1-11c.026-.28-.067-.557-.257-.764zM12 4H6v2h6v5.72l-4 1.334-4-1.333V9h2v1.28l2 .666 2-.667V8H4V2h8v2z"
|
d="M14.738.326C14.548.118 14.28 0 14 0H2c-.28 0-.55.118-.738.326S.98.81 1.004 1.09l1 11c.03.317.208.603.48.767l5 3c.16.095.338.143.516.143s.356-.048.515-.143l5-3c.273-.164.452-.45.48-.767l1-11c.026-.28-.067-.557-.257-.764zM12 4H6v2h6v5.72l-4 1.334-4-1.333V9h2v1.28l2 .666 2-.667V8H4V2h8v2z"
|
||||||
></path></svg
|
></path>
|
||||||
>Audio</button
|
</svg>
|
||||||
|
Audio</button
|
||||||
>,
|
>,
|
||||||
<button type="button" class="faux-link" data-source="youtube">
|
<button type="button" class="link" data-source="youtube">
|
||||||
<svg class="icon" role="presentation">
|
<svg class="icon" role="presentation">
|
||||||
<title>YouTube</title>
|
<title>YouTube</title>
|
||||||
<path
|
<path
|
||||||
d="M15.8,4.8c-0.2-1.3-0.8-2.2-2.2-2.4C11.4,2,8,2,8,2S4.6,2,2.4,2.4C1,2.6,0.3,3.5,0.2,4.8C0,6.1,0,8,0,8
|
d="M15.8,4.8c-0.2-1.3-0.8-2.2-2.2-2.4C11.4,2,8,2,8,2S4.6,2,2.4,2.4C1,2.6,0.3,3.5,0.2,4.8C0,6.1,0,8,0,8
|
||||||
s0,1.9,0.2,3.2c0.2,1.3,0.8,2.2,2.2,2.4C4.6,14,8,14,8,14s3.4,0,5.6-0.4c1.4-0.3,2-1.1,2.2-2.4C16,9.9,16,8,16,8S16,6.1,15.8,4.8z
|
s0,1.9,0.2,3.2c0.2,1.3,0.8,2.2,2.2,2.4C4.6,14,8,14,8,14s3.4,0,5.6-0.4c1.4-0.3,2-1.1,2.2-2.4C16,9.9,16,8,16,8S16,6.1,15.8,4.8z
|
||||||
M6,11V5l5,3L6,11z"
|
M6,11V5l5,3L6,11z"
|
||||||
></path></svg
|
></path>
|
||||||
>YouTube
|
</svg>
|
||||||
|
YouTube
|
||||||
</button>
|
</button>
|
||||||
and
|
and
|
||||||
<button type="button" class="faux-link" data-source="vimeo">
|
<button type="button" class="link" data-source="vimeo">
|
||||||
<svg class="icon" role="presentation">
|
<svg class="icon" role="presentation">
|
||||||
<title>Vimeo</title>
|
<title>Vimeo</title>
|
||||||
<path
|
<path
|
||||||
d="M16,4.3c-0.1,1.6-1.2,3.7-3.3,6.4c-2.2,2.8-4,4.2-5.5,4.2c-0.9,0-1.7-0.9-2.4-2.6C4,9.9,3.4,5,2,5
|
d="M16,4.3c-0.1,1.6-1.2,3.7-3.3,6.4c-2.2,2.8-4,4.2-5.5,4.2c-0.9,0-1.7-0.9-2.4-2.6C4,9.9,3.4,5,2,5
|
||||||
C1.9,5,1.5,5.3,0.8,5.8L0,4.8c0.8-0.7,3.5-3.4,4.7-3.5C5.9,1.2,6.7,2,7,3.8c0.3,2,0.8,6.1,1.8,6.1c0.9,0,2.5-3.4,2.6-4
|
C1.9,5,1.5,5.3,0.8,5.8L0,4.8c0.8-0.7,3.5-3.4,4.7-3.5C5.9,1.2,6.7,2,7,3.8c0.3,2,0.8,6.1,1.8,6.1c0.9,0,2.5-3.4,2.6-4
|
||||||
c0.1-0.9-0.3-1.9-2.3-1.1c0.8-2.6,2.3-3.8,4.5-3.8C15.3,1.1,16.1,2.2,16,4.3z"
|
c0.1-0.9-0.3-1.9-2.3-1.1c0.8-2.6,2.3-3.8,4.5-3.8C15.3,1.1,16.1,2.2,16,4.3z"
|
||||||
></path></svg
|
></path>
|
||||||
>Vimeo
|
</svg>
|
||||||
|
Vimeo
|
||||||
</button>
|
</button>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
|
||||||
Premium video monetization from
|
|
||||||
<a href="https://vi.ai/publisher-video-monetization/?aid=plyrio" target="_blank" class="no-border">
|
|
||||||
<img src="https://cdn.plyr.io/static/vi-logo-24x24.svg" alt="ai.vi" />
|
|
||||||
<span class="sr-only">ai.vi</span>
|
|
||||||
</a>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<div class="call-to-action">
|
<div class="call-to-action">
|
||||||
<a href="https://github.com/sampotts/plyr" target="_blank" class="button js-shr">
|
<a href="https://github.com/sampotts/plyr" target="_blank" class="button js-shr">
|
||||||
<svg class="icon" role="presentation">
|
<svg class="icon" role="presentation">
|
||||||
@ -185,7 +181,10 @@
|
|||||||
d="M14.738.326C14.548.118 14.28 0 14 0H2c-.28 0-.55.118-.738.326S.98.81 1.004 1.09l1 11c.03.317.208.603.48.767l5 3c.16.095.338.143.516.143s.356-.048.515-.143l5-3c.273-.164.452-.45.48-.767l1-11c.026-.28-.067-.557-.257-.764zM12 4H6v2h6v5.72l-4 1.334-4-1.333V9h2v1.28l2 .666 2-.667V8H4V2h8v2z"
|
d="M14.738.326C14.548.118 14.28 0 14 0H2c-.28 0-.55.118-.738.326S.98.81 1.004 1.09l1 11c.03.317.208.603.48.767l5 3c.16.095.338.143.516.143s.356-.048.515-.143l5-3c.273-.164.452-.45.48-.767l1-11c.026-.28-.067-.557-.257-.764zM12 4H6v2h6v5.72l-4 1.334-4-1.333V9h2v1.28l2 .666 2-.667V8H4V2h8v2z"
|
||||||
></path>
|
></path>
|
||||||
</svg>
|
</svg>
|
||||||
<a href="https://itunes.apple.com/au/movie/view-from-a-blue-moon/id1041586323" target="_blank"
|
<a
|
||||||
|
href="https://itunes.apple.com/au/movie/view-from-a-blue-moon/id1041586323"
|
||||||
|
target="_blank"
|
||||||
|
class="link"
|
||||||
>View From A Blue Moon</a
|
>View From A Blue Moon</a
|
||||||
>
|
>
|
||||||
© Brainfarm
|
© Brainfarm
|
||||||
@ -199,7 +198,7 @@
|
|||||||
d="M14.738.326C14.548.118 14.28 0 14 0H2c-.28 0-.55.118-.738.326S.98.81 1.004 1.09l1 11c.03.317.208.603.48.767l5 3c.16.095.338.143.516.143s.356-.048.515-.143l5-3c.273-.164.452-.45.48-.767l1-11c.026-.28-.067-.557-.257-.764zM12 4H6v2h6v5.72l-4 1.334-4-1.333V9h2v1.28l2 .666 2-.667V8H4V2h8v2z"
|
d="M14.738.326C14.548.118 14.28 0 14 0H2c-.28 0-.55.118-.738.326S.98.81 1.004 1.09l1 11c.03.317.208.603.48.767l5 3c.16.095.338.143.516.143s.356-.048.515-.143l5-3c.273-.164.452-.45.48-.767l1-11c.026-.28-.067-.557-.257-.764zM12 4H6v2h6v5.72l-4 1.334-4-1.333V9h2v1.28l2 .666 2-.667V8H4V2h8v2z"
|
||||||
></path>
|
></path>
|
||||||
</svg>
|
</svg>
|
||||||
<a href="http://www.kishibashi.com/" target="_blank"
|
<a href="http://www.kishibashi.com/" target="_blank" class="link"
|
||||||
>Kishi Bashi – “It All Began With A Burst”</a
|
>Kishi Bashi – “It All Began With A Burst”</a
|
||||||
>
|
>
|
||||||
© Kishi Bashi
|
© Kishi Bashi
|
||||||
@ -223,7 +222,7 @@
|
|||||||
</li>
|
</li>
|
||||||
<li class="plyr__cite plyr__cite--vimeo" hidden>
|
<li class="plyr__cite plyr__cite--vimeo" hidden>
|
||||||
<small>
|
<small>
|
||||||
<a href="https://vimeo.com/40648169" target="_blank">Toob “Wavaphon” Music Video</a>
|
<a href="https://vimeo.com/40648169" target="_blank" class="link">Toob “Wavaphon” Music Video</a>
|
||||||
on
|
on
|
||||||
<span class="color--vimeo">
|
<span class="color--vimeo">
|
||||||
<svg class="icon" role="presentation">
|
<svg class="icon" role="presentation">
|
||||||
@ -256,7 +255,7 @@
|
|||||||
<a
|
<a
|
||||||
href="https://twitter.com/intent/tweet?text=A+simple+HTML5+media+player+with+custom+controls+and+WebVTT+captions.&url=http%3A%2F%2Fplyr.io&via=Sam_Potts"
|
href="https://twitter.com/intent/tweet?text=A+simple+HTML5+media+player+with+custom+controls+and+WebVTT+captions.&url=http%3A%2F%2Fplyr.io&via=Sam_Potts"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
class="js-shr"
|
class="link js-shr"
|
||||||
>tweet it</a
|
>tweet it</a
|
||||||
>
|
>
|
||||||
👍
|
👍
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
// Please see README.md in the root or github.com/sampotts/plyr
|
// Please see README.md in the root or github.com/sampotts/plyr
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
|
|
||||||
import './tab-focus';
|
|
||||||
import 'custom-event-polyfill';
|
import 'custom-event-polyfill';
|
||||||
import 'url-polyfill';
|
import 'url-polyfill';
|
||||||
|
|
||||||
@ -13,13 +12,13 @@ import Shr from 'shr-buttons';
|
|||||||
|
|
||||||
import Plyr from '../../../src/js/plyr';
|
import Plyr from '../../../src/js/plyr';
|
||||||
import sources from './sources';
|
import sources from './sources';
|
||||||
import toggleClass from './toggle-class';
|
|
||||||
|
|
||||||
(() => {
|
(() => {
|
||||||
const production = 'plyr.io';
|
const production = 'plyr.io';
|
||||||
|
const isProduction = window.location.host.includes(production);
|
||||||
|
|
||||||
// Sentry for demo site (https://plyr.io) only
|
// Sentry for demo site (https://plyr.io) only
|
||||||
if (window.location.host === production) {
|
if (isProduction) {
|
||||||
Sentry.init({
|
Sentry.init({
|
||||||
dsn: 'https://d4ad9866ad834437a4754e23937071e4@sentry.io/305555',
|
dsn: 'https://d4ad9866ad834437a4754e23937071e4@sentry.io/305555',
|
||||||
whitelistUrls: [production].map((d) => new RegExp(`https://(([a-z0-9])+(.))*${d}`)),
|
whitelistUrls: [production].map((d) => new RegExp(`https://(([a-z0-9])+(.))*${d}`)),
|
||||||
@ -53,10 +52,10 @@ import toggleClass from './toggle-class';
|
|||||||
captions: {
|
captions: {
|
||||||
active: true,
|
active: true,
|
||||||
},
|
},
|
||||||
ads: {
|
/* ads: {
|
||||||
enabled: window.location.host.includes(production),
|
enabled: isProduction,
|
||||||
publisherId: '918848828995742',
|
publisherId: '918848828995742',
|
||||||
},
|
}, */
|
||||||
previewThumbnails: {
|
previewThumbnails: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
src: ['https://cdn.plyr.io/static/demo/thumbs/100p.vtt', 'https://cdn.plyr.io/static/demo/thumbs/240p.vtt'],
|
src: ['https://cdn.plyr.io/static/demo/thumbs/100p.vtt', 'https://cdn.plyr.io/static/demo/thumbs/240p.vtt'],
|
||||||
@ -65,6 +64,34 @@ import toggleClass from './toggle-class';
|
|||||||
// Prevent Vimeo blocking plyr.io demo site
|
// Prevent Vimeo blocking plyr.io demo site
|
||||||
referrerPolicy: 'no-referrer',
|
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
|
// Expose for tinkering in the console
|
||||||
@ -79,10 +106,10 @@ import toggleClass from './toggle-class';
|
|||||||
|
|
||||||
function render(type) {
|
function render(type) {
|
||||||
// Remove active classes
|
// Remove active classes
|
||||||
Array.from(buttons).forEach((button) => toggleClass(button.parentElement, 'active', false));
|
Array.from(buttons).forEach((button) => button.parentElement.classList.toggle('active', false));
|
||||||
|
|
||||||
// Set active on parent
|
// Set active on parent
|
||||||
toggleClass(document.querySelector(`[data-source="${type}"]`), 'active', true);
|
document.querySelector(`[data-source="${type}"]`).classList.toggle('active', true);
|
||||||
|
|
||||||
// Show cite
|
// Show cite
|
||||||
Array.from(document.querySelectorAll('.plyr__cite')).forEach((cite) => {
|
Array.from(document.querySelectorAll('.plyr__cite')).forEach((cite) => {
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
// Setup tab focus
|
|
||||||
const container = document.getElementById('container');
|
|
||||||
const tabClassName = 'tab-focus';
|
|
||||||
|
|
||||||
// Remove class on blur
|
|
||||||
document.addEventListener('focusout', (event) => {
|
|
||||||
if (!event.target.classList || container.contains(event.target)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
event.target.classList.remove(tabClassName);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Add classname to tabbed elements
|
|
||||||
document.addEventListener('keydown', (event) => {
|
|
||||||
if (event.keyCode !== 9) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delay the adding of classname until the focus has changed
|
|
||||||
// This event fires before the focusin event
|
|
||||||
setTimeout(() => {
|
|
||||||
const focused = document.activeElement;
|
|
||||||
|
|
||||||
if (!focused || !focused.classList || container.contains(focused)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
focused.classList.add(tabClassName);
|
|
||||||
}, 10);
|
|
||||||
});
|
|
@ -1,5 +0,0 @@
|
|||||||
// Toggle class on an element
|
|
||||||
const toggleClass = (element, className = '', toggle = false) =>
|
|
||||||
element && element.classList[toggle ? 'add' : 'remove'](className);
|
|
||||||
|
|
||||||
export default toggleClass;
|
|
@ -1,9 +1,11 @@
|
|||||||
|
@charset "UTF-8";
|
||||||
|
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
// Plyr.io Demo Page
|
// Plyr.io Demo Page
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
@charset 'UTF-8';
|
|
||||||
|
|
||||||
@import '../../../../src/sass/lib/css-vars';
|
@import '../../../../src/sass/lib/css-vars';
|
||||||
|
|
||||||
$css-vars-use-native: true;
|
$css-vars-use-native: true;
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
|
@charset "UTF-8";
|
||||||
|
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
// Plyr.io Error Page
|
// Plyr.io Error Page
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
@charset 'UTF-8';
|
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
@import '../settings/colors';
|
@import '../settings/colors';
|
||||||
|
@ -7,8 +7,7 @@
|
|||||||
.button__count {
|
.button__count {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
border: 0;
|
border: 0;
|
||||||
border-radius: $border-radius-base;
|
border-radius: $border-radius-medium;
|
||||||
box-shadow: 0 1px 1px rgba(#000, 0.1);
|
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
padding: ($spacing-base * 0.75);
|
padding: ($spacing-base * 0.75);
|
||||||
position: relative;
|
position: relative;
|
||||||
@ -19,66 +18,72 @@
|
|||||||
|
|
||||||
// Buttons
|
// Buttons
|
||||||
.button {
|
.button {
|
||||||
background: $color-button-background;
|
--shadow-color: 0deg 0% 20%;
|
||||||
|
align-items: center;
|
||||||
|
background-color: $color-button-background;
|
||||||
|
background-image: linear-gradient(0deg, transparent, rgba(255, 255, 255, 0.05));
|
||||||
|
border: 1px solid darken($color-button-background, 5);
|
||||||
|
box-shadow: 0 0.8px 1px hsl(var(--shadow-color) / 0.05), 0 1.3px 1.6px -1px hsl(var(--shadow-color) / 0.06),
|
||||||
|
0 2.8px 3.4px -2px hsl(var(--shadow-color) / 0.07);
|
||||||
color: $color-button-text;
|
color: $color-button-text;
|
||||||
|
display: inline-flex;
|
||||||
font-weight: $font-weight-bold;
|
font-weight: $font-weight-bold;
|
||||||
|
gap: 0.25rem;
|
||||||
padding-left: ($spacing-base * 1.25);
|
padding-left: ($spacing-base * 1.25);
|
||||||
padding-right: ($spacing-base * 1.25);
|
padding-right: ($spacing-base * 1.25);
|
||||||
|
text-decoration: none;
|
||||||
|
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
|
||||||
transition: all 0.2s ease;
|
transition: all 0.2s ease;
|
||||||
|
|
||||||
&:hover,
|
&:hover,
|
||||||
&:focus {
|
&:focus {
|
||||||
background: $color-button-background-hover;
|
background: $color-button-background-hover;
|
||||||
|
border-color: darken($color-button-background, 7);
|
||||||
|
|
||||||
// Remove the underline/border
|
// Remove the underline/border
|
||||||
&::after {
|
&::after {
|
||||||
display: none;
|
display: none !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&:hover {
|
|
||||||
box-shadow: 0 2px 2px rgba(#000, 0.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
&:focus {
|
&:focus {
|
||||||
outline: 0;
|
outline: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.tab-focus {
|
&:focus-visible {
|
||||||
@include tab-focus();
|
@include focus-visible($color-button-background);
|
||||||
}
|
}
|
||||||
|
|
||||||
&:active {
|
&:active {
|
||||||
|
box-shadow: none;
|
||||||
top: 1px;
|
top: 1px;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Button group
|
.icon {
|
||||||
.button--with-count {
|
filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.1));
|
||||||
display: inline-flex;
|
|
||||||
|
|
||||||
.button .icon {
|
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Count bubble
|
// Count bubble
|
||||||
.button__count {
|
.button__count {
|
||||||
animation: fadein 0.2s ease;
|
animation: fade-in 0.2s ease;
|
||||||
background: $color-button-count-background;
|
background: $color-button-count-background;
|
||||||
|
border: 1px solid $color-gray-100;
|
||||||
color: $color-button-count-text;
|
color: $color-button-count-text;
|
||||||
margin-left: ($spacing-base * 0.75);
|
margin-left: ($spacing-base * 0.75);
|
||||||
|
|
||||||
&::before {
|
&::before {
|
||||||
border: $arrow-size solid transparent;
|
background-color: $color-button-count-background;
|
||||||
border-left-width: 0;
|
border: inherit;
|
||||||
border-right-color: $color-button-count-background;
|
border-width: 0 0 1px 1px;
|
||||||
content: '';
|
content: '';
|
||||||
height: 0;
|
display: block;
|
||||||
|
height: 8px;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 100%;
|
right: 100%;
|
||||||
top: 50%;
|
top: 50%;
|
||||||
transform: translateY(-50%);
|
transform: translateY(-50%) translateX(50%) translateX(-1px) rotate(45deg);
|
||||||
width: 0;
|
width: 8px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ header {
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
|
|
||||||
h1 span {
|
h1 span {
|
||||||
animation: shrinkHide 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) 2s forwards;
|
animation: shrink-hide 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) 2s forwards;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
font-weight: $font-weight-light;
|
font-weight: $font-weight-light;
|
||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
// Icons
|
// Icons
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
|
|
||||||
|
@use 'sass:math';
|
||||||
|
|
||||||
// Base size icon styles
|
// Base size icon styles
|
||||||
.icon {
|
.icon {
|
||||||
fill: currentColor;
|
fill: currentColor;
|
||||||
@ -19,5 +21,5 @@ label svg {
|
|||||||
|
|
||||||
a .icon,
|
a .icon,
|
||||||
.btn .icon {
|
.btn .icon {
|
||||||
margin-right: ($spacing-base / 2);
|
margin-right: math.div($spacing-base, 4);
|
||||||
}
|
}
|
||||||
|
@ -2,15 +2,9 @@
|
|||||||
// Links
|
// Links
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
|
|
||||||
// Make a <button> look like an <a>
|
.link {
|
||||||
button.faux-link {
|
align-items: center;
|
||||||
@extend a; // stylelint-disable-line
|
border-bottom: 1px dashed currentColor;
|
||||||
@include cancel-button-styles();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Links
|
|
||||||
a {
|
|
||||||
border-bottom: 1px dotted currentColor;
|
|
||||||
color: $color-link;
|
color: $color-link;
|
||||||
position: relative;
|
position: relative;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
@ -38,8 +32,8 @@ a {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&.tab-focus {
|
&:focus-visible {
|
||||||
@include tab-focus();
|
@include focus-visible($color-link);
|
||||||
}
|
}
|
||||||
|
|
||||||
&.no-border::after {
|
&.no-border::after {
|
||||||
|
@ -2,10 +2,14 @@
|
|||||||
// Examples
|
// Examples
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
|
|
||||||
|
@use 'sass:math';
|
||||||
|
|
||||||
// Example players
|
// Example players
|
||||||
.plyr {
|
.plyr {
|
||||||
border-radius: $border-radius-large;
|
--shadow-color: 197deg 32% 65%;
|
||||||
box-shadow: 0 2px 15px rgba(#000, 0.1);
|
border-radius: $border-radius-2x-large;
|
||||||
|
box-shadow: 0 0.5px 0.6px hsl(var(--shadow-color) / 0.36), 0 1.7px 1.9px -0.8px hsl(var(--shadow-color) / 0.36),
|
||||||
|
0 4.3px 4.8px -1.7px hsl(var(--shadow-color) / 0.36), -0.1px 10.6px 11.9px -2.5px hsl(var(--shadow-color) / 0.36);
|
||||||
margin: $spacing-base auto;
|
margin: $spacing-base auto;
|
||||||
|
|
||||||
&.plyr--audio {
|
&.plyr--audio {
|
||||||
@ -15,6 +19,7 @@
|
|||||||
|
|
||||||
.plyr__video-wrapper::after {
|
.plyr__video-wrapper::after {
|
||||||
border: 1px solid rgba(#000, 0.15);
|
border: 1px solid rgba(#000, 0.15);
|
||||||
|
border-bottom-color: rgba(#000, 0.25);
|
||||||
border-radius: inherit;
|
border-radius: inherit;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
content: '';
|
content: '';
|
||||||
@ -31,6 +36,6 @@
|
|||||||
color: $color-gray-500;
|
color: $color-gray-500;
|
||||||
|
|
||||||
.icon {
|
.icon {
|
||||||
margin-right: ceil($spacing-base / 6);
|
margin-right: math.div($spacing-base, 6);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
// Core
|
// Core
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
|
|
||||||
|
@use 'sass:math';
|
||||||
|
|
||||||
html,
|
html,
|
||||||
body {
|
body {
|
||||||
display: flex;
|
display: flex;
|
||||||
@ -35,6 +37,7 @@ main {
|
|||||||
aside {
|
aside {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
|
box-shadow: 0 -1px 0 rgba(0, 0, 0, 0.05);
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
@ -46,7 +49,7 @@ aside {
|
|||||||
|
|
||||||
.icon {
|
.icon {
|
||||||
fill: $color-twitter;
|
fill: $color-twitter;
|
||||||
margin-right: ($spacing-base / 2);
|
margin-right: math.div($spacing-base, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
p {
|
p {
|
||||||
@ -56,8 +59,8 @@ aside {
|
|||||||
a {
|
a {
|
||||||
color: $color-twitter;
|
color: $color-twitter;
|
||||||
|
|
||||||
&.tab-focus {
|
&:focus-visible {
|
||||||
@include tab-focus($color-twitter);
|
@include focus-visible($color-twitter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,23 +3,26 @@
|
|||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
|
|
||||||
// Fade
|
// Fade
|
||||||
@keyframes fadein {
|
@keyframes fade-in {
|
||||||
0% {
|
0% {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
100% {
|
100% {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes shrinkHide {
|
@keyframes shrink-hide {
|
||||||
0% {
|
0% {
|
||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
width: 38px;
|
width: 38px;
|
||||||
}
|
}
|
||||||
|
|
||||||
20% {
|
20% {
|
||||||
width: 45px;
|
width: 45px;
|
||||||
}
|
}
|
||||||
|
|
||||||
100% {
|
100% {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
width: 0;
|
width: 0;
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
@font-face {
|
@font-face {
|
||||||
font-display: swap;
|
font-display: swap;
|
||||||
font-family: 'Gordita';
|
font-family: Gordita;
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
font-weight: $font-weight-light;
|
font-weight: $font-weight-light;
|
||||||
src: url('https://cdn.plyr.io/static/fonts/gordita-light.woff2') format('woff2'),
|
src: url('https://cdn.plyr.io/static/fonts/gordita-light.woff2') format('woff2'),
|
||||||
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
@font-face {
|
@font-face {
|
||||||
font-display: swap;
|
font-display: swap;
|
||||||
font-family: 'Gordita';
|
font-family: Gordita;
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
font-weight: $font-weight-regular;
|
font-weight: $font-weight-regular;
|
||||||
src: url('https://cdn.plyr.io/static/fonts/gordita-regular.woff2') format('woff2'),
|
src: url('https://cdn.plyr.io/static/fonts/gordita-regular.woff2') format('woff2'),
|
||||||
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
@font-face {
|
@font-face {
|
||||||
font-display: swap;
|
font-display: swap;
|
||||||
font-family: 'Gordita';
|
font-family: Gordita;
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
font-weight: $font-weight-medium;
|
font-weight: $font-weight-medium;
|
||||||
src: url('https://cdn.plyr.io/static/fonts/gordita-medium.woff2') format('woff2'),
|
src: url('https://cdn.plyr.io/static/fonts/gordita-medium.woff2') format('woff2'),
|
||||||
@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
@font-face {
|
@font-face {
|
||||||
font-display: swap;
|
font-display: swap;
|
||||||
font-family: 'Gordita';
|
font-family: Gordita;
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
font-weight: $font-weight-bold;
|
font-weight: $font-weight-bold;
|
||||||
src: url('https://cdn.plyr.io/static/fonts/gordita-bold.woff2') format('woff2'),
|
src: url('https://cdn.plyr.io/static/fonts/gordita-bold.woff2') format('woff2'),
|
||||||
@ -40,7 +40,7 @@
|
|||||||
|
|
||||||
@font-face {
|
@font-face {
|
||||||
font-display: swap;
|
font-display: swap;
|
||||||
font-family: 'Gordita';
|
font-family: Gordita;
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
font-weight: $font-weight-black;
|
font-weight: $font-weight-black;
|
||||||
src: url('https://cdn.plyr.io/static/fonts/gordita-black.woff2') format('woff2'),
|
src: url('https://cdn.plyr.io/static/fonts/gordita-black.woff2') format('woff2'),
|
||||||
|
@ -2,37 +2,20 @@
|
|||||||
// Mixins
|
// Mixins
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
|
|
||||||
// Convert a <button> into an <a>
|
@use 'sass:math';
|
||||||
// ---------------------------------------
|
|
||||||
@mixin cancel-button-styles() {
|
|
||||||
background: transparent;
|
|
||||||
border: 0;
|
|
||||||
border-radius: 0;
|
|
||||||
cursor: pointer;
|
|
||||||
font: inherit;
|
|
||||||
line-height: $line-height-base;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
position: relative;
|
|
||||||
text-align: inherit;
|
|
||||||
text-shadow: inherit;
|
|
||||||
-moz-user-select: text; // stylelint-disable-line
|
|
||||||
vertical-align: baseline;
|
|
||||||
width: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Nicer focus styles
|
// Nicer focus styles
|
||||||
// ---------------------------------------
|
// ---------------------------------------
|
||||||
@mixin tab-focus($color: $tab-focus-default-color) {
|
@mixin focus-visible($color: $focus-default-color) {
|
||||||
box-shadow: 0 0 0 3px rgba($color, 0.35);
|
outline: 2px dashed $color;
|
||||||
outline: 0;
|
outline-offset: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use rems for font sizing
|
// Use rems for font sizing
|
||||||
// Leave <body> at 100%/16px
|
// Leave <body> at 100%/16px
|
||||||
// ---------------------------------------
|
// ---------------------------------------
|
||||||
@function calculate-rem($size) {
|
@function calculate-rem($size) {
|
||||||
$rem: $size / 16;
|
$rem: math.div($size, 16);
|
||||||
@return #{$rem}rem;
|
@return #{$rem}rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
17
demo/src/sass/lib/normalize.scss
vendored
17
demo/src/sass/lib/normalize.scss
vendored
@ -11,8 +11,7 @@
|
|||||||
|
|
||||||
html {
|
html {
|
||||||
line-height: 1.15; /* 1 */
|
line-height: 1.15; /* 1 */
|
||||||
-ms-text-size-adjust: 100%; /* 2 */
|
text-size-adjust: 100%; /* 2 */
|
||||||
-webkit-text-size-adjust: 100%; /* 2 */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sections
|
/* Sections
|
||||||
@ -89,7 +88,7 @@ hr {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
pre {
|
pre {
|
||||||
font-family: monospace, monospace; /* 1 */
|
font-family: monospace; /* 1 */
|
||||||
font-size: 1em; /* 2 */
|
font-size: 1em; /* 2 */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,7 +102,7 @@ pre {
|
|||||||
|
|
||||||
a {
|
a {
|
||||||
background-color: transparent; /* 1 */
|
background-color: transparent; /* 1 */
|
||||||
-webkit-text-decoration-skip: objects; /* 2 */
|
text-decoration-skip: objects; /* 2 */
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -112,7 +111,7 @@ a {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
abbr[title] {
|
abbr[title] {
|
||||||
border-bottom: none; /* 1 */
|
border-bottom: 0; /* 1 */
|
||||||
text-decoration: underline; /* 2 */
|
text-decoration: underline; /* 2 */
|
||||||
text-decoration: underline dotted; /* 2 */
|
text-decoration: underline dotted; /* 2 */
|
||||||
}
|
}
|
||||||
@ -281,7 +280,7 @@ button,
|
|||||||
html [type='button'],
|
html [type='button'],
|
||||||
[type='reset'],
|
[type='reset'],
|
||||||
[type='submit'] {
|
[type='submit'] {
|
||||||
-webkit-appearance: button; /* 2 */
|
appearance: button; /* 2 */
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -375,7 +374,7 @@ textarea {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
[type='search'] {
|
[type='search'] {
|
||||||
-webkit-appearance: textfield; /* 1 */
|
appearance: textfield; /* 1 */
|
||||||
outline-offset: -2px; /* 2 */
|
outline-offset: -2px; /* 2 */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -385,7 +384,7 @@ textarea {
|
|||||||
|
|
||||||
[type='search']::-webkit-search-cancel-button,
|
[type='search']::-webkit-search-cancel-button,
|
||||||
[type='search']::-webkit-search-decoration {
|
[type='search']::-webkit-search-decoration {
|
||||||
-webkit-appearance: none;
|
appearance: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -394,7 +393,7 @@ textarea {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
::-webkit-file-upload-button {
|
::-webkit-file-upload-button {
|
||||||
-webkit-appearance: button; /* 1 */
|
appearance: button; /* 1 */
|
||||||
font: inherit; /* 2 */
|
font: inherit; /* 2 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,3 +9,7 @@
|
|||||||
*::before {
|
*::before {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
all: unset;
|
||||||
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
|
|
||||||
// Grayscale
|
// Grayscale
|
||||||
$color-gray-900: hsl(210, 15%, 16%);
|
$color-gray-900: hsl(210deg 15% 16%);
|
||||||
$color-gray-800: lighten($color-gray-900, 9%);
|
$color-gray-800: lighten($color-gray-900, 9%);
|
||||||
$color-gray-700: lighten($color-gray-800, 9%);
|
$color-gray-700: lighten($color-gray-800, 9%);
|
||||||
$color-gray-600: lighten($color-gray-700, 9%);
|
$color-gray-600: lighten($color-gray-700, 9%);
|
||||||
@ -15,7 +15,7 @@ $color-gray-100: lighten($color-gray-200, 9%);
|
|||||||
$color-gray-50: lighten($color-gray-100, 9%);
|
$color-gray-50: lighten($color-gray-100, 9%);
|
||||||
|
|
||||||
// Branding
|
// Branding
|
||||||
$color-brand-primary: hsl(198, 100%, 50%);
|
$color-brand-primary: hsl(198deg 100% 50%);
|
||||||
|
|
||||||
// Text
|
// Text
|
||||||
$color-text: $color-gray-700;
|
$color-text: $color-gray-700;
|
||||||
@ -28,15 +28,15 @@ $color-twitter: #4baaf4;
|
|||||||
$color-link: $color-brand-primary;
|
$color-link: $color-brand-primary;
|
||||||
|
|
||||||
// Background
|
// Background
|
||||||
$color-background-from: hsl(198, 100%, 94%);
|
$color-background-from: hsl(198deg 100% 94%);
|
||||||
$color-background-to: hsl(198, 100%, 98%);
|
$color-background-to: hsl(198deg 100% 98%);
|
||||||
|
|
||||||
// Buttons
|
// Buttons
|
||||||
$color-button-background: $color-brand-primary;
|
$color-button-background: $color-brand-primary;
|
||||||
$color-button-text: #fff;
|
$color-button-text: #fff;
|
||||||
$color-button-background-hover: hsl(198, 100%, 55%);
|
$color-button-background-hover: hsl(198deg 100% 55%);
|
||||||
$color-button-count-background: #fff;
|
$color-button-count-background: #fff;
|
||||||
$color-button-count-text: $color-gray-600;
|
$color-button-count-text: $color-gray-600;
|
||||||
|
|
||||||
// Focus
|
// Focus
|
||||||
$tab-focus-default-color: #fff;
|
$focus-default-color: $color-brand-primary;
|
||||||
|
@ -6,8 +6,9 @@
|
|||||||
$arrow-size: 5px;
|
$arrow-size: 5px;
|
||||||
|
|
||||||
// Radii
|
// Radii
|
||||||
$border-radius-base: 4px;
|
$border-radius-small: 4px;
|
||||||
$border-radius-large: 8px;
|
$border-radius-medium: 6px;
|
||||||
|
$border-radius-2x-large: 12px;
|
||||||
|
|
||||||
// Background
|
// Background
|
||||||
$page-background: linear-gradient(to left top, $color-background-from, $color-background-to);
|
$page-background: linear-gradient(to left top, $color-background-from, $color-background-to);
|
||||||
|
@ -4,18 +4,14 @@
|
|||||||
|
|
||||||
$font-sans-serif: 'Gordita', 'Avenir', 'Helvetica Neue', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji',
|
$font-sans-serif: 'Gordita', 'Avenir', 'Helvetica Neue', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji',
|
||||||
'Segoe UI Symbol';
|
'Segoe UI Symbol';
|
||||||
|
|
||||||
$font-size-base: 15;
|
$font-size-base: 15;
|
||||||
$font-size-small: 13;
|
$font-size-small: 13;
|
||||||
$font-size-large: 18;
|
$font-size-large: 18;
|
||||||
$font-size-h1: 64;
|
$font-size-h1: 64;
|
||||||
|
|
||||||
$font-weight-light: 300;
|
$font-weight-light: 300;
|
||||||
$font-weight-regular: 400;
|
$font-weight-regular: 400;
|
||||||
$font-weight-medium: 500;
|
$font-weight-medium: 500;
|
||||||
$font-weight-bold: 600;
|
$font-weight-bold: 600;
|
||||||
$font-weight-black: 900;
|
$font-weight-black: 900;
|
||||||
|
|
||||||
$line-height-base: 1.75;
|
$line-height-base: 1.75;
|
||||||
|
|
||||||
$letter-spacing-headings: -0.025em;
|
$letter-spacing-headings: -0.025em;
|
||||||
|
@ -8,8 +8,9 @@ html {
|
|||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
@include font-smoothing();
|
@include font-smoothing;
|
||||||
@include font-size($font-size-base);
|
@include font-size($font-size-base);
|
||||||
|
|
||||||
color: $color-text;
|
color: $color-text;
|
||||||
font-family: $font-sans-serif;
|
font-family: $font-sans-serif;
|
||||||
font-weight: $font-weight-medium;
|
font-weight: $font-weight-medium;
|
||||||
@ -30,5 +31,6 @@ small {
|
|||||||
|
|
||||||
small {
|
small {
|
||||||
@include font-size($font-size-small);
|
@include font-size($font-size-small);
|
||||||
|
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
@include font-size($font-size-h1);
|
@include font-size($font-size-h1);
|
||||||
|
|
||||||
color: $color-headings;
|
color: $color-headings;
|
||||||
font-weight: $font-weight-bold;
|
font-weight: $font-weight-bold;
|
||||||
letter-spacing: $letter-spacing-headings;
|
letter-spacing: $letter-spacing-headings;
|
||||||
|
4
demo/src/sass/utilities/focus.scss
Normal file
4
demo/src/sass/utilities/focus.scss
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
*:focus-visible {
|
||||||
|
outline: 2px dotted $color-brand-primary;
|
||||||
|
outline-offset: 2px;
|
||||||
|
}
|
72
package.json
72
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "plyr",
|
"name": "plyr",
|
||||||
"version": "3.6.8",
|
"version": "3.7.8",
|
||||||
"description": "A simple, accessible and customizable HTML5, YouTube and Vimeo media player",
|
"description": "A simple, accessible and customizable HTML5, YouTube and Vimeo media player",
|
||||||
"homepage": "https://plyr.io",
|
"homepage": "https://plyr.io",
|
||||||
"author": "Sam Potts <sam@potts.es>",
|
"author": "Sam Potts <sam@potts.es>",
|
||||||
@ -31,66 +31,68 @@
|
|||||||
"browserslist": "> 1%",
|
"browserslist": "> 1%",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "gulp build",
|
"build": "gulp build",
|
||||||
"lint": "eslint src/js && npm run-script remark",
|
"lint": "eslint src/js && npm run remark && stylelint **/*.scss",
|
||||||
"lint:fix": "eslint --fix src/js",
|
"lint:fix": "eslint --fix src/js && stylelint **/*.scss --fix",
|
||||||
"remark": "remark -f --use 'validate-links=repository:\"sampotts/plyr\"' '{,!(node_modules),.?**/}*.md'",
|
"remark": "remark -f --use 'validate-links=repository:\"sampotts/plyr\"' '{,!(node_modules),.?**/}*.md'",
|
||||||
"deploy": "yarn lint && gulp version && gulp build && gulp deploy",
|
"deploy": "npm run lint && gulp version && gulp build && gulp deploy",
|
||||||
"format": "prettier --write \"./{src,demo/src}/**/*.{js,scss}\"",
|
"format": "prettier --write \"./{src,demo/src}/**/*.{js,scss}\"",
|
||||||
|
"spellcheck": "cspell \"**/*.{js,md,scss,json}\" --no-must-find-files",
|
||||||
"start": "gulp"
|
"start": "gulp"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@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",
|
"@sampotts/eslint-config": "1.1.7",
|
||||||
"autoprefixer": "^10.2.5",
|
"autoprefixer": "^10.4.13",
|
||||||
"aws-sdk": "^2.888.0",
|
"aws-sdk": "^2.1256.0",
|
||||||
"@babel/core": "^7.13.15",
|
|
||||||
"@babel/preset-env": "^7.13.15",
|
|
||||||
"@babel/plugin-proposal-class-properties": "^7.13.0",
|
|
||||||
"babel-eslint": "^10.1.0",
|
"babel-eslint": "^10.1.0",
|
||||||
"browser-sync": "^2.26.14",
|
"browser-sync": "^2.27.10",
|
||||||
"colorette": "1.2.2",
|
"colorette": "2.0.19",
|
||||||
"cssnano": "^5.0.1",
|
"cspell": "^6.14.2",
|
||||||
"del": "^6.0.0",
|
"cssnano": "^5.1.14",
|
||||||
|
"del": "^6.1.1",
|
||||||
"eslint": "^7.23.0",
|
"eslint": "^7.23.0",
|
||||||
"fancy-log": "^1.3.3",
|
"fancy-log": "^2.0.0",
|
||||||
"git-branch": "^2.0.1",
|
"git-branch": "^2.0.1",
|
||||||
"gulp": "^4.0.2",
|
"gulp": "^4.0.2",
|
||||||
"gulp-awspublish": "^4.1.2",
|
"gulp-awspublish": "^6.0.2",
|
||||||
"gulp-better-rollup": "^4.0.1",
|
"gulp-better-rollup": "^4.0.1",
|
||||||
"gulp-filter": "^6.0.0",
|
"gulp-filter": "^7.0.0",
|
||||||
"gulp-header": "^2.0.9",
|
"gulp-header": "^2.0.9",
|
||||||
"gulp-hub": "^4.2.0",
|
"gulp-hub": "^4.2.0",
|
||||||
"gulp-if": "^3.0.0",
|
"gulp-if": "^3.0.0",
|
||||||
"gulp-imagemin": "^7.1.0",
|
"gulp-imagemin": "^7.1.0",
|
||||||
"gulp-open": "^3.0.1",
|
"gulp-open": "^3.0.1",
|
||||||
"gulp-plumber": "^1.2.1",
|
"gulp-plumber": "^1.2.1",
|
||||||
"gulp-postcss": "^9.0.0",
|
"gulp-postcss": "^9.0.1",
|
||||||
"gulp-rename": "^2.0.0",
|
"gulp-rename": "^2.0.0",
|
||||||
"gulp-replace": "^1.0.0",
|
"gulp-replace": "^1.1.3",
|
||||||
"gulp-sass": "^4.1.0",
|
"gulp-sass": "^5.1.0",
|
||||||
"gulp-size": "^3.0.0",
|
"gulp-size": "^4.0.1",
|
||||||
"gulp-sourcemaps": "^3.0.0",
|
"gulp-sourcemaps": "^3.0.0",
|
||||||
"gulp-svgstore": "^7.0.1",
|
"gulp-svgstore": "^9.0.0",
|
||||||
"gulp-terser": "^2.0.1",
|
"gulp-terser": "^2.1.0",
|
||||||
"postcss": "^8.2.10",
|
"postcss": "^8.4.19",
|
||||||
"postcss-custom-properties": "^11.0.0",
|
"postcss-custom-properties": "^12.1.9",
|
||||||
|
"postcss-scss": "^4.0.5",
|
||||||
"prettier-eslint": "^12.0.0",
|
"prettier-eslint": "^12.0.0",
|
||||||
"prettier-stylelint": "^0.4.2",
|
"prettier-stylelint": "^0.4.2",
|
||||||
"remark-cli": "^9.0.0",
|
"remark-cli": "^11.0.0",
|
||||||
"remark-validate-links": "^10.0.4",
|
"remark-validate-links": "^12.1.0",
|
||||||
"rollup": "^2.45.2",
|
"rollup": "^3.3.0",
|
||||||
"rollup-plugin-babel": "^4.4.0",
|
"rollup-plugin-babel": "^4.4.0",
|
||||||
"rollup-plugin-commonjs": "^10.1.0",
|
"rollup-plugin-commonjs": "^10.1.0",
|
||||||
"rollup-plugin-node-resolve": "^5.2.0",
|
"rollup-plugin-node-resolve": "^5.2.0",
|
||||||
"stylelint": "^13.12.0",
|
"sass": "^1.56.1",
|
||||||
"stylelint-config-prettier": "^8.0.2",
|
"stylelint": "^14.15.0",
|
||||||
"stylelint-config-recommended": "^4.0.0",
|
"stylelint-config-prettier": "^9.0.4",
|
||||||
"stylelint-config-sass-guidelines": "^8.0.0",
|
"stylelint-config-sass-guidelines": "^9.0.1",
|
||||||
"stylelint-order": "^4.1.0",
|
"stylelint-selector-bem-pattern": "^2.1.1"
|
||||||
"stylelint-scss": "^3.19.0",
|
|
||||||
"stylelint-selector-bem-pattern": "^2.1.0"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"core-js": "^3.10.1",
|
"core-js": "^3.26.1",
|
||||||
"custom-event-polyfill": "^1.0.7",
|
"custom-event-polyfill": "^1.0.7",
|
||||||
"loadjs": "^4.2.0",
|
"loadjs": "^4.2.0",
|
||||||
"rangetouch": "^2.0.1",
|
"rangetouch": "^2.0.1",
|
||||||
|
@ -12,7 +12,9 @@
|
|||||||
|
|
||||||
// Linting
|
// Linting
|
||||||
"stylelint.enable": true,
|
"stylelint.enable": true,
|
||||||
|
"stylelint.validate": ["css", "scss"],
|
||||||
"css.validate": false,
|
"css.validate": false,
|
||||||
|
"less.validate": false,
|
||||||
"scss.validate": false,
|
"scss.validate": false,
|
||||||
"javascript.validate.enable": false,
|
"javascript.validate.enable": false,
|
||||||
|
|
||||||
|
13882
pnpm-lock.yaml
generated
Normal file
13882
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -47,6 +47,7 @@ const captions = {
|
|||||||
// Inject the container
|
// Inject the container
|
||||||
if (!is.element(this.elements.captions)) {
|
if (!is.element(this.elements.captions)) {
|
||||||
this.elements.captions = createElement('div', getAttributesFromSelector(this.config.selectors.captions));
|
this.elements.captions = createElement('div', getAttributesFromSelector(this.config.selectors.captions));
|
||||||
|
this.elements.captions.setAttribute('dir', 'auto');
|
||||||
|
|
||||||
insertAfter(this.elements.captions, this.elements.wrapper);
|
insertAfter(this.elements.captions, this.elements.wrapper);
|
||||||
}
|
}
|
||||||
@ -154,7 +155,9 @@ const captions = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Enable or disable captions based on track length
|
// Enable or disable captions based on track length
|
||||||
|
if (this.elements) {
|
||||||
toggleClass(this.elements.container, this.config.classNames.captions.enabled, !is.empty(tracks));
|
toggleClass(this.elements.container, this.config.classNames.captions.enabled, !is.empty(tracks));
|
||||||
|
}
|
||||||
|
|
||||||
// Update available languages in list
|
// Update available languages in list
|
||||||
if (
|
if (
|
||||||
|
@ -18,8 +18,7 @@ const defaults = {
|
|||||||
// Only allow one media playing at once (vimeo only)
|
// Only allow one media playing at once (vimeo only)
|
||||||
autopause: true,
|
autopause: true,
|
||||||
|
|
||||||
// Allow inline playback on iOS (this effects YouTube/Vimeo - HTML5 requires the attribute present)
|
// Allow inline playback on iOS
|
||||||
// TODO: Remove iosNative fullscreen option in favour of this (logic needs work)
|
|
||||||
playsinline: true,
|
playsinline: true,
|
||||||
|
|
||||||
// Default time to skip when rewind/fast forward
|
// Default time to skip when rewind/fast forward
|
||||||
@ -61,7 +60,7 @@ const defaults = {
|
|||||||
// Sprite (for icons)
|
// Sprite (for icons)
|
||||||
loadSprite: true,
|
loadSprite: true,
|
||||||
iconPrefix: 'plyr',
|
iconPrefix: 'plyr',
|
||||||
iconUrl: 'https://cdn.plyr.io/3.6.8/plyr.svg',
|
iconUrl: 'https://cdn.plyr.io/3.7.8/plyr.svg',
|
||||||
|
|
||||||
// Blank video (used to prevent errors on source change)
|
// Blank video (used to prevent errors on source change)
|
||||||
blankVideo: 'https://cdn.plyr.io/static/blank.mp4',
|
blankVideo: 'https://cdn.plyr.io/static/blank.mp4',
|
||||||
@ -350,9 +349,9 @@ const defaults = {
|
|||||||
hover: 'plyr--hover',
|
hover: 'plyr--hover',
|
||||||
tooltip: 'plyr__tooltip',
|
tooltip: 'plyr__tooltip',
|
||||||
cues: 'plyr__cues',
|
cues: 'plyr__cues',
|
||||||
|
marker: 'plyr__progress__marker',
|
||||||
hidden: 'plyr__sr-only',
|
hidden: 'plyr__sr-only',
|
||||||
hideControls: 'plyr--hide-controls',
|
hideControls: 'plyr--hide-controls',
|
||||||
isIos: 'plyr--is-ios',
|
|
||||||
isTouch: 'plyr--is-touch',
|
isTouch: 'plyr--is-touch',
|
||||||
uiSupported: 'plyr--full-ui',
|
uiSupported: 'plyr--full-ui',
|
||||||
noTransition: 'plyr--no-transition',
|
noTransition: 'plyr--no-transition',
|
||||||
@ -380,7 +379,6 @@ const defaults = {
|
|||||||
supported: 'plyr--airplay-supported',
|
supported: 'plyr--airplay-supported',
|
||||||
active: 'plyr--airplay-active',
|
active: 'plyr--airplay-active',
|
||||||
},
|
},
|
||||||
tabFocus: 'plyr__tab-focus',
|
|
||||||
previewThumbnails: {
|
previewThumbnails: {
|
||||||
// Tooltip thumbs
|
// Tooltip thumbs
|
||||||
thumbContainer: 'plyr__preview-thumb',
|
thumbContainer: 'plyr__preview-thumb',
|
||||||
@ -398,6 +396,7 @@ const defaults = {
|
|||||||
embed: {
|
embed: {
|
||||||
provider: 'data-plyr-provider',
|
provider: 'data-plyr-provider',
|
||||||
id: 'data-plyr-embed-id',
|
id: 'data-plyr-embed-id',
|
||||||
|
hash: 'data-plyr-embed-hash',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -440,6 +439,20 @@ const defaults = {
|
|||||||
customControls: true,
|
customControls: true,
|
||||||
noCookie: false, // Whether to use an alternative version of YouTube without cookies
|
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;
|
export default defaults;
|
||||||
|
156
src/js/controls.js
vendored
156
src/js/controls.js
vendored
@ -38,7 +38,8 @@ const controls = {
|
|||||||
// Get icon URL
|
// Get icon URL
|
||||||
getIconUrl() {
|
getIconUrl() {
|
||||||
const url = new URL(this.config.iconUrl, window.location);
|
const url = new URL(this.config.iconUrl, window.location);
|
||||||
const cors = url.host !== window.location.host || (browser.isIE && !window.svg4everybody);
|
const host = window.location.host ? window.location.host : window.top.location.host;
|
||||||
|
const cors = url.host !== host || (browser.isIE && !window.svg4everybody);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
url: this.config.iconUrl,
|
url: this.config.iconUrl,
|
||||||
@ -382,6 +383,7 @@ const controls = {
|
|||||||
extend(attributes, {
|
extend(attributes, {
|
||||||
class: `${attributes.class ? attributes.class : ''} ${this.config.classNames.display.time} `.trim(),
|
class: `${attributes.class ? attributes.class : ''} ${this.config.classNames.display.time} `.trim(),
|
||||||
'aria-label': i18n.get(type, this.config),
|
'aria-label': i18n.get(type, this.config),
|
||||||
|
role: 'timer',
|
||||||
}),
|
}),
|
||||||
'00:00',
|
'00:00',
|
||||||
);
|
);
|
||||||
@ -403,7 +405,7 @@ const controls = {
|
|||||||
'keydown keyup',
|
'keydown keyup',
|
||||||
(event) => {
|
(event) => {
|
||||||
// We only care about space and ⬆️ ⬇️️ ➡️
|
// We only care about space and ⬆️ ⬇️️ ➡️
|
||||||
if (![32, 38, 39, 40].includes(event.which)) {
|
if (![' ', 'ArrowUp', 'ArrowDown', 'ArrowRight'].includes(event.key)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -419,13 +421,13 @@ const controls = {
|
|||||||
const isRadioButton = matches(menuItem, '[role="menuitemradio"]');
|
const isRadioButton = matches(menuItem, '[role="menuitemradio"]');
|
||||||
|
|
||||||
// Show the respective menu
|
// Show the respective menu
|
||||||
if (!isRadioButton && [32, 39].includes(event.which)) {
|
if (!isRadioButton && [' ', 'ArrowRight'].includes(event.key)) {
|
||||||
controls.showMenuPanel.call(this, type, true);
|
controls.showMenuPanel.call(this, type, true);
|
||||||
} else {
|
} else {
|
||||||
let target;
|
let target;
|
||||||
|
|
||||||
if (event.which !== 32) {
|
if (event.key !== ' ') {
|
||||||
if (event.which === 40 || (isRadioButton && event.which === 39)) {
|
if (event.key === 'ArrowDown' || (isRadioButton && event.key === 'ArrowRight')) {
|
||||||
target = menuItem.nextElementSibling;
|
target = menuItem.nextElementSibling;
|
||||||
|
|
||||||
if (!is.element(target)) {
|
if (!is.element(target)) {
|
||||||
@ -449,9 +451,7 @@ const controls = {
|
|||||||
// Enter will fire a `click` event but we still need to manage focus
|
// 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
|
// So we bind to keyup which fires after and set focus here
|
||||||
on.call(this, menuItem, 'keyup', (event) => {
|
on.call(this, menuItem, 'keyup', (event) => {
|
||||||
if (event.which !== 13) {
|
if (event.key !== 'Return') return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
controls.focusFirstMenuItem.call(this, null, true);
|
controls.focusFirstMenuItem.call(this, null, true);
|
||||||
});
|
});
|
||||||
@ -483,7 +483,7 @@ const controls = {
|
|||||||
|
|
||||||
menuItem.appendChild(flex);
|
menuItem.appendChild(flex);
|
||||||
|
|
||||||
// Replicate radio button behaviour
|
// Replicate radio button behavior
|
||||||
Object.defineProperty(menuItem, 'checked', {
|
Object.defineProperty(menuItem, 'checked', {
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
get() {
|
get() {
|
||||||
@ -505,7 +505,7 @@ const controls = {
|
|||||||
menuItem,
|
menuItem,
|
||||||
'click keyup',
|
'click keyup',
|
||||||
(event) => {
|
(event) => {
|
||||||
if (is.keyboardEvent(event) && event.which !== 32) {
|
if (is.keyboardEvent(event) && event.key !== ' ') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -677,7 +677,7 @@ const controls = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// WebKit only
|
// WebKit only
|
||||||
if (!browser.isWebkit) {
|
if (!browser.isWebKit && !browser.isIPadOS) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -697,8 +697,9 @@ const controls = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const tipElement = this.elements.display.seekTooltip;
|
||||||
const visible = `${this.config.classNames.tooltip}--visible`;
|
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
|
// Hide on touch
|
||||||
if (this.touch) {
|
if (this.touch) {
|
||||||
@ -712,8 +713,8 @@ const controls = {
|
|||||||
|
|
||||||
if (is.event(event)) {
|
if (is.event(event)) {
|
||||||
percent = (100 / clientRect.width) * (event.pageX - clientRect.left);
|
percent = (100 / clientRect.width) * (event.pageX - clientRect.left);
|
||||||
} else if (hasClass(this.elements.display.seekTooltip, visible)) {
|
} else if (hasClass(tipElement, visible)) {
|
||||||
percent = parseFloat(this.elements.display.seekTooltip.style.left, 10);
|
percent = parseFloat(tipElement.style.left, 10);
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -725,11 +726,21 @@ const controls = {
|
|||||||
percent = 100;
|
percent = 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const time = (this.duration / 100) * percent;
|
||||||
|
|
||||||
// Display the time a click would seek to
|
// 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
|
// Set position
|
||||||
this.elements.display.seekTooltip.style.left = `${percent}%`;
|
tipElement.style.left = `${percent}%`;
|
||||||
|
|
||||||
// Show/hide the tooltip
|
// Show/hide the tooltip
|
||||||
// If the event is a moues in/out and percentage is inside bounds
|
// If the event is a moues in/out and percentage is inside bounds
|
||||||
@ -795,6 +806,10 @@ const controls = {
|
|||||||
controls.updateTimeDisplay.call(this, this.elements.display.duration, this.duration);
|
controls.updateTimeDisplay.call(this, this.elements.display.duration, this.duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.config.markers.enabled) {
|
||||||
|
controls.setMarkers.call(this);
|
||||||
|
}
|
||||||
|
|
||||||
// Update the tooltip (if visible)
|
// Update the tooltip (if visible)
|
||||||
controls.updateSeekTooltip.call(this);
|
controls.updateSeekTooltip.call(this);
|
||||||
},
|
},
|
||||||
@ -1091,7 +1106,7 @@ const controls = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// Focus the first menu item in a given (or visible) menu
|
// Focus the first menu item in a given (or visible) menu
|
||||||
focusFirstMenuItem(pane, tabFocus = false) {
|
focusFirstMenuItem(pane, focusVisible = false) {
|
||||||
if (this.elements.settings.popup.hidden) {
|
if (this.elements.settings.popup.hidden) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1104,7 +1119,7 @@ const controls = {
|
|||||||
|
|
||||||
const firstItem = target.querySelector('[role^="menuitem"]');
|
const firstItem = target.querySelector('[role^="menuitem"]');
|
||||||
|
|
||||||
setFocus.call(this, firstItem, tabFocus);
|
setFocus.call(this, firstItem, focusVisible);
|
||||||
},
|
},
|
||||||
|
|
||||||
// Show/hide menu
|
// Show/hide menu
|
||||||
@ -1123,7 +1138,7 @@ const controls = {
|
|||||||
|
|
||||||
if (is.boolean(input)) {
|
if (is.boolean(input)) {
|
||||||
show = input;
|
show = input;
|
||||||
} else if (is.keyboardEvent(input) && input.which === 27) {
|
} else if (is.keyboardEvent(input) && input.key === 'Escape') {
|
||||||
show = false;
|
show = false;
|
||||||
} else if (is.event(input)) {
|
} else if (is.event(input)) {
|
||||||
// If Plyr is in a shadowDOM, the event target is set to the component, instead of the
|
// If Plyr is in a shadowDOM, the event target is set to the component, instead of the
|
||||||
@ -1181,7 +1196,7 @@ const controls = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// Show a panel in the menu
|
// Show a panel in the menu
|
||||||
showMenuPanel(type = '', tabFocus = false) {
|
showMenuPanel(type = '', focusVisible = false) {
|
||||||
const target = this.elements.container.querySelector(`#plyr-settings-${this.id}-${type}`);
|
const target = this.elements.container.querySelector(`#plyr-settings-${this.id}-${type}`);
|
||||||
|
|
||||||
// Nothing to show, bail
|
// Nothing to show, bail
|
||||||
@ -1232,7 +1247,7 @@ const controls = {
|
|||||||
toggleHidden(target, false);
|
toggleHidden(target, false);
|
||||||
|
|
||||||
// Focus the first item
|
// Focus the first item
|
||||||
controls.focusFirstMenuItem.call(this, target, tabFocus);
|
controls.focusFirstMenuItem.call(this, target, focusVisible);
|
||||||
},
|
},
|
||||||
|
|
||||||
// Set the download URL
|
// Set the download URL
|
||||||
@ -1371,7 +1386,7 @@ const controls = {
|
|||||||
// Volume range control
|
// Volume range control
|
||||||
// Ignored on iOS as it's handled globally
|
// Ignored on iOS as it's handled globally
|
||||||
// https://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/Using_HTML5_Audio_Video/Device-SpecificConsiderations/Device-SpecificConsiderations.html
|
// https://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/Using_HTML5_Audio_Video/Device-SpecificConsiderations/Device-SpecificConsiderations.html
|
||||||
if (control === 'volume' && !browser.isIos) {
|
if (control === 'volume' && !browser.isIos && !browser.isIPadOS) {
|
||||||
// Set the attributes
|
// Set the attributes
|
||||||
const attributes = {
|
const attributes = {
|
||||||
max: 1,
|
max: 1,
|
||||||
@ -1511,10 +1526,7 @@ const controls = {
|
|||||||
pane,
|
pane,
|
||||||
'keydown',
|
'keydown',
|
||||||
(event) => {
|
(event) => {
|
||||||
// We only care about <-
|
if (event.key !== 'ArrowLeft') return;
|
||||||
if (event.which !== 37) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Prevent seek
|
// Prevent seek
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@ -1704,13 +1716,17 @@ const controls = {
|
|||||||
if (!is.empty(this.elements.buttons)) {
|
if (!is.empty(this.elements.buttons)) {
|
||||||
const addProperty = (button) => {
|
const addProperty = (button) => {
|
||||||
const className = this.config.classNames.controlPressed;
|
const className = this.config.classNames.controlPressed;
|
||||||
|
button.setAttribute('aria-pressed', 'false');
|
||||||
|
|
||||||
Object.defineProperty(button, 'pressed', {
|
Object.defineProperty(button, 'pressed', {
|
||||||
|
configurable: true,
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
get() {
|
get() {
|
||||||
return hasClass(button, className);
|
return hasClass(button, className);
|
||||||
},
|
},
|
||||||
set(pressed = false) {
|
set(pressed = false) {
|
||||||
toggleClass(button, className, pressed);
|
toggleClass(button, className, pressed);
|
||||||
|
button.setAttribute('aria-pressed', pressed ? 'true' : 'false');
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -1744,6 +1760,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;
|
export default controls;
|
||||||
|
@ -57,12 +57,10 @@ class Fullscreen {
|
|||||||
|
|
||||||
// Update the UI
|
// Update the UI
|
||||||
this.update();
|
this.update();
|
||||||
|
|
||||||
// this.toggle = this.toggle.bind(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine if native supported
|
// Determine if native supported
|
||||||
static get native() {
|
static get nativeSupported() {
|
||||||
return !!(
|
return !!(
|
||||||
document.fullscreenEnabled ||
|
document.fullscreenEnabled ||
|
||||||
document.webkitFullscreenEnabled ||
|
document.webkitFullscreenEnabled ||
|
||||||
@ -72,16 +70,14 @@ class Fullscreen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If we're actually using native
|
// If we're actually using native
|
||||||
get usingNative() {
|
get useNative() {
|
||||||
return Fullscreen.native && !this.forceFallback;
|
return Fullscreen.nativeSupported && !this.forceFallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the prefix for handlers
|
// Get the prefix for handlers
|
||||||
static get prefix() {
|
static get prefix() {
|
||||||
// No prefix
|
// No prefix
|
||||||
if (is.function(document.exitFullscreen)) {
|
if (is.function(document.exitFullscreen)) return '';
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check for fullscreen support by vendor prefix
|
// Check for fullscreen support by vendor prefix
|
||||||
let value = '';
|
let value = '';
|
||||||
@ -103,28 +99,36 @@ class Fullscreen {
|
|||||||
return this.prefix === 'moz' ? 'FullScreen' : 'Fullscreen';
|
return this.prefix === 'moz' ? 'FullScreen' : 'Fullscreen';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine if fullscreen is enabled
|
// Determine if fullscreen is supported
|
||||||
get enabled() {
|
get supported() {
|
||||||
return (
|
return [
|
||||||
(Fullscreen.native || this.player.config.fullscreen.fallback) &&
|
// Fullscreen is enabled in config
|
||||||
this.player.config.fullscreen.enabled &&
|
this.player.config.fullscreen.enabled,
|
||||||
this.player.supported.ui &&
|
// Must be a video
|
||||||
this.player.isVideo
|
this.player.isVideo,
|
||||||
);
|
// Either native is supported or fallback enabled
|
||||||
|
Fullscreen.nativeSupported || this.player.config.fullscreen.fallback,
|
||||||
|
// YouTube has no way to trigger fullscreen, so on devices with no native support, playsinline
|
||||||
|
// must be enabled and iosNative fullscreen must be disabled to offer the fullscreen fallback
|
||||||
|
!this.player.isYouTube ||
|
||||||
|
Fullscreen.nativeSupported ||
|
||||||
|
!browser.isIos ||
|
||||||
|
(this.player.config.playsinline && !this.player.config.fullscreen.iosNative),
|
||||||
|
].every(Boolean);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get active state
|
// Get active state
|
||||||
get active() {
|
get active() {
|
||||||
if (!this.enabled) {
|
if (!this.supported) return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fallback using classname
|
// Fallback using classname
|
||||||
if (!Fullscreen.native || this.forceFallback) {
|
if (!Fullscreen.nativeSupported || this.forceFallback) {
|
||||||
return hasClass(this.target, this.player.config.classNames.fullscreen.fallback);
|
return hasClass(this.target, this.player.config.classNames.fullscreen.fallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
const element = !this.prefix ? document.fullscreenElement : document[`${this.prefix}${this.property}Element`];
|
const element = !this.prefix
|
||||||
|
? this.target.getRootNode().fullscreenElement
|
||||||
|
: this.target.getRootNode()[`${this.prefix}${this.property}Element`];
|
||||||
|
|
||||||
return element && element.shadowRoot ? element === this.target.getRootNode().host : element === this.target;
|
return element && element.shadowRoot ? element === this.target.getRootNode().host : element === this.target;
|
||||||
}
|
}
|
||||||
@ -133,13 +137,11 @@ class Fullscreen {
|
|||||||
get target() {
|
get target() {
|
||||||
return browser.isIos && this.player.config.fullscreen.iosNative
|
return browser.isIos && this.player.config.fullscreen.iosNative
|
||||||
? this.player.media
|
? this.player.media
|
||||||
: this.player.elements.fullscreen || this.player.elements.container;
|
: this.player.elements.fullscreen ?? this.player.elements.container;
|
||||||
}
|
}
|
||||||
|
|
||||||
onChange = () => {
|
onChange = () => {
|
||||||
if (!this.enabled) {
|
if (!this.supported) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update toggle button
|
// Update toggle button
|
||||||
const button = this.player.elements.buttons.fullscreen;
|
const button = this.player.elements.buttons.fullscreen;
|
||||||
@ -157,8 +159,8 @@ class Fullscreen {
|
|||||||
// Store or restore scroll position
|
// Store or restore scroll position
|
||||||
if (toggle) {
|
if (toggle) {
|
||||||
this.scrollPosition = {
|
this.scrollPosition = {
|
||||||
x: window.scrollX || 0,
|
x: window.scrollX ?? 0,
|
||||||
y: window.scrollY || 0,
|
y: window.scrollY ?? 0,
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
window.scrollTo(this.scrollPosition.x, this.scrollPosition.y);
|
window.scrollTo(this.scrollPosition.x, this.scrollPosition.y);
|
||||||
@ -186,10 +188,7 @@ class Fullscreen {
|
|||||||
|
|
||||||
if (toggle) {
|
if (toggle) {
|
||||||
this.cleanupViewport = !hasProperty;
|
this.cleanupViewport = !hasProperty;
|
||||||
|
if (!hasProperty) viewport.content += `,${property}`;
|
||||||
if (!hasProperty) {
|
|
||||||
viewport.content += `,${property}`;
|
|
||||||
}
|
|
||||||
} else if (this.cleanupViewport) {
|
} else if (this.cleanupViewport) {
|
||||||
viewport.content = viewport.content
|
viewport.content = viewport.content
|
||||||
.split(',')
|
.split(',')
|
||||||
@ -204,10 +203,8 @@ class Fullscreen {
|
|||||||
|
|
||||||
// Trap focus inside container
|
// Trap focus inside container
|
||||||
trapFocus = (event) => {
|
trapFocus = (event) => {
|
||||||
// Bail if iOS, not active, not the tab key
|
// Bail if iOS/iPadOS, not active, not the tab key
|
||||||
if (browser.isIos || !this.active || event.key !== 'Tab' || event.keyCode !== 9) {
|
if (browser.isIos || browser.isIPadOS || !this.active || event.key !== 'Tab') return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the current focused element
|
// Get the current focused element
|
||||||
const focused = document.activeElement;
|
const focused = document.activeElement;
|
||||||
@ -228,16 +225,12 @@ class Fullscreen {
|
|||||||
|
|
||||||
// Update UI
|
// Update UI
|
||||||
update = () => {
|
update = () => {
|
||||||
if (this.enabled) {
|
if (this.supported) {
|
||||||
let mode;
|
let mode;
|
||||||
|
|
||||||
if (this.forceFallback) {
|
if (this.forceFallback) mode = 'Fallback (forced)';
|
||||||
mode = 'Fallback (forced)';
|
else if (Fullscreen.nativeSupported) mode = 'Native';
|
||||||
} else if (Fullscreen.native) {
|
else mode = 'Fallback';
|
||||||
mode = 'Native';
|
|
||||||
} else {
|
|
||||||
mode = 'Fallback';
|
|
||||||
}
|
|
||||||
|
|
||||||
this.player.debug.log(`${mode} fullscreen enabled`);
|
this.player.debug.log(`${mode} fullscreen enabled`);
|
||||||
} else {
|
} else {
|
||||||
@ -245,14 +238,12 @@ class Fullscreen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add styling hook to show button
|
// Add styling hook to show button
|
||||||
toggleClass(this.player.elements.container, this.player.config.classNames.fullscreen.enabled, this.enabled);
|
toggleClass(this.player.elements.container, this.player.config.classNames.fullscreen.enabled, this.supported);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Make an element fullscreen
|
// Make an element fullscreen
|
||||||
enter = () => {
|
enter = () => {
|
||||||
if (!this.enabled) {
|
if (!this.supported) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// iOS native fullscreen doesn't need the request step
|
// iOS native fullscreen doesn't need the request step
|
||||||
if (browser.isIos && this.player.config.fullscreen.iosNative) {
|
if (browser.isIos && this.player.config.fullscreen.iosNative) {
|
||||||
@ -261,7 +252,7 @@ class Fullscreen {
|
|||||||
} else {
|
} else {
|
||||||
this.target.webkitEnterFullscreen();
|
this.target.webkitEnterFullscreen();
|
||||||
}
|
}
|
||||||
} else if (!Fullscreen.native || this.forceFallback) {
|
} else if (!Fullscreen.nativeSupported || this.forceFallback) {
|
||||||
this.toggleFallback(true);
|
this.toggleFallback(true);
|
||||||
} else if (!this.prefix) {
|
} else if (!this.prefix) {
|
||||||
this.target.requestFullscreen({ navigationUI: 'hide' });
|
this.target.requestFullscreen({ navigationUI: 'hide' });
|
||||||
@ -272,15 +263,17 @@ class Fullscreen {
|
|||||||
|
|
||||||
// Bail from fullscreen
|
// Bail from fullscreen
|
||||||
exit = () => {
|
exit = () => {
|
||||||
if (!this.enabled) {
|
if (!this.supported) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// iOS native fullscreen
|
// iOS native fullscreen
|
||||||
if (browser.isIos && this.player.config.fullscreen.iosNative) {
|
if (browser.isIos && this.player.config.fullscreen.iosNative) {
|
||||||
this.target.webkitExitFullscreen();
|
if (this.player.isVimeo) {
|
||||||
|
this.player.embed.exitFullscreen();
|
||||||
|
} else {
|
||||||
|
this.target.webkitEnterFullscreen();
|
||||||
|
}
|
||||||
silencePromise(this.player.play());
|
silencePromise(this.player.play());
|
||||||
} else if (!Fullscreen.native || this.forceFallback) {
|
} else if (!Fullscreen.nativeSupported || this.forceFallback) {
|
||||||
this.toggleFallback(false);
|
this.toggleFallback(false);
|
||||||
} else if (!this.prefix) {
|
} else if (!this.prefix) {
|
||||||
(document.cancelFullScreen || document.exitFullscreen).call(document);
|
(document.cancelFullScreen || document.exitFullscreen).call(document);
|
||||||
@ -292,11 +285,8 @@ class Fullscreen {
|
|||||||
|
|
||||||
// Toggle state
|
// Toggle state
|
||||||
toggle = () => {
|
toggle = () => {
|
||||||
if (!this.active) {
|
if (!this.active) this.enter();
|
||||||
this.enter();
|
else this.exit();
|
||||||
} else {
|
|
||||||
this.exit();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ const html5 = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we're using an an external handler...
|
// If we're using an external handler...
|
||||||
if (player.config.quality.forced && is.function(player.config.quality.onChange)) {
|
if (player.config.quality.forced && is.function(player.config.quality.onChange)) {
|
||||||
player.config.quality.onChange(input);
|
player.config.quality.onChange(input);
|
||||||
} else {
|
} else {
|
||||||
|
@ -21,7 +21,6 @@ class Listeners {
|
|||||||
|
|
||||||
this.handleKey = this.handleKey.bind(this);
|
this.handleKey = this.handleKey.bind(this);
|
||||||
this.toggleMenu = this.toggleMenu.bind(this);
|
this.toggleMenu = this.toggleMenu.bind(this);
|
||||||
this.setTabFocus = this.setTabFocus.bind(this);
|
|
||||||
this.firstTouch = this.firstTouch.bind(this);
|
this.firstTouch = this.firstTouch.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,25 +28,25 @@ class Listeners {
|
|||||||
handleKey(event) {
|
handleKey(event) {
|
||||||
const { player } = this;
|
const { player } = this;
|
||||||
const { elements } = player;
|
const { elements } = player;
|
||||||
const code = event.keyCode ? event.keyCode : event.which;
|
const { key, type, altKey, ctrlKey, metaKey, shiftKey } = event;
|
||||||
const pressed = event.type === 'keydown';
|
const pressed = type === 'keydown';
|
||||||
const repeat = pressed && code === this.lastKey;
|
const repeat = pressed && key === this.lastKey;
|
||||||
|
|
||||||
// Bail if a modifier key is set
|
// Bail if a modifier key is set
|
||||||
if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) {
|
if (altKey || ctrlKey || metaKey || shiftKey) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the event is bubbled from the media element
|
// If the event is bubbled from the media element
|
||||||
// Firefox doesn't get the keycode for whatever reason
|
// Firefox doesn't get the key for whatever reason
|
||||||
if (!is.number(code)) {
|
if (!key) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Seek by the number keys
|
// Seek by increment
|
||||||
const seekByKey = () => {
|
const seekByIncrement = (increment) => {
|
||||||
// Divide the max duration into 10th's and times by the number value
|
// 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
|
// Handle the key on keydown
|
||||||
@ -65,113 +64,114 @@ class Listeners {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.which === 32 && matches(focused, 'button, [role^="menuitem"]')) {
|
if (event.key === ' ' && matches(focused, 'button, [role^="menuitem"]')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Which keycodes should we prevent default
|
// Which keys 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];
|
const preventDefault = [
|
||||||
|
' ',
|
||||||
|
'ArrowLeft',
|
||||||
|
'ArrowUp',
|
||||||
|
'ArrowRight',
|
||||||
|
'ArrowDown',
|
||||||
|
|
||||||
// If the code is found prevent default (e.g. prevent scrolling for arrows)
|
'0',
|
||||||
if (preventDefault.includes(code)) {
|
'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.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (code) {
|
switch (key) {
|
||||||
case 48:
|
case '0':
|
||||||
case 49:
|
case '1':
|
||||||
case 50:
|
case '2':
|
||||||
case 51:
|
case '3':
|
||||||
case 52:
|
case '4':
|
||||||
case 53:
|
case '5':
|
||||||
case 54:
|
case '6':
|
||||||
case 55:
|
case '7':
|
||||||
case 56:
|
case '8':
|
||||||
case 57:
|
case '9':
|
||||||
// 0-9
|
|
||||||
if (!repeat) {
|
if (!repeat) {
|
||||||
seekByKey();
|
seekByIncrement(parseInt(key, 10));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 32:
|
case ' ':
|
||||||
case 75:
|
case 'k':
|
||||||
// Space and K key
|
|
||||||
if (!repeat) {
|
if (!repeat) {
|
||||||
silencePromise(player.togglePlay());
|
silencePromise(player.togglePlay());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 38:
|
case 'ArrowUp':
|
||||||
// Arrow up
|
|
||||||
player.increaseVolume(0.1);
|
player.increaseVolume(0.1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 40:
|
case 'ArrowDown':
|
||||||
// Arrow down
|
|
||||||
player.decreaseVolume(0.1);
|
player.decreaseVolume(0.1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 77:
|
case 'm':
|
||||||
// M key
|
|
||||||
if (!repeat) {
|
if (!repeat) {
|
||||||
player.muted = !player.muted;
|
player.muted = !player.muted;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 39:
|
case 'ArrowRight':
|
||||||
// Arrow forward
|
|
||||||
player.forward();
|
player.forward();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 37:
|
case 'ArrowLeft':
|
||||||
// Arrow back
|
|
||||||
player.rewind();
|
player.rewind();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 70:
|
case 'f':
|
||||||
// F key
|
|
||||||
player.fullscreen.toggle();
|
player.fullscreen.toggle();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 67:
|
case 'c':
|
||||||
// C key
|
|
||||||
if (!repeat) {
|
if (!repeat) {
|
||||||
player.toggleCaptions();
|
player.toggleCaptions();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 76:
|
case 'l':
|
||||||
// L key
|
|
||||||
player.loop = !player.loop;
|
player.loop = !player.loop;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* case 73:
|
|
||||||
this.setLoop('start');
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 76:
|
|
||||||
this.setLoop();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 79:
|
|
||||||
this.setLoop('end');
|
|
||||||
break; */
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Escape is handle natively when in full screen
|
// Escape is handle natively when in full screen
|
||||||
// So we only need to worry about non native
|
// 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();
|
player.fullscreen.toggle();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store last code for next cycle
|
// Store last key for next cycle
|
||||||
this.lastKey = code;
|
this.lastKey = key;
|
||||||
} else {
|
} else {
|
||||||
this.lastKey = null;
|
this.lastKey = null;
|
||||||
}
|
}
|
||||||
@ -193,56 +193,6 @@ class Listeners {
|
|||||||
toggleClass(elements.container, player.config.classNames.isTouch, true);
|
toggleClass(elements.container, player.config.classNames.isTouch, true);
|
||||||
};
|
};
|
||||||
|
|
||||||
setTabFocus = (event) => {
|
|
||||||
const { player } = this;
|
|
||||||
const { elements } = player;
|
|
||||||
|
|
||||||
clearTimeout(this.focusTimer);
|
|
||||||
|
|
||||||
// Ignore any key other than tab
|
|
||||||
if (event.type === 'keydown' && event.which !== 9) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Store reference to event timeStamp
|
|
||||||
if (event.type === 'keydown') {
|
|
||||||
this.lastKeyDown = event.timeStamp;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove current classes
|
|
||||||
const removeCurrent = () => {
|
|
||||||
const className = player.config.classNames.tabFocus;
|
|
||||||
const current = getElements.call(player, `.${className}`);
|
|
||||||
toggleClass(current, className, false);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Determine if a key was pressed to trigger this event
|
|
||||||
const wasKeyDown = event.timeStamp - this.lastKeyDown <= 20;
|
|
||||||
|
|
||||||
// Ignore focus events if a key was pressed prior
|
|
||||||
if (event.type === 'focus' && !wasKeyDown) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove all current
|
|
||||||
removeCurrent();
|
|
||||||
|
|
||||||
// Delay the adding of classname until the focus has changed
|
|
||||||
// This event fires before the focusin event
|
|
||||||
if (event.type !== 'focusout') {
|
|
||||||
this.focusTimer = setTimeout(() => {
|
|
||||||
const focused = document.activeElement;
|
|
||||||
|
|
||||||
// Ignore if current focus element isn't inside the player
|
|
||||||
if (!elements.container.contains(focused)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
toggleClass(document.activeElement, player.config.classNames.tabFocus, true);
|
|
||||||
}, 10);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Global window & document listeners
|
// Global window & document listeners
|
||||||
global = (toggle = true) => {
|
global = (toggle = true) => {
|
||||||
const { player } = this;
|
const { player } = this;
|
||||||
@ -257,9 +207,6 @@ class Listeners {
|
|||||||
|
|
||||||
// Detect touch by events
|
// Detect touch by events
|
||||||
once.call(player, document.body, 'touchstart', this.firstTouch);
|
once.call(player, document.body, 'touchstart', this.firstTouch);
|
||||||
|
|
||||||
// Tab focus detection
|
|
||||||
toggleListener.call(player, document.body, 'keydown focus blur focusout', this.setTabFocus, toggle, false, true);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Container listeners
|
// Container listeners
|
||||||
@ -661,15 +608,12 @@ class Listeners {
|
|||||||
elements.buttons.settings,
|
elements.buttons.settings,
|
||||||
'keyup',
|
'keyup',
|
||||||
(event) => {
|
(event) => {
|
||||||
const code = event.which;
|
if (![' ', 'Enter'].includes(event.key)) {
|
||||||
|
|
||||||
// We only care about space and return
|
|
||||||
if (![13, 32].includes(code)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Because return triggers a click anyway, all we need to do is set focus
|
// 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);
|
controls.focusFirstMenuItem.call(player, null, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -689,7 +633,7 @@ class Listeners {
|
|||||||
|
|
||||||
// Escape closes menu
|
// Escape closes menu
|
||||||
this.bind(elements.settings.menu, 'keydown', (event) => {
|
this.bind(elements.settings.menu, 'keydown', (event) => {
|
||||||
if (event.which === 27) {
|
if (event.key === 'Escape') {
|
||||||
controls.toggleMenu.call(player, event);
|
controls.toggleMenu.call(player, event);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -704,10 +648,9 @@ class Listeners {
|
|||||||
// Pause while seeking
|
// Pause while seeking
|
||||||
this.bind(elements.inputs.seek, 'mousedown mouseup keydown keyup touchstart touchend', (event) => {
|
this.bind(elements.inputs.seek, 'mousedown mouseup keydown keyup touchstart touchend', (event) => {
|
||||||
const seek = event.currentTarget;
|
const seek = event.currentTarget;
|
||||||
const code = event.keyCode ? event.keyCode : event.which;
|
|
||||||
const attribute = 'play-on-seeked';
|
const attribute = 'play-on-seeked';
|
||||||
|
|
||||||
if (is.keyboardEvent(event) && code !== 39 && code !== 37) {
|
if (is.keyboardEvent(event) && !['ArrowLeft', 'ArrowRight'].includes(event.key)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -799,7 +742,7 @@ class Listeners {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Polyfill for lower fill in <input type="range"> for webkit
|
// Polyfill for lower fill in <input type="range"> for webkit
|
||||||
if (browser.isWebkit) {
|
if (browser.isWebKit) {
|
||||||
Array.from(getElements.call(player, 'input[type="range"]')).forEach((element) => {
|
Array.from(getElements.call(player, 'input[type="range"]')).forEach((element) => {
|
||||||
this.bind(element, 'input', (event) => controls.updateRangeFill.call(player, event.target));
|
this.bind(element, 'input', (event) => controls.updateRangeFill.call(player, event.target));
|
||||||
});
|
});
|
||||||
@ -841,7 +784,9 @@ class Listeners {
|
|||||||
.filter((c) => !c.contains(elements.container))
|
.filter((c) => !c.contains(elements.container))
|
||||||
.forEach((child) => {
|
.forEach((child) => {
|
||||||
this.bind(child, 'mouseenter mouseleave', (event) => {
|
this.bind(child, 'mouseenter mouseleave', (event) => {
|
||||||
|
if (elements.controls) {
|
||||||
elements.controls.hover = !player.touch && event.type === 'mouseenter';
|
elements.controls.hover = !player.touch && event.type === 'mouseenter';
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -881,7 +826,7 @@ class Listeners {
|
|||||||
elements.inputs.volume,
|
elements.inputs.volume,
|
||||||
'wheel',
|
'wheel',
|
||||||
(event) => {
|
(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
|
// Other browsers on OS X will be inverted until support improves
|
||||||
const inverted = event.webkitDirectionInvertedFromDevice;
|
const inverted = event.webkitDirectionInvertedFromDevice;
|
||||||
// Get delta from event. Invert if `inverted` is true
|
// Get delta from event. Invert if `inverted` is true
|
||||||
|
@ -213,8 +213,8 @@ class Ads {
|
|||||||
request.setAdWillPlayMuted(!this.player.muted);
|
request.setAdWillPlayMuted(!this.player.muted);
|
||||||
|
|
||||||
this.loader.requestAds(request);
|
this.loader.requestAds(request);
|
||||||
} catch (e) {
|
} catch (error) {
|
||||||
this.onAdError(e);
|
this.onAdError(error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -240,7 +240,7 @@ class Ads {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is called whenever the ads are ready inside the AdDisplayContainer
|
* This method is called whenever the ads are ready inside the AdDisplayContainer
|
||||||
* @param {Event} adsManagerLoadedEvent
|
* @param {Event} event - adsManagerLoadedEvent
|
||||||
*/
|
*/
|
||||||
onAdsManagerLoaded = (event) => {
|
onAdsManagerLoaded = (event) => {
|
||||||
// Load could occur after a source change (race condition)
|
// Load could occur after a source change (race condition)
|
||||||
@ -581,6 +581,7 @@ class Ads {
|
|||||||
/**
|
/**
|
||||||
* Handles callbacks after an ad event was invoked
|
* Handles callbacks after an ad event was invoked
|
||||||
* @param {String} event - Event type
|
* @param {String} event - Event type
|
||||||
|
* @param args
|
||||||
*/
|
*/
|
||||||
trigger = (event, ...args) => {
|
trigger = (event, ...args) => {
|
||||||
const handlers = this.events[event];
|
const handlers = this.events[event];
|
||||||
|
@ -2,6 +2,7 @@ import { createElement } from '../utils/elements';
|
|||||||
import { once } from '../utils/events';
|
import { once } from '../utils/events';
|
||||||
import fetch from '../utils/fetch';
|
import fetch from '../utils/fetch';
|
||||||
import is from '../utils/is';
|
import is from '../utils/is';
|
||||||
|
import { clamp } from '../utils/numbers';
|
||||||
import { formatTime } from '../utils/time';
|
import { formatTime } from '../utils/time';
|
||||||
|
|
||||||
// Arg: vttDataString example: "WEBVTT\n\n1\n00:00:05.000 --> 00:00:10.000\n1080p-00001.jpg"
|
// 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;
|
this.player.elements.display.seekTooltip.hidden = this.enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.enabled) {
|
if (!this.enabled) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.getThumbnails().then(() => {
|
this.getThumbnails().then(() => {
|
||||||
if (!this.enabled) {
|
if (!this.enabled) {
|
||||||
@ -124,6 +123,9 @@ class PreviewThumbnails {
|
|||||||
// Check to see if thumb container size was specified manually in CSS
|
// Check to see if thumb container size was specified manually in CSS
|
||||||
this.determineContainerAutoSizing();
|
this.determineContainerAutoSizing();
|
||||||
|
|
||||||
|
// Set up listeners
|
||||||
|
this.listeners();
|
||||||
|
|
||||||
this.loaded = true;
|
this.loaded = true;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -205,18 +207,12 @@ class PreviewThumbnails {
|
|||||||
};
|
};
|
||||||
|
|
||||||
startMove = (event) => {
|
startMove = (event) => {
|
||||||
if (!this.loaded) {
|
if (!this.loaded) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!is.event(event) || !['touchmove', 'mousemove'].includes(event.type)) {
|
if (!is.event(event) || !['touchmove', 'mousemove'].includes(event.type)) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Wait until media has a duration
|
// Wait until media has a duration
|
||||||
if (!this.player.media.duration) {
|
if (!this.player.media.duration) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event.type === 'touchmove') {
|
if (event.type === 'touchmove') {
|
||||||
// Calculate seek hover position as approx video seconds
|
// Calculate seek hover position as approx video seconds
|
||||||
@ -241,6 +237,15 @@ class PreviewThumbnails {
|
|||||||
|
|
||||||
// Set time text inside image container
|
// Set time text inside image container
|
||||||
this.elements.thumb.time.innerText = formatTime(this.seekTime);
|
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
|
// Download and show image
|
||||||
@ -326,7 +331,7 @@ class PreviewThumbnails {
|
|||||||
this.elements.thumb.time = createElement('span', {}, '00:00');
|
this.elements.thumb.time = createElement('span', {}, '00:00');
|
||||||
timeContainer.appendChild(this.elements.thumb.time);
|
timeContainer.appendChild(this.elements.thumb.time);
|
||||||
|
|
||||||
this.elements.thumb.container.appendChild(timeContainer);
|
this.elements.thumb.imageContainer.appendChild(timeContainer);
|
||||||
|
|
||||||
// Inject the whole thumb
|
// Inject the whole thumb
|
||||||
if (is.element(this.player.elements.progress)) {
|
if (is.element(this.player.elements.progress)) {
|
||||||
@ -553,11 +558,7 @@ class PreviewThumbnails {
|
|||||||
};
|
};
|
||||||
|
|
||||||
get currentImageContainer() {
|
get currentImageContainer() {
|
||||||
if (this.mouseDown) {
|
return this.mouseDown ? this.elements.scrubbing.container : this.elements.thumb.imageContainer;
|
||||||
return this.elements.scrubbing.container;
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.elements.thumb.imageContainer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get usingSprites() {
|
get usingSprites() {
|
||||||
@ -590,11 +591,7 @@ class PreviewThumbnails {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get currentImageElement() {
|
get currentImageElement() {
|
||||||
if (this.mouseDown) {
|
return this.mouseDown ? this.currentScrubbingImageElement : this.currentThumbnailImageElement;
|
||||||
return this.currentScrubbingImageElement;
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.currentThumbnailImageElement;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
set currentImageElement(element) {
|
set currentImageElement(element) {
|
||||||
@ -634,46 +631,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
|
// 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 = () => {
|
setThumbContainerSizeAndPos = () => {
|
||||||
|
const { imageContainer } = this.elements.thumb;
|
||||||
|
|
||||||
if (!this.sizeSpecifiedInCSS) {
|
if (!this.sizeSpecifiedInCSS) {
|
||||||
const thumbWidth = Math.floor(this.thumbContainerHeight * this.thumbAspectRatio);
|
const thumbWidth = Math.floor(this.thumbContainerHeight * this.thumbAspectRatio);
|
||||||
this.elements.thumb.imageContainer.style.height = `${this.thumbContainerHeight}px`;
|
imageContainer.style.height = `${this.thumbContainerHeight}px`;
|
||||||
this.elements.thumb.imageContainer.style.width = `${thumbWidth}px`;
|
imageContainer.style.width = `${thumbWidth}px`;
|
||||||
} else if (
|
} else if (imageContainer.clientHeight > 20 && imageContainer.clientWidth < 20) {
|
||||||
this.elements.thumb.imageContainer.clientHeight > 20 &&
|
const thumbWidth = Math.floor(imageContainer.clientHeight * this.thumbAspectRatio);
|
||||||
this.elements.thumb.imageContainer.clientWidth < 20
|
imageContainer.style.width = `${thumbWidth}px`;
|
||||||
) {
|
} else if (imageContainer.clientHeight < 20 && imageContainer.clientWidth > 20) {
|
||||||
const thumbWidth = Math.floor(this.elements.thumb.imageContainer.clientHeight * this.thumbAspectRatio);
|
const thumbHeight = Math.floor(imageContainer.clientWidth / this.thumbAspectRatio);
|
||||||
this.elements.thumb.imageContainer.style.width = `${thumbWidth}px`;
|
imageContainer.style.height = `${thumbHeight}px`;
|
||||||
} else if (
|
|
||||||
this.elements.thumb.imageContainer.clientHeight < 20 &&
|
|
||||||
this.elements.thumb.imageContainer.clientWidth > 20
|
|
||||||
) {
|
|
||||||
const thumbHeight = Math.floor(this.elements.thumb.imageContainer.clientWidth / this.thumbAspectRatio);
|
|
||||||
this.elements.thumb.imageContainer.style.height = `${thumbHeight}px`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setThumbContainerPos();
|
this.setThumbContainerPos();
|
||||||
};
|
};
|
||||||
|
|
||||||
setThumbContainerPos = () => {
|
setThumbContainerPos = () => {
|
||||||
const seekbarRect = this.player.elements.progress.getBoundingClientRect();
|
const scrubberRect = this.player.elements.progress.getBoundingClientRect();
|
||||||
const plyrRect = this.player.elements.container.getBoundingClientRect();
|
const containerRect = this.player.elements.container.getBoundingClientRect();
|
||||||
const { container } = this.elements.thumb;
|
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
|
// 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 min = containerRect.left - scrubberRect.left + 10;
|
||||||
const maxVal = plyrRect.right - seekbarRect.left - container.clientWidth - 10;
|
const max = containerRect.right - scrubberRect.left - container.clientWidth - 10;
|
||||||
// Set preview container position to: mousepos, minus seekbar.left, minus half of previewContainer.clientWidth
|
// 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) {
|
// Move the popover position
|
||||||
previewPos = minVal;
|
container.style.left = `${clamped}px`;
|
||||||
}
|
|
||||||
|
|
||||||
if (previewPos > maxVal) {
|
// The arrow can follow the cursor
|
||||||
previewPos = maxVal;
|
container.style.setProperty('--preview-arrow-offset', `${position - clamped}px`);
|
||||||
}
|
|
||||||
|
|
||||||
container.style.left = `${previewPos}px`;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Can't use 100% width, in case the video is a different aspect ratio to the video container
|
// Can't use 100% width, in case the video is a different aspect ratio to the video container
|
||||||
@ -688,9 +678,7 @@ class PreviewThumbnails {
|
|||||||
|
|
||||||
// Sprites need to be offset to the correct location
|
// Sprites need to be offset to the correct location
|
||||||
setImageSizeAndOffset = (previewImage, frame) => {
|
setImageSizeAndOffset = (previewImage, frame) => {
|
||||||
if (!this.usingSprites) {
|
if (!this.usingSprites) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find difference between height and preview container height
|
// Find difference between height and preview container height
|
||||||
const multiplier = this.thumbContainerHeight / frame.h;
|
const multiplier = this.thumbContainerHeight / frame.h;
|
||||||
|
@ -28,6 +28,21 @@ function parseId(url) {
|
|||||||
return url.match(regex) ? RegExp.$2 : url;
|
return url.match(regex) ? RegExp.$2 : url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Try to extract a hash for private videos from the URL
|
||||||
|
function parseHash(url) {
|
||||||
|
/* This regex matches a hexadecimal hash if given in any of these forms:
|
||||||
|
* - [https://player.]vimeo.com/video/{id}/{hash}[?params]
|
||||||
|
* - [https://player.]vimeo.com/video/{id}?h={hash}[¶ms]
|
||||||
|
* - [https://player.]vimeo.com/video/{id}?[params]&h={hash}
|
||||||
|
* - video/{id}/{hash}
|
||||||
|
* If matched, the hash is available in capture group 4
|
||||||
|
*/
|
||||||
|
const regex = /^.*(vimeo.com\/|video\/)(\d+)(\?.*&*h=|\/)+([\d,a-f]+)/;
|
||||||
|
const found = url.match(regex);
|
||||||
|
|
||||||
|
return found && found.length === 5 ? found[4] : null;
|
||||||
|
}
|
||||||
|
|
||||||
// Set playback state and trigger change (only on actual change)
|
// Set playback state and trigger change (only on actual change)
|
||||||
function assurePlaybackState(play) {
|
function assurePlaybackState(play) {
|
||||||
if (play && !this.embed.hasPlayed) {
|
if (play && !this.embed.hasPlayed) {
|
||||||
@ -71,6 +86,18 @@ const vimeo = {
|
|||||||
const player = this;
|
const player = this;
|
||||||
const config = player.config.vimeo;
|
const config = player.config.vimeo;
|
||||||
const { premium, referrerPolicy, ...frameParams } = config;
|
const { premium, referrerPolicy, ...frameParams } = config;
|
||||||
|
// Get the source URL or ID
|
||||||
|
let source = player.media.getAttribute('src');
|
||||||
|
let hash = '';
|
||||||
|
// Get from <div> if needed
|
||||||
|
if (is.empty(source)) {
|
||||||
|
source = player.media.getAttribute(player.config.attributes.embed.id);
|
||||||
|
// hash can also be set as attribute on the <div>
|
||||||
|
hash = player.media.getAttribute(player.config.attributes.embed.hash);
|
||||||
|
} else {
|
||||||
|
hash = parseHash(source);
|
||||||
|
}
|
||||||
|
const hashParam = hash ? { h: hash } : {};
|
||||||
|
|
||||||
// If the owner has a pro or premium account then we can hide controls etc
|
// If the owner has a pro or premium account then we can hide controls etc
|
||||||
if (premium) {
|
if (premium) {
|
||||||
@ -86,18 +113,12 @@ const vimeo = {
|
|||||||
autoplay: player.autoplay,
|
autoplay: player.autoplay,
|
||||||
muted: player.muted,
|
muted: player.muted,
|
||||||
gesture: 'media',
|
gesture: 'media',
|
||||||
playsinline: !this.config.fullscreen.iosNative,
|
playsinline: player.config.playsinline,
|
||||||
|
// hash has to be added to iframe-URL
|
||||||
|
...hashParam,
|
||||||
...frameParams,
|
...frameParams,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Get the source URL or ID
|
|
||||||
let source = player.media.getAttribute('src');
|
|
||||||
|
|
||||||
// Get from <div> if needed
|
|
||||||
if (is.empty(source)) {
|
|
||||||
source = player.media.getAttribute(player.config.attributes.embed.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
const id = parseId(source);
|
const id = parseId(source);
|
||||||
// Build an iframe
|
// Build an iframe
|
||||||
const iframe = createElement('iframe');
|
const iframe = createElement('iframe');
|
||||||
@ -244,7 +265,7 @@ const vimeo = {
|
|||||||
set(input) {
|
set(input) {
|
||||||
const toggle = is.boolean(input) ? input : false;
|
const toggle = is.boolean(input) ? input : false;
|
||||||
|
|
||||||
player.embed.setVolume(toggle ? 0 : player.config.volume).then(() => {
|
player.embed.setMuted(toggle ? true : player.config.muted).then(() => {
|
||||||
muted = toggle;
|
muted = toggle;
|
||||||
triggerEvent.call(player, player.media, 'volumechange');
|
triggerEvent.call(player, player.media, 'volumechange');
|
||||||
});
|
});
|
||||||
|
@ -131,7 +131,7 @@ const youtube = {
|
|||||||
const posterSrc = (s) => `https://i.ytimg.com/vi/${videoId}/${s}default.jpg`;
|
const posterSrc = (s) => `https://i.ytimg.com/vi/${videoId}/${s}default.jpg`;
|
||||||
|
|
||||||
// Check thumbnail images in order of quality, but reject fallback thumbnails (120px wide)
|
// Check thumbnail images in order of quality, but reject fallback thumbnails (120px wide)
|
||||||
loadImage(posterSrc('maxres'), 121) // Higest quality and unpadded
|
loadImage(posterSrc('maxres'), 121) // Highest quality and un-padded
|
||||||
.catch(() => loadImage(posterSrc('sd'), 121)) // 480p padded 4:3
|
.catch(() => loadImage(posterSrc('sd'), 121)) // 480p padded 4:3
|
||||||
.catch(() => loadImage(posterSrc('hq'))) // 360p padded 4:3. Always exists
|
.catch(() => loadImage(posterSrc('hq'))) // 360p padded 4:3. Always exists
|
||||||
.then((image) => ui.setPoster.call(player, image.src))
|
.then((image) => ui.setPoster.call(player, image.src))
|
||||||
@ -161,7 +161,7 @@ const youtube = {
|
|||||||
// Disable keyboard as we handle it
|
// Disable keyboard as we handle it
|
||||||
disablekb: 1,
|
disablekb: 1,
|
||||||
// Allow iOS inline playback
|
// Allow iOS inline playback
|
||||||
playsinline: !player.config.fullscreen.iosNative ? 1 : 0,
|
playsinline: player.config.playsinline && !player.config.fullscreen.iosNative ? 1 : 0,
|
||||||
// Captions are flaky on YouTube
|
// Captions are flaky on YouTube
|
||||||
cc_load_policy: player.captions.active ? 1 : 0,
|
cc_load_policy: player.captions.active ? 1 : 0,
|
||||||
cc_lang_pref: player.config.captions.language,
|
cc_lang_pref: player.config.captions.language,
|
||||||
@ -183,7 +183,7 @@ const youtube = {
|
|||||||
100: 'The video requested was not found. This error occurs when a video has been removed (for any reason) or has been marked as private.',
|
100: 'The video requested was not found. This error occurs when a video has been removed (for any reason) or has been marked as private.',
|
||||||
101: 'The owner of the requested video does not allow it to be played in embedded players.',
|
101: 'The owner of the requested video does not allow it to be played in embedded players.',
|
||||||
150: 'The owner of the requested video does not allow it to be played in embedded players.',
|
150: 'The owner of the requested video does not allow it to be played in embedded players.',
|
||||||
}[code] || 'An unknown error occured';
|
}[code] || 'An unknown error occurred';
|
||||||
|
|
||||||
player.media.error = { code, message };
|
player.media.error = { code, message };
|
||||||
|
|
||||||
|
56
src/js/plyr.d.ts
vendored
56
src/js/plyr.d.ts
vendored
@ -211,6 +211,11 @@ declare class Plyr {
|
|||||||
*/
|
*/
|
||||||
airplay(): void;
|
airplay(): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the preview thumbnails for the current source.
|
||||||
|
*/
|
||||||
|
setPreviewThumbnails(source: Plyr.PreviewThumbnailsOptions): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Toggle the controls (video only). Takes optional truthy value to force it on/off.
|
* Toggle the controls (video only). Takes optional truthy value to force it on/off.
|
||||||
*/
|
*/
|
||||||
@ -238,8 +243,10 @@ declare class Plyr {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Destroy lib instance
|
* Destroy lib instance
|
||||||
|
* @param {Function} callback - Callback for when destroy is complete
|
||||||
|
* @param {Boolean} soft - Whether it's a soft destroy (for source changes etc)
|
||||||
*/
|
*/
|
||||||
destroy(): void;
|
destroy(callback?: (...args: any[]) => void, soft?: boolean): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare namespace Plyr {
|
declare namespace Plyr {
|
||||||
@ -265,8 +272,8 @@ declare namespace Plyr {
|
|||||||
controlsshown: PlyrEvent;
|
controlsshown: PlyrEvent;
|
||||||
ready: PlyrEvent;
|
ready: PlyrEvent;
|
||||||
};
|
};
|
||||||
// For retrocompatibility, we keep StandadEvent
|
// For retrocompatibility, we keep StandardEvent
|
||||||
type StandadEvent = keyof Plyr.StandardEventMap;
|
type StandardEvent = keyof Plyr.StandardEventMap;
|
||||||
type Html5EventMap = {
|
type Html5EventMap = {
|
||||||
loadstart: PlyrEvent;
|
loadstart: PlyrEvent;
|
||||||
loadeddata: PlyrEvent;
|
loadeddata: PlyrEvent;
|
||||||
@ -334,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.
|
* 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']
|
* 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
|
* If you're using the default controls are used then you can specify which settings to show in the menu
|
||||||
@ -511,6 +518,16 @@ declare namespace Plyr {
|
|||||||
* Preview Thumbnails Options.
|
* Preview Thumbnails Options.
|
||||||
*/
|
*/
|
||||||
previewThumbnails?: PreviewThumbnailsOptions;
|
previewThumbnails?: PreviewThumbnailsOptions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Media Metadata Options.
|
||||||
|
*/
|
||||||
|
mediaMetadata?: MediaMetadataOptions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Markers Options
|
||||||
|
*/
|
||||||
|
markers?: MarkersOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface QualityOptions {
|
interface QualityOptions {
|
||||||
@ -526,7 +543,8 @@ declare namespace Plyr {
|
|||||||
|
|
||||||
interface AdOptions {
|
interface AdOptions {
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
publisherId: string;
|
publisherId?: string;
|
||||||
|
tagUrl?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface SpeedOptions {
|
interface SpeedOptions {
|
||||||
@ -568,6 +586,29 @@ declare namespace Plyr {
|
|||||||
src?: string | string[];
|
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 {
|
export interface Elements {
|
||||||
buttons: {
|
buttons: {
|
||||||
airplay?: HTMLButtonElement;
|
airplay?: HTMLButtonElement;
|
||||||
@ -616,6 +657,11 @@ declare namespace Plyr {
|
|||||||
* Booleans are converted to HTML5 value-less attributes.
|
* Booleans are converted to HTML5 value-less attributes.
|
||||||
*/
|
*/
|
||||||
tracks?: Track[];
|
tracks?: Track[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable or disable preview thumbnails for current source
|
||||||
|
*/
|
||||||
|
previewThumbnails?: Plyr.PreviewThumbnailsOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Source {
|
interface Source {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
// Plyr
|
// Plyr
|
||||||
// plyr.js v3.6.8
|
// plyr.js v3.7.8
|
||||||
// https://github.com/sampotts/plyr
|
// https://github.com/sampotts/plyr
|
||||||
// License: The MIT License (MIT)
|
// License: The MIT License (MIT)
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
@ -72,7 +72,7 @@ class Plyr {
|
|||||||
(() => {
|
(() => {
|
||||||
try {
|
try {
|
||||||
return JSON.parse(this.media.getAttribute('data-plyr-config'));
|
return JSON.parse(this.media.getAttribute('data-plyr-config'));
|
||||||
} catch (e) {
|
} catch (_) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
})(),
|
})(),
|
||||||
@ -246,7 +246,7 @@ class Plyr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check for support again but with type
|
// Check for support again but with type
|
||||||
this.supported = support.check(this.type, this.provider, this.config.playsinline);
|
this.supported = support.check(this.type, this.provider);
|
||||||
|
|
||||||
// If no support for even API, bail
|
// If no support for even API, bail
|
||||||
if (!this.supported.api) {
|
if (!this.supported.api) {
|
||||||
@ -267,7 +267,7 @@ class Plyr {
|
|||||||
|
|
||||||
// Wrap media
|
// Wrap media
|
||||||
if (!is.element(this.elements.container)) {
|
if (!is.element(this.elements.container)) {
|
||||||
this.elements.container = createElement('div', { tabindex: 0 });
|
this.elements.container = createElement('div');
|
||||||
wrap(this.media, this.elements.container);
|
wrap(this.media, this.elements.container);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -649,7 +649,7 @@ class Plyr {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set playback speed
|
* 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) {
|
set speed(input) {
|
||||||
let speed = null;
|
let speed = null;
|
||||||
@ -675,7 +675,9 @@ class Plyr {
|
|||||||
|
|
||||||
// Set media speed
|
// Set media speed
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
if (this.media) {
|
||||||
this.media.playbackRate = speed;
|
this.media.playbackRate = speed;
|
||||||
|
}
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -931,8 +933,7 @@ class Plyr {
|
|||||||
* @param {Boolean} input - Whether to autoplay or not
|
* @param {Boolean} input - Whether to autoplay or not
|
||||||
*/
|
*/
|
||||||
set autoplay(input) {
|
set autoplay(input) {
|
||||||
const toggle = is.boolean(input) ? input : this.config.autoplay;
|
this.config.autoplay = is.boolean(input) ? input : this.config.autoplay;
|
||||||
this.config.autoplay = toggle;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -952,10 +953,11 @@ class Plyr {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the caption track by index
|
* Set the caption track by index
|
||||||
* @param {Number} - Caption index
|
* @param {Number} input - Caption index
|
||||||
*/
|
*/
|
||||||
set currentTrack(input) {
|
set currentTrack(input) {
|
||||||
captions.set.call(this, input, false);
|
captions.set.call(this, input, false);
|
||||||
|
captions.setup.call(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -969,7 +971,7 @@ class Plyr {
|
|||||||
/**
|
/**
|
||||||
* Set the wanted language for captions
|
* 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
|
* 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) {
|
set language(input) {
|
||||||
captions.setLanguage.call(this, input, false);
|
captions.setLanguage.call(this, input, false);
|
||||||
@ -1029,6 +1031,23 @@ class Plyr {
|
|||||||
return this.media === document.pictureInPictureElement;
|
return this.media === document.pictureInPictureElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the preview thumbnails for the current source
|
||||||
|
*/
|
||||||
|
setPreviewThumbnails(thumbnailSource) {
|
||||||
|
if (this.previewThumbnails && this.previewThumbnails.loaded) {
|
||||||
|
this.previewThumbnails.destroy();
|
||||||
|
this.previewThumbnails = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object.assign(this.config.previewThumbnails, thumbnailSource);
|
||||||
|
|
||||||
|
// Create new instance if it is still enabled
|
||||||
|
if (this.config.previewThumbnails.enabled) {
|
||||||
|
this.previewThumbnails = new PreviewThumbnails(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Trigger the airplay dialog
|
* Trigger the airplay dialog
|
||||||
* TODO: update player with state, support, enabled
|
* TODO: update player with state, support, enabled
|
||||||
@ -1220,10 +1239,9 @@ class Plyr {
|
|||||||
* Check for support
|
* Check for support
|
||||||
* @param {String} type - Player type (audio/video)
|
* @param {String} type - Player type (audio/video)
|
||||||
* @param {String} provider - Provider (html5/youtube/vimeo)
|
* @param {String} provider - Provider (html5/youtube/vimeo)
|
||||||
* @param {Boolean} inline - Where player has `playsinline` sttribute
|
|
||||||
*/
|
*/
|
||||||
static supported(type, provider, inline) {
|
static supported(type, provider) {
|
||||||
return support.check(type, provider, inline);
|
return support.check(type, provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
// Plyr Polyfilled Build
|
// Plyr Polyfilled Build
|
||||||
// plyr.js v3.6.8
|
// plyr.js v3.7.8
|
||||||
// https://github.com/sampotts/plyr
|
// https://github.com/sampotts/plyr
|
||||||
// License: The MIT License (MIT)
|
// License: The MIT License (MIT)
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
|
@ -26,7 +26,7 @@ class Storage {
|
|||||||
window.localStorage.removeItem(test);
|
window.localStorage.removeItem(test);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (e) {
|
} catch (_) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -70,7 +70,11 @@ class Storage {
|
|||||||
extend(storage, object);
|
extend(storage, object);
|
||||||
|
|
||||||
// Update storage
|
// Update storage
|
||||||
|
try {
|
||||||
window.localStorage.setItem(this.key, JSON.stringify(storage));
|
window.localStorage.setItem(this.key, JSON.stringify(storage));
|
||||||
|
} catch (_) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,10 +24,9 @@ const support = {
|
|||||||
|
|
||||||
// Check for support
|
// Check for support
|
||||||
// Basic functionality vs full UI
|
// Basic functionality vs full UI
|
||||||
check(type, provider, playsinline) {
|
check(type, provider) {
|
||||||
const canPlayInline = browser.isIPhone && playsinline && support.playsinline;
|
|
||||||
const api = support[type] || provider !== 'html5';
|
const api = support[type] || provider !== 'html5';
|
||||||
const ui = api && support.rangeInput && (type !== 'video' || !browser.isIPhone || canPlayInline);
|
const ui = api && support.rangeInput;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
api,
|
api,
|
||||||
@ -38,6 +37,9 @@ const support = {
|
|||||||
// Picture-in-picture support
|
// Picture-in-picture support
|
||||||
// Safari & Chrome only currently
|
// Safari & Chrome only currently
|
||||||
pip: (() => {
|
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) {
|
if (browser.isIPhone) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -88,7 +90,7 @@ const support = {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
return Boolean(type && this.media.canPlayType(type).replace(/no/, ''));
|
return Boolean(type && this.media.canPlayType(type).replace(/no/, ''));
|
||||||
} catch (e) {
|
} catch (_) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
16
src/js/ui.js
16
src/js/ui.js
@ -5,7 +5,6 @@
|
|||||||
import captions from './captions';
|
import captions from './captions';
|
||||||
import controls from './controls';
|
import controls from './controls';
|
||||||
import support from './support';
|
import support from './support';
|
||||||
import browser from './utils/browser';
|
|
||||||
import { getElement, toggleClass } from './utils/elements';
|
import { getElement, toggleClass } from './utils/elements';
|
||||||
import { ready, triggerEvent } from './utils/events';
|
import { ready, triggerEvent } from './utils/events';
|
||||||
import i18n from './utils/i18n';
|
import i18n from './utils/i18n';
|
||||||
@ -82,6 +81,9 @@ const ui = {
|
|||||||
// Reset time display
|
// Reset time display
|
||||||
controls.timeUpdate.call(this);
|
controls.timeUpdate.call(this);
|
||||||
|
|
||||||
|
// Reset duration display
|
||||||
|
controls.durationUpdate.call(this);
|
||||||
|
|
||||||
// Update the UI
|
// Update the UI
|
||||||
ui.checkPlaying.call(this);
|
ui.checkPlaying.call(this);
|
||||||
|
|
||||||
@ -95,9 +97,6 @@ const ui = {
|
|||||||
// Check for airplay support
|
// Check for airplay support
|
||||||
toggleClass(this.elements.container, this.config.classNames.airplay.supported, support.airplay && this.isHTML5);
|
toggleClass(this.elements.container, this.config.classNames.airplay.supported, support.airplay && this.isHTML5);
|
||||||
|
|
||||||
// Add iOS class
|
|
||||||
toggleClass(this.elements.container, this.config.classNames.isIos, browser.isIos);
|
|
||||||
|
|
||||||
// Add touch class
|
// Add touch class
|
||||||
toggleClass(this.elements.container, this.config.classNames.isTouch, this.touch);
|
toggleClass(this.elements.container, this.config.classNames.isTouch, this.touch);
|
||||||
|
|
||||||
@ -122,6 +121,11 @@ const ui = {
|
|||||||
if (this.config.duration) {
|
if (this.config.duration) {
|
||||||
controls.durationUpdate.call(this);
|
controls.durationUpdate.call(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Media metadata
|
||||||
|
if (this.config.mediaMetadata) {
|
||||||
|
controls.setMediaMetadata.call(this);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// Setup aria attribute for play and iframe title
|
// Setup aria attribute for play and iframe title
|
||||||
@ -181,13 +185,13 @@ const ui = {
|
|||||||
.call(this)
|
.call(this)
|
||||||
// Load image
|
// Load image
|
||||||
.then(() => loadImage(poster))
|
.then(() => loadImage(poster))
|
||||||
.catch((err) => {
|
.catch((error) => {
|
||||||
// Hide poster on error unless it's been set by another call
|
// Hide poster on error unless it's been set by another call
|
||||||
if (poster === this.poster) {
|
if (poster === this.poster) {
|
||||||
ui.togglePoster.call(this, false);
|
ui.togglePoster.call(this, false);
|
||||||
}
|
}
|
||||||
// Rethrow
|
// Rethrow
|
||||||
throw err;
|
throw error;
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// Prevent race conditions
|
// Prevent race conditions
|
||||||
|
@ -31,7 +31,7 @@ export function repaint(element, delay) {
|
|||||||
|
|
||||||
// eslint-disable-next-line no-param-reassign
|
// eslint-disable-next-line no-param-reassign
|
||||||
element.hidden = false;
|
element.hidden = false;
|
||||||
} catch (e) {
|
} catch (_) {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
}, delay);
|
}, delay);
|
||||||
|
@ -3,14 +3,19 @@
|
|||||||
// Unfortunately, due to mixed support, UA sniffing is required
|
// Unfortunately, due to mixed support, UA sniffing is required
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
|
|
||||||
const browser = {
|
const isIE = Boolean(window.document.documentMode);
|
||||||
isIE: Boolean(window.document.documentMode),
|
const isEdge = /Edge/g.test(navigator.userAgent);
|
||||||
isEdge: window.navigator.userAgent.includes('Edge'),
|
const isWebKit = 'WebkitAppearance' in document.documentElement.style && !/Edge/g.test(navigator.userAgent);
|
||||||
isWebkit: 'WebkitAppearance' in document.documentElement.style && !/Edge/.test(navigator.userAgent),
|
const isIPhone = /iPhone|iPod/gi.test(navigator.userAgent) && navigator.maxTouchPoints > 1;
|
||||||
isIPhone: /(iPhone|iPod)/gi.test(navigator.platform),
|
// navigator.platform may be deprecated but this check is still required
|
||||||
isIos:
|
const isIPadOS = navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1;
|
||||||
(navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1) ||
|
const isIos = /iPad|iPhone|iPod/gi.test(navigator.userAgent) && navigator.maxTouchPoints > 1;
|
||||||
/(iPad|iPhone|iPod)/gi.test(navigator.platform),
|
|
||||||
};
|
|
||||||
|
|
||||||
export default browser;
|
export default {
|
||||||
|
isIE,
|
||||||
|
isEdge,
|
||||||
|
isWebKit,
|
||||||
|
isIPhone,
|
||||||
|
isIPadOS,
|
||||||
|
isIos,
|
||||||
|
};
|
||||||
|
@ -37,9 +37,7 @@ export function wrap(elements, wrapper) {
|
|||||||
|
|
||||||
// Set attributes
|
// Set attributes
|
||||||
export function setAttributes(element, attributes) {
|
export function setAttributes(element, attributes) {
|
||||||
if (!is.element(element) || is.empty(attributes)) {
|
if (!is.element(element) || is.empty(attributes)) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Assume null and undefined attributes should be left out,
|
// Assume null and undefined attributes should be left out,
|
||||||
// Setting them would otherwise convert them to "null" and "undefined"
|
// Setting them would otherwise convert them to "null" and "undefined"
|
||||||
@ -67,20 +65,16 @@ export function createElement(type, attributes, text) {
|
|||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inaert an element after another
|
// Insert an element after another
|
||||||
export function insertAfter(element, target) {
|
export function insertAfter(element, target) {
|
||||||
if (!is.element(element) || !is.element(target)) {
|
if (!is.element(element) || !is.element(target)) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
target.parentNode.insertBefore(element, target.nextSibling);
|
target.parentNode.insertBefore(element, target.nextSibling);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Insert a DocumentFragment
|
// Insert a DocumentFragment
|
||||||
export function insertElement(type, parent, attributes, text) {
|
export function insertElement(type, parent, attributes, text) {
|
||||||
if (!is.element(parent)) {
|
if (!is.element(parent)) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
parent.appendChild(createElement(type, attributes, text));
|
parent.appendChild(createElement(type, attributes, text));
|
||||||
}
|
}
|
||||||
@ -101,9 +95,7 @@ export function removeElement(element) {
|
|||||||
|
|
||||||
// Remove all child elements
|
// Remove all child elements
|
||||||
export function emptyElement(element) {
|
export function emptyElement(element) {
|
||||||
if (!is.element(element)) {
|
if (!is.element(element)) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let { length } = element.childNodes;
|
let { length } = element.childNodes;
|
||||||
|
|
||||||
@ -115,9 +107,7 @@ export function emptyElement(element) {
|
|||||||
|
|
||||||
// Replace element
|
// Replace element
|
||||||
export function replaceElement(newChild, oldChild) {
|
export function replaceElement(newChild, oldChild) {
|
||||||
if (!is.element(oldChild) || !is.element(oldChild.parentNode) || !is.element(newChild)) {
|
if (!is.element(oldChild) || !is.element(oldChild.parentNode) || !is.element(newChild)) return null;
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
oldChild.parentNode.replaceChild(newChild, oldChild);
|
oldChild.parentNode.replaceChild(newChild, oldChild);
|
||||||
|
|
||||||
@ -131,9 +121,7 @@ export function getAttributesFromSelector(sel, existingAttributes) {
|
|||||||
// '#test' to { id: 'test' }
|
// '#test' to { id: 'test' }
|
||||||
// '[data-test="test"]' to { 'data-test': 'test' }
|
// '[data-test="test"]' to { 'data-test': 'test' }
|
||||||
|
|
||||||
if (!is.string(sel) || is.empty(sel)) {
|
if (!is.string(sel) || is.empty(sel)) return {};
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
const attributes = {};
|
const attributes = {};
|
||||||
const existing = extend({}, existingAttributes);
|
const existing = extend({}, existingAttributes);
|
||||||
@ -181,9 +169,7 @@ export function getAttributesFromSelector(sel, existingAttributes) {
|
|||||||
|
|
||||||
// Toggle hidden
|
// Toggle hidden
|
||||||
export function toggleHidden(element, hidden) {
|
export function toggleHidden(element, hidden) {
|
||||||
if (!is.element(element)) {
|
if (!is.element(element)) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let hide = hidden;
|
let hide = hidden;
|
||||||
|
|
||||||
@ -268,16 +254,9 @@ export function getElement(selector) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set focus and tab focus class
|
// Set focus and tab focus class
|
||||||
export function setFocus(element = null, tabFocus = false) {
|
export function setFocus(element = null, focusVisible = false) {
|
||||||
if (!is.element(element)) {
|
if (!is.element(element)) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set regular focus
|
// Set regular focus
|
||||||
element.focus({ preventScroll: true });
|
element.focus({ preventScroll: true, focusVisible });
|
||||||
|
|
||||||
// If we want to mimic keyboard focus via tab
|
|
||||||
if (tabFocus) {
|
|
||||||
toggleClass(element, this.config.classNames.tabFocus);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ const supportsPassiveListeners = (() => {
|
|||||||
});
|
});
|
||||||
window.addEventListener('test', null, options);
|
window.addEventListener('test', null, options);
|
||||||
window.removeEventListener('test', null, options);
|
window.removeEventListener('test', null, options);
|
||||||
} catch (e) {
|
} catch (_) {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ export default function fetch(url, responseType = 'text') {
|
|||||||
if (responseType === 'text') {
|
if (responseType === 'text') {
|
||||||
try {
|
try {
|
||||||
resolve(JSON.parse(request.responseText));
|
resolve(JSON.parse(request.responseText));
|
||||||
} catch (e) {
|
} catch (_) {
|
||||||
resolve(request.responseText);
|
resolve(request.responseText);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -35,8 +35,8 @@ export default function fetch(url, responseType = 'text') {
|
|||||||
request.responseType = responseType;
|
request.responseType = responseType;
|
||||||
|
|
||||||
request.send();
|
request.send();
|
||||||
} catch (e) {
|
} catch (error) {
|
||||||
reject(e);
|
reject(error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ const isObject = (input) => getConstructor(input) === Object;
|
|||||||
const isNumber = (input) => getConstructor(input) === Number && !Number.isNaN(input);
|
const isNumber = (input) => getConstructor(input) === Number && !Number.isNaN(input);
|
||||||
const isString = (input) => getConstructor(input) === String;
|
const isString = (input) => getConstructor(input) === String;
|
||||||
const isBoolean = (input) => getConstructor(input) === Boolean;
|
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 isArray = (input) => Array.isArray(input);
|
||||||
const isWeakMap = (input) => instanceOf(input, WeakMap);
|
const isWeakMap = (input) => instanceOf(input, WeakMap);
|
||||||
const isNodeList = (input) => instanceOf(input, NodeList);
|
const isNodeList = (input) => instanceOf(input, NodeList);
|
||||||
@ -51,7 +51,7 @@ const isUrl = (input) => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
return !isEmpty(new URL(string).hostname);
|
return !isEmpty(new URL(string).hostname);
|
||||||
} catch (e) {
|
} catch (_) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -60,12 +60,16 @@ export default function loadSprite(url, id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (useStorage) {
|
if (useStorage) {
|
||||||
|
try {
|
||||||
window.localStorage.setItem(
|
window.localStorage.setItem(
|
||||||
`${prefix}-${id}`,
|
`${prefix}-${id}`,
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
content: result,
|
content: result,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
} catch (_) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
update(container, result);
|
update(container, result);
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* @param {Number} input
|
* @param {Number} input
|
||||||
* @param {Number} min The lower boundary of the output range
|
* @param {Number} min The lower boundary of the output range
|
||||||
* @param {Number} max The upper 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
|
* @type Number
|
||||||
*/
|
*/
|
||||||
export function clamp(input = 0, min = 0, max = 255) {
|
export function clamp(input = 0, min = 0, max = 255) {
|
||||||
|
@ -11,11 +11,9 @@ export function generateId(prefix) {
|
|||||||
|
|
||||||
// Format string
|
// Format string
|
||||||
export function format(input, ...args) {
|
export function format(input, ...args) {
|
||||||
if (is.empty(input)) {
|
if (is.empty(input)) return input;
|
||||||
return input;
|
|
||||||
}
|
|
||||||
|
|
||||||
return input.toString().replace(/{(\d+)}/g, (match, i) => args[i].toString());
|
return input.toString().replace(/{(\d+)}/g, (_, i) => args[i].toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get percentage
|
// Get percentage
|
||||||
@ -27,13 +25,13 @@ export function getPercentage(current, max) {
|
|||||||
return ((current / max) * 100).toFixed(2);
|
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 = '') =>
|
export const replaceAll = (input = '', find = '', replace = '') =>
|
||||||
input.replace(new RegExp(find.toString().replace(/([.*+?^=!:${}()|[\]/\\])/g, '\\$1'), 'g'), replace.toString());
|
input.replace(new RegExp(find.toString().replace(/([.*+?^=!:${}()|[\]/\\])/g, '\\$1'), 'g'), replace.toString());
|
||||||
|
|
||||||
// Convert to title case
|
// Convert to title case
|
||||||
export const toTitleCase = (input = '') =>
|
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
|
// Convert string to pascalCase
|
||||||
export function toPascalCase(input = '') {
|
export function toPascalCase(input = '') {
|
||||||
|
@ -20,7 +20,7 @@ export function parseUrl(input, safe = true) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
return new URL(url);
|
return new URL(url);
|
||||||
} catch (e) {
|
} catch (_) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
// Base
|
// Base
|
||||||
.plyr {
|
.plyr {
|
||||||
@include plyr-font-smoothing($plyr-font-smoothing);
|
@include plyr-font-smoothing($plyr-font-smoothing);
|
||||||
|
|
||||||
align-items: center;
|
align-items: center;
|
||||||
direction: ltr;
|
direction: ltr;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -28,8 +28,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Tab focus
|
// Tab focus
|
||||||
&.plyr__tab-focus {
|
&:focus-visible {
|
||||||
@include plyr-tab-focus();
|
@include plyr-focus-visible;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,6 +56,7 @@
|
|||||||
.plyr [data-plyr='fullscreen'] {
|
.plyr [data-plyr='fullscreen'] {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.plyr--captions-enabled [data-plyr='captions'],
|
.plyr--captions-enabled [data-plyr='captions'],
|
||||||
.plyr--pip-supported [data-plyr='pip'],
|
.plyr--pip-supported [data-plyr='pip'],
|
||||||
.plyr--airplay-supported [data-plyr='airplay'],
|
.plyr--airplay-supported [data-plyr='airplay'],
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
.plyr__control svg {
|
.plyr__control svg {
|
||||||
transition: transform 0.3s ease;
|
transition: transform 0.3s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
.plyr__control[aria-expanded='true'] {
|
.plyr__control[aria-expanded='true'] {
|
||||||
svg {
|
svg {
|
||||||
transform: rotate(90deg);
|
transform: rotate(90deg);
|
||||||
@ -25,7 +26,7 @@
|
|||||||
&__container {
|
&__container {
|
||||||
animation: plyr-popup 0.2s ease;
|
animation: plyr-popup 0.2s ease;
|
||||||
background: $plyr-menu-background;
|
background: $plyr-menu-background;
|
||||||
border-radius: 4px;
|
border-radius: $plyr-menu-radius;
|
||||||
bottom: 100%;
|
bottom: 100%;
|
||||||
box-shadow: $plyr-menu-shadow;
|
box-shadow: $plyr-menu-shadow;
|
||||||
color: $plyr-menu-color;
|
color: $plyr-menu-color;
|
||||||
@ -73,10 +74,7 @@
|
|||||||
color: $plyr-menu-color;
|
color: $plyr-menu-color;
|
||||||
display: flex;
|
display: flex;
|
||||||
font-size: $plyr-font-size-menu;
|
font-size: $plyr-font-size-menu;
|
||||||
padding-bottom: calc(#{$plyr-control-padding} / 1.5);
|
padding: calc(#{$plyr-control-padding} / 1.5) calc(#{$plyr-control-padding} * 1.5);
|
||||||
padding-left: calc(#{$plyr-control-padding} * 1.5);
|
|
||||||
padding-right: calc(#{$plyr-control-padding} * 1.5);
|
|
||||||
padding-top: calc(#{$plyr-control-padding} / 1.5);
|
|
||||||
user-select: none;
|
user-select: none;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
@ -102,7 +100,7 @@
|
|||||||
right: calc((#{$plyr-control-padding} * 1.5) - #{$plyr-menu-item-arrow-size});
|
right: calc((#{$plyr-control-padding} * 1.5) - #{$plyr-menu-item-arrow-size});
|
||||||
}
|
}
|
||||||
|
|
||||||
&.plyr__tab-focus::after,
|
&:focus-visible::after,
|
||||||
&:hover::after {
|
&:hover::after {
|
||||||
border-left-color: currentColor;
|
border-left-color: currentColor;
|
||||||
}
|
}
|
||||||
@ -134,7 +132,7 @@
|
|||||||
top: 100%;
|
top: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.plyr__tab-focus::after,
|
&:focus-visible::after,
|
||||||
&:hover::after {
|
&:hover::after {
|
||||||
border-right-color: currentColor;
|
border-right-color: currentColor;
|
||||||
}
|
}
|
||||||
@ -176,13 +174,14 @@
|
|||||||
&::before {
|
&::before {
|
||||||
background: $plyr-control-toggle-checked-background;
|
background: $plyr-control-toggle-checked-background;
|
||||||
}
|
}
|
||||||
|
|
||||||
&::after {
|
&::after {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
transform: translateY(-50%) scale(1);
|
transform: translateY(-50%) scale(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&.plyr__tab-focus::before,
|
&:focus-visible::before,
|
||||||
&:hover::before {
|
&:hover::before {
|
||||||
background: rgba($plyr-color-gray-900, 0.1);
|
background: rgba($plyr-color-gray-900, 0.1);
|
||||||
}
|
}
|
||||||
@ -193,7 +192,7 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
display: flex;
|
display: flex;
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
margin-right: calc((#{$plyr-control-padding} - 2) * -1);
|
margin-right: calc((#{$plyr-control-padding} - 2px) * -1);
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
padding-left: calc(#{$plyr-control-padding} * 3.5);
|
padding-left: calc(#{$plyr-control-padding} * 3.5);
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
|
@ -24,8 +24,9 @@ $plyr-progress-offset: $plyr-range-thumb-height;
|
|||||||
|
|
||||||
// Seek tooltip to show time
|
// Seek tooltip to show time
|
||||||
.plyr__tooltip {
|
.plyr__tooltip {
|
||||||
font-size: $plyr-font-size-time;
|
|
||||||
left: 0;
|
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 {
|
.plyr--audio.plyr--loading .plyr__progress__buffer {
|
||||||
background-color: $plyr-audio-progress-buffered-background;
|
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'] {
|
.plyr--full-ui input[type='range'] {
|
||||||
-webkit-appearance: none; /* stylelint-disable-line */
|
appearance: none;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
border: 0;
|
border: 0;
|
||||||
border-radius: calc(#{$plyr-range-thumb-height} * 2);
|
border-radius: calc(#{$plyr-range-thumb-height} * 2);
|
||||||
|
|
||||||
// `color` property is used in JS to populate lower fill for WebKit
|
// `color` property is used in JS to populate lower fill for WebKit
|
||||||
color: $plyr-range-fill-background;
|
color: $plyr-range-fill-background;
|
||||||
display: block;
|
display: block;
|
||||||
@ -18,23 +19,25 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
&::-webkit-slider-runnable-track {
|
&::-webkit-slider-runnable-track {
|
||||||
@include plyr-range-track();
|
@include plyr-range-track;
|
||||||
|
|
||||||
background-image: linear-gradient(to right, currentColor var(--value, 0%), transparent var(--value, 0%));
|
background-image: linear-gradient(to right, currentColor var(--value, 0%), transparent var(--value, 0%));
|
||||||
}
|
}
|
||||||
|
|
||||||
&::-webkit-slider-thumb {
|
&::-webkit-slider-thumb {
|
||||||
@include plyr-range-thumb();
|
@include plyr-range-thumb;
|
||||||
-webkit-appearance: none; /* stylelint-disable-line */
|
|
||||||
|
appearance: none;
|
||||||
margin-top: calc(((#{$plyr-range-thumb-height} - #{$plyr-range-track-height}) / 2) * -1);
|
margin-top: calc(((#{$plyr-range-thumb-height} - #{$plyr-range-track-height}) / 2) * -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mozilla
|
// Mozilla
|
||||||
&::-moz-range-track {
|
&::-moz-range-track {
|
||||||
@include plyr-range-track();
|
@include plyr-range-track;
|
||||||
}
|
}
|
||||||
|
|
||||||
&::-moz-range-thumb {
|
&::-moz-range-thumb {
|
||||||
@include plyr-range-thumb();
|
@include plyr-range-thumb;
|
||||||
}
|
}
|
||||||
|
|
||||||
&::-moz-range-progress {
|
&::-moz-range-progress {
|
||||||
@ -45,22 +48,24 @@
|
|||||||
|
|
||||||
// Microsoft
|
// Microsoft
|
||||||
&::-ms-track {
|
&::-ms-track {
|
||||||
@include plyr-range-track();
|
@include plyr-range-track;
|
||||||
|
|
||||||
color: transparent;
|
color: transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
&::-ms-fill-upper {
|
&::-ms-fill-upper {
|
||||||
@include plyr-range-track();
|
@include plyr-range-track;
|
||||||
}
|
}
|
||||||
|
|
||||||
&::-ms-fill-lower {
|
&::-ms-fill-lower {
|
||||||
@include plyr-range-track();
|
@include plyr-range-track;
|
||||||
|
|
||||||
background: currentColor;
|
background: currentColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
&::-ms-thumb {
|
&::-ms-thumb {
|
||||||
@include plyr-range-thumb();
|
@include plyr-range-thumb;
|
||||||
|
|
||||||
// For some reason, Edge uses the -webkit margin above
|
// For some reason, Edge uses the -webkit margin above
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
}
|
}
|
||||||
@ -70,25 +75,25 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Focus styles
|
// Focus styles
|
||||||
&:focus {
|
|
||||||
outline: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
&::-moz-focus-outer {
|
&::-moz-focus-outer {
|
||||||
border: 0;
|
border: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.plyr__tab-focus {
|
&:focus {
|
||||||
|
outline: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:focus-visible {
|
||||||
&::-webkit-slider-runnable-track {
|
&::-webkit-slider-runnable-track {
|
||||||
@include plyr-tab-focus();
|
@include plyr-focus-visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
&::-moz-range-track {
|
&::-moz-range-track {
|
||||||
@include plyr-tab-focus();
|
@include plyr-focus-visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
&::-ms-track {
|
&::-ms-track {
|
||||||
@include plyr-tab-focus();
|
@include plyr-focus-visible;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
/* stylelint-disable selector-max-compound-selectors */
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
// Tooltips
|
// Tooltips
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
@ -41,7 +42,7 @@
|
|||||||
|
|
||||||
// Displaying
|
// Displaying
|
||||||
.plyr .plyr__control:hover .plyr__tooltip,
|
.plyr .plyr__control:hover .plyr__tooltip,
|
||||||
.plyr .plyr__control.plyr__tab-focus .plyr__tooltip,
|
.plyr .plyr__control:focus-visible .plyr__tooltip,
|
||||||
.plyr__tooltip--visible {
|
.plyr__tooltip--visible {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
transform: translate(-50%, 0) scale(1);
|
transform: translate(-50%, 0) scale(1);
|
||||||
@ -81,7 +82,7 @@
|
|||||||
.plyr__controls > .plyr__control:first-child + .plyr__control,
|
.plyr__controls > .plyr__control:first-child + .plyr__control,
|
||||||
.plyr__controls > .plyr__control:last-child {
|
.plyr__controls > .plyr__control:last-child {
|
||||||
&:hover .plyr__tooltip,
|
&:hover .plyr__tooltip,
|
||||||
&.plyr__tab-focus .plyr__tooltip,
|
&:focus-visible .plyr__tooltip,
|
||||||
.plyr__tooltip--visible {
|
.plyr__tooltip--visible {
|
||||||
transform: translate(0, 0) scale(1);
|
transform: translate(0, 0) scale(1);
|
||||||
}
|
}
|
||||||
|
@ -5,21 +5,14 @@
|
|||||||
.plyr__volume {
|
.plyr__volume {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
display: flex;
|
display: flex;
|
||||||
max-width: 110px;
|
|
||||||
min-width: 80px;
|
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 20%;
|
|
||||||
|
|
||||||
input[type='range'] {
|
input[type='range'] {
|
||||||
margin-left: calc(#{$plyr-control-spacing} / 2);
|
margin-left: calc(#{$plyr-control-spacing} / 2);
|
||||||
margin-right: calc(#{$plyr-control-spacing} / 2);
|
margin-right: calc(#{$plyr-control-spacing} / 2);
|
||||||
|
max-width: 90px;
|
||||||
|
min-width: 60px;
|
||||||
position: relative;
|
position: relative;
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Auto size on iOS as there's no slider
|
|
||||||
.plyr--is-ios .plyr__volume {
|
|
||||||
min-width: 0;
|
|
||||||
width: auto;
|
|
||||||
}
|
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
// Downloaded from https://github.com/malyw/css-vars (and modified)
|
// Downloaded from https://github.com/malyw/css-vars (and modified)
|
||||||
|
|
||||||
|
@use 'sass:list';
|
||||||
|
@use 'sass:map';
|
||||||
|
|
||||||
// global map to be filled via variables
|
// global map to be filled via variables
|
||||||
$css-vars: ();
|
$css-vars: ();
|
||||||
|
|
||||||
@ -21,36 +24,35 @@ $css-vars-use-native: false !default;
|
|||||||
|
|
||||||
///
|
///
|
||||||
// Emulates var() CSS native function behavior
|
// Emulates var() CSS native function behavior
|
||||||
//
|
|
||||||
// $args[0] {String} "--" + variable name
|
// $args[0] {String} "--" + variable name
|
||||||
// [$args[1]] Optional default value if variable is not assigned yet
|
// [$args[1]] Optional default value if variable is not assigned yet
|
||||||
//
|
|
||||||
// E.G.:
|
// E.G.:
|
||||||
// color: var(--main-color);
|
// color: var(--main-color);
|
||||||
// background: var(--main-background, green);
|
// background: var(--main-background, green);
|
||||||
///
|
///
|
||||||
@function var($args...) {
|
@function var($args...) {
|
||||||
// CHECK PARAMS
|
// CHECK PARAMS
|
||||||
@if (length($args) ==0) {
|
@if length($args) == 0 {
|
||||||
@error 'Variable name is expected to be passed to the var() function';
|
@error 'Variable name is expected to be passed to the var() function';
|
||||||
}
|
}
|
||||||
@if (str-length(nth($args, 1)) < 2 or str-slice(nth($args, 1), 0, 2) != '--') {
|
|
||||||
|
@if str-length(nth($args, 1)) < 2 or str-slice(nth($args, 1), 0, 2) != '--' {
|
||||||
@error "Variable name is expected to start from '--'";
|
@error "Variable name is expected to start from '--'";
|
||||||
}
|
}
|
||||||
|
|
||||||
// PROCESS
|
// PROCESS
|
||||||
$var-name: nth($args, 1);
|
$var-name: list.nth($args, 1);
|
||||||
$var-value: map-get($css-vars, $var-name);
|
$var-value: map.get($css-vars, $var-name);
|
||||||
|
|
||||||
@if ($css-vars-use-native) {
|
@if $css-vars-use-native {
|
||||||
// CSS variables
|
// CSS variables
|
||||||
// Native CSS: don't process function in case of native
|
// Native CSS: don't process function in case of native
|
||||||
@return unquote('var(' + $args + ')');
|
@return unquote('var(' + $args + ')');
|
||||||
} @else {
|
} @else {
|
||||||
@if ($var-value == null) {
|
@if not $var-value {
|
||||||
// variable is not provided so far
|
// variable is not provided so far
|
||||||
@if (length($args) == 2) {
|
@if length($args) == 2 {
|
||||||
$var-value: nth($args, 2);
|
$var-value: list.nth($args, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,7 +62,7 @@ $css-vars-use-native: false !default;
|
|||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
// SASS mixin to provide variables
|
// Sass mixin to provide variables
|
||||||
// E.G.:
|
// E.G.:
|
||||||
// @include css-vars((
|
// @include css-vars((
|
||||||
// --color: rebeccapurple,
|
// --color: rebeccapurple,
|
||||||
@ -70,20 +72,21 @@ $css-vars-use-native: false !default;
|
|||||||
///
|
///
|
||||||
@mixin css-vars($var-map: null) {
|
@mixin css-vars($var-map: null) {
|
||||||
// CHECK PARAMS
|
// CHECK PARAMS
|
||||||
@if ($var-map == null) {
|
@if not $var-map {
|
||||||
@error 'Map of variables is expected, instead got: null';
|
@error 'Map of variables is expected, instead got: null';
|
||||||
}
|
}
|
||||||
@if (type_of($var-map) != map) {
|
|
||||||
|
@if type_of($var-map) != map {
|
||||||
@error 'Map of variables is expected, instead got another type passed: #{type_of($var, ap)}';
|
@error 'Map of variables is expected, instead got another type passed: #{type_of($var, ap)}';
|
||||||
}
|
}
|
||||||
|
|
||||||
// PROCESS
|
// PROCESS
|
||||||
@if ($css-vars-use-native) {
|
@if $css-vars-use-native {
|
||||||
// CSS variables
|
// CSS variables
|
||||||
// Native CSS: assign CSS custom properties to the global scope
|
// Native CSS: assign CSS custom properties to the global scope
|
||||||
@at-root :root {
|
@at-root :root {
|
||||||
@each $var-name, $var-value in $var-map {
|
@each $var-name, $var-value in $var-map {
|
||||||
@if (type_of($var-value) == string) {
|
@if type_of($var-value) == string {
|
||||||
#{$var-name}: $var-value; // to prevent quotes interpolation
|
#{$var-name}: $var-value; // to prevent quotes interpolation
|
||||||
} @else {
|
} @else {
|
||||||
#{$var-name}: #{$var-value};
|
#{$var-name}: #{$var-value};
|
||||||
|
@ -1,7 +1,3 @@
|
|||||||
// ==========================================================================
|
|
||||||
// Useful functions
|
|
||||||
// ==========================================================================
|
|
||||||
|
|
||||||
@function to-percentage($input) {
|
@function to-percentage($input) {
|
||||||
@return $input * 1%;
|
@return $input * 1%;
|
||||||
}
|
}
|
||||||
|
@ -4,11 +4,9 @@
|
|||||||
|
|
||||||
// Nicer focus styles
|
// Nicer focus styles
|
||||||
// ---------------------------------------
|
// ---------------------------------------
|
||||||
@mixin plyr-tab-focus($color: $plyr-tab-focus-color) {
|
@mixin plyr-focus-visible($color: $plyr-focus-visible-color) {
|
||||||
outline-color: $color;
|
outline: 2px dashed $color;
|
||||||
outline-offset: 2px;
|
outline-offset: 2px;
|
||||||
outline-style: dotted;
|
|
||||||
outline-width: 3px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Font smoothing
|
// Font smoothing
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
z-index: 3;
|
z-index: 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
&::after:empty {
|
&:empty::after {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -47,10 +47,10 @@
|
|||||||
display: block;
|
display: block;
|
||||||
height: $plyr-range-track-height;
|
height: $plyr-range-track-height;
|
||||||
left: 0;
|
left: 0;
|
||||||
margin: -($plyr-range-track-height / 2) 0 0;
|
|
||||||
opacity: 0.8;
|
opacity: 0.8;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 50%;
|
top: 50%;
|
||||||
|
transform: translateY(-50%);
|
||||||
width: 3px;
|
width: 3px;
|
||||||
z-index: 3; // Between progress and thumb
|
z-index: 3; // Between progress and thumb
|
||||||
}
|
}
|
||||||
|
@ -6,12 +6,12 @@
|
|||||||
|
|
||||||
.plyr__preview-thumb {
|
.plyr__preview-thumb {
|
||||||
background-color: $plyr-preview-background;
|
background-color: $plyr-preview-background;
|
||||||
border-radius: 3px;
|
border-radius: $plyr-preview-radius;
|
||||||
bottom: 100%;
|
bottom: 100%;
|
||||||
box-shadow: $plyr-preview-shadow;
|
box-shadow: $plyr-preview-shadow;
|
||||||
margin-bottom: calc(#{$plyr-preview-padding} * 2);
|
margin-bottom: calc(#{$plyr-preview-padding} * 2);
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
padding: $plyr-preview-radius;
|
padding: 3px;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
transform: translate(0, 10px) scale(0.8);
|
transform: translate(0, 10px) scale(0.8);
|
||||||
@ -32,7 +32,7 @@
|
|||||||
bottom: calc(#{$plyr-preview-arrow-size} * -1);
|
bottom: calc(#{$plyr-preview-arrow-size} * -1);
|
||||||
content: '';
|
content: '';
|
||||||
height: 0;
|
height: 0;
|
||||||
left: 50%;
|
left: calc(50% + var(--preview-arrow-offset));
|
||||||
position: absolute;
|
position: absolute;
|
||||||
transform: translateX(-50%);
|
transform: translateX(-50%);
|
||||||
width: 0;
|
width: 0;
|
||||||
@ -46,32 +46,45 @@
|
|||||||
position: relative;
|
position: relative;
|
||||||
z-index: 0;
|
z-index: 0;
|
||||||
|
|
||||||
img {
|
img,
|
||||||
height: 100%; // Non sprite images are 100%. Sprites will have their size applied by JavaScript
|
&::after {
|
||||||
|
height: 100%;
|
||||||
left: 0;
|
left: 0;
|
||||||
max-height: none;
|
|
||||||
max-width: none;
|
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
width: 100%;
|
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
|
// Seek time text
|
||||||
&__time-container {
|
&__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;
|
left: 0;
|
||||||
|
line-height: 1.1;
|
||||||
|
padding: $plyr-preview-time-container-padding;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 0;
|
right: 0;
|
||||||
white-space: nowrap;
|
|
||||||
z-index: 3;
|
z-index: 3;
|
||||||
|
|
||||||
span {
|
span {
|
||||||
background-color: $plyr-preview-time-background;
|
|
||||||
border-radius: calc(#{$plyr-preview-radius} - 1px);
|
|
||||||
color: $plyr-preview-time-color;
|
color: $plyr-preview-time-color;
|
||||||
font-size: $plyr-preview-time-font-size;
|
font-size: $plyr-preview-time-font-size;
|
||||||
padding: $plyr-preview-time-padding;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,12 +4,14 @@
|
|||||||
|
|
||||||
$plyr-preview-padding: $plyr-tooltip-padding !default;
|
$plyr-preview-padding: $plyr-tooltip-padding !default;
|
||||||
$plyr-preview-background: $plyr-tooltip-background !default;
|
$plyr-preview-background: $plyr-tooltip-background !default;
|
||||||
$plyr-preview-radius: $plyr-tooltip-radius !default;
|
$plyr-preview-radius: $plyr-menu-radius !default;
|
||||||
$plyr-preview-shadow: $plyr-tooltip-shadow !default;
|
$plyr-preview-shadow: $plyr-tooltip-shadow !default;
|
||||||
$plyr-preview-arrow-size: $plyr-tooltip-arrow-size !default;
|
$plyr-preview-arrow-size: $plyr-tooltip-arrow-size !default;
|
||||||
$plyr-preview-image-background: $plyr-color-gray-200 !default;
|
$plyr-preview-image-background: $plyr-color-gray-200 !default;
|
||||||
$plyr-preview-time-font-size: $plyr-font-size-time !default;
|
$plyr-preview-time-container-background: var(
|
||||||
$plyr-preview-time-padding: 3px 6px !default;
|
--plyr-video-controls-background,
|
||||||
$plyr-preview-time-background: rgba(0, 0, 0, 0.55);
|
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-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
|
// Plyr styles
|
||||||
// https://github.com/sampotts/plyr
|
// https://github.com/sampotts/plyr
|
||||||
// TODO: Review use of BEM classnames
|
// TODO: Review use of BEM classnames
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
@charset 'UTF-8';
|
|
||||||
|
|
||||||
@import 'lib/css-vars';
|
@import 'lib/css-vars';
|
||||||
|
|
||||||
$css-vars-use-native: true;
|
$css-vars-use-native: true;
|
||||||
|
|
||||||
@import 'settings/breakpoints';
|
@import 'settings/breakpoints';
|
||||||
@import 'settings/colors';
|
@import 'settings/colors';
|
||||||
@import 'settings/cosmetics';
|
@import 'settings/cosmetics';
|
||||||
@import 'settings/type';
|
@import 'settings/type';
|
||||||
|
|
||||||
@import 'settings/badges';
|
@import 'settings/badges';
|
||||||
@import 'settings/captions';
|
@import 'settings/captions';
|
||||||
@import 'settings/controls';
|
@import 'settings/controls';
|
||||||
@ -21,13 +22,10 @@ $css-vars-use-native: true;
|
|||||||
@import 'settings/progress';
|
@import 'settings/progress';
|
||||||
@import 'settings/sliders';
|
@import 'settings/sliders';
|
||||||
@import 'settings/tooltips';
|
@import 'settings/tooltips';
|
||||||
|
|
||||||
@import 'lib/animation';
|
@import 'lib/animation';
|
||||||
@import 'lib/functions';
|
@import 'lib/functions';
|
||||||
@import 'lib/mixins';
|
@import 'lib/mixins';
|
||||||
|
|
||||||
@import 'base';
|
@import 'base';
|
||||||
|
|
||||||
@import 'components/badges';
|
@import 'components/badges';
|
||||||
@import 'components/captions';
|
@import 'components/captions';
|
||||||
@import 'components/control';
|
@import 'components/control';
|
||||||
@ -39,14 +37,10 @@ $css-vars-use-native: true;
|
|||||||
@import 'components/tooltips';
|
@import 'components/tooltips';
|
||||||
@import 'components/progress';
|
@import 'components/progress';
|
||||||
@import 'components/volume';
|
@import 'components/volume';
|
||||||
|
|
||||||
@import 'types/audio';
|
@import 'types/audio';
|
||||||
@import 'types/video';
|
@import 'types/video';
|
||||||
|
|
||||||
@import 'states/fullscreen';
|
@import 'states/fullscreen';
|
||||||
|
|
||||||
@import 'plugins/ads';
|
@import 'plugins/ads';
|
||||||
@import 'plugins/preview-thumbnails/index';
|
@import 'plugins/preview-thumbnails/index';
|
||||||
|
|
||||||
@import 'utils/animation';
|
@import 'utils/animation';
|
||||||
@import 'utils/hidden';
|
@import 'utils/hidden';
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
$plyr-captions-background: var(--plyr-captions-background, rgba(#000, 0.8)) !default;
|
$plyr-captions-background: var(--plyr-captions-background, rgba(#000, 0.8)) !default;
|
||||||
$plyr-captions-text-color: var(--plyr-captions-text-color, #fff) !default;
|
$plyr-captions-text-color: var(--plyr-captions-text-color, #fff) !default;
|
||||||
|
|
||||||
$plyr-font-size-captions-base: $plyr-font-size-base !default;
|
$plyr-font-size-captions-base: $plyr-font-size-base !default;
|
||||||
$plyr-font-size-captions-small: $plyr-font-size-small !default;
|
$plyr-font-size-captions-small: $plyr-font-size-small !default;
|
||||||
$plyr-font-size-captions-medium: $plyr-font-size-large !default;
|
$plyr-font-size-captions-medium: $plyr-font-size-large !default;
|
||||||
|
@ -2,17 +2,17 @@
|
|||||||
// Colors
|
// Colors
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
|
|
||||||
$plyr-color-main: var(--plyr-color-main, hsl(198, 100%, 50%)) !default;
|
$plyr-color-main: var(--plyr-color-main, hsl(198deg 100% 50%)) !default;
|
||||||
$plyr-video-background: var(--plyr-video-background, rgba(0,0,0,1)) !default;
|
$plyr-video-background: var(--plyr-video-background, rgb(0 0 0 / 100%)) !default;
|
||||||
|
|
||||||
// Grayscale
|
// Grayscale
|
||||||
$plyr-color-gray-900: hsl(216, 15%, 16%) !default;
|
$plyr-color-gray-900: hsl(216deg 15% 16%) !default;
|
||||||
$plyr-color-gray-800: hsl(216, 15%, 25%) !default;
|
$plyr-color-gray-800: hsl(216deg 15% 25%) !default;
|
||||||
$plyr-color-gray-700: hsl(216, 15%, 34%) !default;
|
$plyr-color-gray-700: hsl(216deg 15% 34%) !default;
|
||||||
$plyr-color-gray-600: hsl(216, 15%, 43%) !default;
|
$plyr-color-gray-600: hsl(216deg 15% 43%) !default;
|
||||||
$plyr-color-gray-500: hsl(216, 15%, 52%) !default;
|
$plyr-color-gray-500: hsl(216deg 15% 52%) !default;
|
||||||
$plyr-color-gray-400: hsl(216, 15%, 61%) !default;
|
$plyr-color-gray-400: hsl(216deg 15% 61%) !default;
|
||||||
$plyr-color-gray-300: hsl(216, 15%, 70%) !default;
|
$plyr-color-gray-300: hsl(216deg 15% 70%) !default;
|
||||||
$plyr-color-gray-200: hsl(216, 15%, 79%) !default;
|
$plyr-color-gray-200: hsl(216deg 15% 79%) !default;
|
||||||
$plyr-color-gray-100: hsl(216, 15%, 88%) !default;
|
$plyr-color-gray-100: hsl(216deg 15% 88%) !default;
|
||||||
$plyr-color-gray-50: hsl(216, 15%, 97%) !default;
|
$plyr-color-gray-50: hsl(216deg 15% 97%) !default;
|
||||||
|
@ -6,13 +6,11 @@ $plyr-control-icon-size: var(--plyr-control-icon-size, 18px) !default;
|
|||||||
$plyr-control-spacing: var(--plyr-control-spacing, 10px) !default;
|
$plyr-control-spacing: var(--plyr-control-spacing, 10px) !default;
|
||||||
$plyr-control-padding: calc(#{$plyr-control-spacing} * 0.7);
|
$plyr-control-padding: calc(#{$plyr-control-spacing} * 0.7);
|
||||||
$plyr-control-padding: var(--plyr-control-padding, $plyr-control-padding) !default;
|
$plyr-control-padding: var(--plyr-control-padding, $plyr-control-padding) !default;
|
||||||
$plyr-control-radius: var(--plyr-control-radius, 3px) !default;
|
$plyr-control-radius: var(--plyr-control-radius, 4px) !default;
|
||||||
|
|
||||||
$plyr-control-toggle-checked-background: var(
|
$plyr-control-toggle-checked-background: var(
|
||||||
--plyr-control-toggle-checked-background,
|
--plyr-control-toggle-checked-background,
|
||||||
var(--plyr-color-main, $plyr-color-main)
|
var(--plyr-color-main, $plyr-color-main)
|
||||||
) !default;
|
) !default;
|
||||||
|
|
||||||
$plyr-video-controls-background: var(
|
$plyr-video-controls-background: var(
|
||||||
--plyr-video-controls-background,
|
--plyr-video-controls-background,
|
||||||
linear-gradient(rgba(#000, 0), rgba(#000, 0.75))
|
linear-gradient(rgba(#000, 0), rgba(#000, 0.75))
|
||||||
@ -23,7 +21,6 @@ $plyr-video-control-background-hover: var(
|
|||||||
--plyr-video-control-background-hover,
|
--plyr-video-control-background-hover,
|
||||||
var(--plyr-color-main, $plyr-color-main)
|
var(--plyr-color-main, $plyr-color-main)
|
||||||
) !default;
|
) !default;
|
||||||
|
|
||||||
$plyr-audio-controls-background: var(--plyr-audio-controls-background, #fff) !default;
|
$plyr-audio-controls-background: var(--plyr-audio-controls-background, #fff) !default;
|
||||||
$plyr-audio-control-color: var(--plyr-audio-control-color, $plyr-color-gray-700) !default;
|
$plyr-audio-control-color: var(--plyr-audio-control-color, $plyr-color-gray-700) !default;
|
||||||
$plyr-audio-control-color-hover: var(--plyr-audio-control-color-hover, #fff) !default;
|
$plyr-audio-control-color-hover: var(--plyr-audio-control-color-hover, #fff) !default;
|
||||||
|
@ -2,4 +2,4 @@
|
|||||||
// Cosmetic
|
// Cosmetic
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
|
|
||||||
$plyr-tab-focus-color: var(--plyr-tab-focus-color, var(--plyr-color-main, $plyr-color-main)) !default;
|
$plyr-focus-visible-color: var(--plyr-focus-visible-color, var(--plyr-color-main, $plyr-color-main)) !default;
|
||||||
|
@ -3,13 +3,11 @@
|
|||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
|
|
||||||
$plyr-menu-background: var(--plyr-menu-background, rgba(#fff, 0.9)) !default;
|
$plyr-menu-background: var(--plyr-menu-background, rgba(#fff, 0.9)) !default;
|
||||||
$plyr-menu-radius: var(--plyr-menu-radius, 4px) !default;
|
$plyr-menu-radius: var(--plyr-menu-radius, 8px) !default;
|
||||||
$plyr-menu-color: var(--plyr-menu-color, $plyr-color-gray-700) !default;
|
$plyr-menu-color: var(--plyr-menu-color, $plyr-color-gray-700) !default;
|
||||||
$plyr-menu-shadow: var(--plyr-menu-shadow, 0 1px 2px rgba(#000, 0.15)) !default;
|
$plyr-menu-shadow: var(--plyr-menu-shadow, 0 1px 2px rgba(#000, 0.15)) !default;
|
||||||
$plyr-menu-arrow-size: var(--plyr-menu-arrow-size, 4px) !default;
|
$plyr-menu-arrow-size: var(--plyr-menu-arrow-size, 4px) !default;
|
||||||
|
|
||||||
$plyr-menu-item-arrow-size: var(--plyr-menu-item-arrow-size, 4px) !default;
|
$plyr-menu-item-arrow-size: var(--plyr-menu-item-arrow-size, 4px) !default;
|
||||||
$plyr-menu-item-arrow-color: var(--plyr-menu-arrow-color, $plyr-color-gray-500) !default;
|
$plyr-menu-item-arrow-color: var(--plyr-menu-arrow-color, $plyr-color-gray-500) !default;
|
||||||
|
|
||||||
$plyr-menu-back-border-color: var(--plyr-menu-back-border-color, $plyr-color-gray-100) !default;
|
$plyr-menu-back-border-color: var(--plyr-menu-back-border-color, $plyr-color-gray-100) !default;
|
||||||
$plyr-menu-back-border-shadow-color: var(--plyr-menu-back-border-shadow-color, #fff) !default;
|
$plyr-menu-back-border-shadow-color: var(--plyr-menu-back-border-shadow-color, #fff) !default;
|
||||||
|
@ -6,6 +6,10 @@
|
|||||||
$plyr-progress-loading-size: var(--plyr-progress-loading-size, 25px) !default;
|
$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;
|
$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
|
// Buffered
|
||||||
$plyr-video-progress-buffered-background: var(--plyr-video-progress-buffered-background, rgba(#fff, 0.25)) !default;
|
$plyr-video-progress-buffered-background: var(--plyr-video-progress-buffered-background, rgba(#fff, 0.25)) !default;
|
||||||
$plyr-audio-progress-buffered-background: var(
|
$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,
|
--plyr-audio-range-thumb-active-shadow-color,
|
||||||
rgba(#fff, 0.5)
|
rgba(#fff, 0.5)
|
||||||
) !default;
|
) !default;
|
||||||
|
|
||||||
$plyr-audio-range-track-background: var(
|
$plyr-audio-range-track-background: var(
|
||||||
--plyr-audio-range-track-background,
|
--plyr-audio-range-track-background,
|
||||||
$plyr-audio-progress-buffered-background
|
$plyr-audio-progress-buffered-background
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
// Tooltips
|
// Tooltips
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
|
|
||||||
$plyr-tooltip-background: var(--plyr-tooltip-background, rgba(#fff, 0.9)) !default;
|
$plyr-tooltip-background: var(--plyr-tooltip-background, #fff) !default;
|
||||||
$plyr-tooltip-color: var(--plyr-tooltip-color, $plyr-color-gray-700) !default;
|
$plyr-tooltip-color: var(--plyr-tooltip-color, $plyr-color-gray-700) !default;
|
||||||
$plyr-tooltip-padding: calc(#{$plyr-control-spacing} / 2);
|
$plyr-tooltip-padding: calc(#{$plyr-control-spacing} / 2);
|
||||||
$plyr-tooltip-padding: var(--plyr-tooltip-padding, $plyr-tooltip-padding) !default;
|
$plyr-tooltip-padding: var(--plyr-tooltip-padding, $plyr-tooltip-padding) !default;
|
||||||
$plyr-tooltip-arrow-size: var(--plyr-tooltip-arrow-size, 4px) !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;
|
$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-small: var(--plyr-font-size-small, 13px) !default;
|
||||||
$plyr-font-size-large: var(--plyr-font-size-large, 18px) !default;
|
$plyr-font-size-large: var(--plyr-font-size-large, 18px) !default;
|
||||||
$plyr-font-size-xlarge: var(--plyr-font-size-xlarge, 21px) !default;
|
$plyr-font-size-xlarge: var(--plyr-font-size-xlarge, 21px) !default;
|
||||||
|
|
||||||
$plyr-font-size-time: var(--plyr-font-size-time, $plyr-font-size-small) !default;
|
$plyr-font-size-time: var(--plyr-font-size-time, $plyr-font-size-small) !default;
|
||||||
$plyr-font-size-menu: var(--plyr-font-size-menu, $plyr-font-size-small) !default;
|
$plyr-font-size-menu: var(--plyr-font-size-menu, $plyr-font-size-small) !default;
|
||||||
$plyr-font-size-badge: var(--plyr-font-size-badge, 9px) !default;
|
$plyr-font-size-badge: var(--plyr-font-size-badge, 9px) !default;
|
||||||
|
|
||||||
$plyr-font-weight-regular: var(--plyr-font-weight-regular, 400) !default;
|
$plyr-font-weight-regular: var(--plyr-font-weight-regular, 400) !default;
|
||||||
$plyr-font-weight-bold: var(--plyr-font-weight-bold, 600) !default;
|
$plyr-font-weight-bold: var(--plyr-font-weight-bold, 600) !default;
|
||||||
|
|
||||||
$plyr-line-height: var(--plyr-line-height, 1.7) !default;
|
$plyr-line-height: var(--plyr-line-height, 1.7) !default;
|
||||||
|
|
||||||
$plyr-font-smoothing: var(--plyr-font-smoothing, false) !default;
|
$plyr-font-smoothing: var(--plyr-font-smoothing, false) !default;
|
||||||
|
@ -3,29 +3,14 @@
|
|||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
|
|
||||||
.plyr:fullscreen {
|
.plyr:fullscreen {
|
||||||
@include plyr-fullscreen-active();
|
@include plyr-fullscreen-active;
|
||||||
}
|
|
||||||
|
|
||||||
/* stylelint-disable-next-line */
|
|
||||||
.plyr:-webkit-full-screen {
|
|
||||||
@include plyr-fullscreen-active();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* stylelint-disable-next-line */
|
|
||||||
.plyr:-moz-full-screen {
|
|
||||||
@include plyr-fullscreen-active();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* stylelint-disable-next-line */
|
|
||||||
.plyr:-ms-fullscreen {
|
|
||||||
@include plyr-fullscreen-active();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback for unsupported browsers
|
// Fallback for unsupported browsers
|
||||||
.plyr--fullscreen-fallback {
|
.plyr--fullscreen-fallback {
|
||||||
@include plyr-fullscreen-active();
|
@include plyr-fullscreen-active;
|
||||||
|
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
display: block;
|
|
||||||
left: 0;
|
left: 0;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
right: 0;
|
right: 0;
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
// Control elements
|
// Control elements
|
||||||
.plyr--audio .plyr__control {
|
.plyr--audio .plyr__control {
|
||||||
&.plyr__tab-focus,
|
&:focus-visible,
|
||||||
&:hover,
|
&:hover,
|
||||||
&[aria-expanded='true'] {
|
&[aria-expanded='true'] {
|
||||||
background: $plyr-audio-control-background-hover;
|
background: $plyr-audio-control-background-hover;
|
||||||
|
@ -2,9 +2,10 @@
|
|||||||
// Video styles
|
// Video styles
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
|
|
||||||
|
@use 'sass:math';
|
||||||
|
|
||||||
// Container
|
// Container
|
||||||
.plyr--video {
|
.plyr--video {
|
||||||
background: var(--plyr-video-background, $plyr-video-background);
|
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
||||||
&.plyr--menu-open {
|
&.plyr--menu-open {
|
||||||
@ -14,6 +15,8 @@
|
|||||||
|
|
||||||
.plyr__video-wrapper {
|
.plyr__video-wrapper {
|
||||||
background: var(--plyr-video-background, $plyr-video-background);
|
background: var(--plyr-video-background, $plyr-video-background);
|
||||||
|
border-radius: inherit;
|
||||||
|
height: 100%;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
position: relative;
|
position: relative;
|
||||||
@ -21,7 +24,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Default to 16:9 ratio but this is set by JavaScript based on config
|
// Default to 16:9 ratio but this is set by JavaScript based on config
|
||||||
$embed-padding: ((100 / 16) * 9);
|
$embed-padding: (math.div(100, 16) * 9);
|
||||||
|
|
||||||
.plyr__video-embed,
|
.plyr__video-embed,
|
||||||
.plyr__video-wrapper--fixed-ratio {
|
.plyr__video-wrapper--fixed-ratio {
|
||||||
@ -47,7 +50,8 @@ $embed-padding: ((100 / 16) * 9);
|
|||||||
// For Vimeo, if the full custom UI is supported
|
// For Vimeo, if the full custom UI is supported
|
||||||
.plyr--full-ui .plyr__video-embed > .plyr__video-embed__container {
|
.plyr--full-ui .plyr__video-embed > .plyr__video-embed__container {
|
||||||
$height: 240;
|
$height: 240;
|
||||||
$offset: to-percentage(($height - $embed-padding) / ($height / 50));
|
$offset: to-percentage(math.div($height - $embed-padding, math.div($height, 50)));
|
||||||
|
|
||||||
padding-bottom: to-percentage($height);
|
padding-bottom: to-percentage($height);
|
||||||
position: relative;
|
position: relative;
|
||||||
transform: translateY(-$offset);
|
transform: translateY(-$offset);
|
||||||
@ -83,8 +87,7 @@ $embed-padding: ((100 / 16) * 9);
|
|||||||
|
|
||||||
// Control elements
|
// Control elements
|
||||||
.plyr--video .plyr__control {
|
.plyr--video .plyr__control {
|
||||||
// Hover and tab focus
|
&:focus-visible,
|
||||||
&.plyr__tab-focus,
|
|
||||||
&:hover,
|
&:hover,
|
||||||
&[aria-expanded='true'] {
|
&[aria-expanded='true'] {
|
||||||
background: $plyr-video-control-background-hover;
|
background: $plyr-video-control-background-hover;
|
||||||
|
@ -13,7 +13,7 @@ const babel = require('rollup-plugin-babel');
|
|||||||
const commonjs = require('rollup-plugin-commonjs');
|
const commonjs = require('rollup-plugin-commonjs');
|
||||||
const resolve = require('rollup-plugin-node-resolve');
|
const resolve = require('rollup-plugin-node-resolve');
|
||||||
// CSS
|
// CSS
|
||||||
const sass = require('gulp-sass');
|
const sass = require('gulp-sass')(require('sass'));
|
||||||
const postcss = require('gulp-postcss');
|
const postcss = require('gulp-postcss');
|
||||||
const autoprefixer = require('autoprefixer');
|
const autoprefixer = require('autoprefixer');
|
||||||
const cssnano = require('cssnano');
|
const cssnano = require('cssnano');
|
||||||
@ -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,
|
babelrc: false,
|
||||||
exclude: [/\/core-js\//],
|
exclude: [/\/core-js\//],
|
||||||
}),
|
}),
|
||||||
|
@ -51,11 +51,19 @@ const paths = {
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
// Get branch info
|
// Get git branch info
|
||||||
|
const currentBranch = (() => {
|
||||||
|
try {
|
||||||
|
return gitbranch.sync();
|
||||||
|
} catch (_) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
const branch = {
|
const branch = {
|
||||||
current: gitbranch.sync(),
|
current: currentBranch,
|
||||||
master: 'master',
|
isMaster: currentBranch === 'master',
|
||||||
beta: 'beta',
|
isBeta: currentBranch === 'beta',
|
||||||
};
|
};
|
||||||
|
|
||||||
const maxAge = 31536000; // 1 year
|
const maxAge = 31536000; // 1 year
|
||||||
@ -66,7 +74,7 @@ const options = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
demo: {
|
demo: {
|
||||||
uploadPath: branch.current === branch.beta ? '/beta' : null,
|
uploadPath: branch.isBeta ? '/beta' : null,
|
||||||
headers: {
|
headers: {
|
||||||
'Cache-Control': 'no-cache, no-store, must-revalidate, max-age=0',
|
'Cache-Control': 'no-cache, no-store, must-revalidate, max-age=0',
|
||||||
},
|
},
|
||||||
@ -99,11 +107,8 @@ const renameFile = rename((p) => {
|
|||||||
|
|
||||||
// Check we're on the correct branch to deploy
|
// Check we're on the correct branch to deploy
|
||||||
const canDeploy = () => {
|
const canDeploy = () => {
|
||||||
const allowed = [branch.master, branch.beta];
|
if (![branch.isMaster, branch.isBeta].some(Boolean)) {
|
||||||
|
console.error(`Must be on an allowed branch to publish! (current: ${branch.current})`);
|
||||||
if (!allowed.includes(branch.current)) {
|
|
||||||
console.error(`Must be on ${allowed.join(', ')} to publish! (current: ${branch.current})`);
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,7 +200,7 @@ gulp.task('demo', (done) => {
|
|||||||
const error = `${paths.demo}error.html`;
|
const error = `${paths.demo}error.html`;
|
||||||
const pages = [index];
|
const pages = [index];
|
||||||
|
|
||||||
if (branch.current === branch.master) {
|
if (branch.isMaster) {
|
||||||
pages.push(error);
|
pages.push(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,7 +225,7 @@ gulp.task('open', () => {
|
|||||||
|
|
||||||
return gulp.src(__filename).pipe(
|
return gulp.src(__filename).pipe(
|
||||||
open({
|
open({
|
||||||
uri: `https://${domain}/${branch.current === branch.beta ? 'beta' : ''}`,
|
uri: `https://${domain}/${branch.isBeta ? 'beta' : ''}`,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user