Compare commits
194 Commits
Author | SHA1 | Date | |
---|---|---|---|
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 | |||
ba236c4753 | |||
a204f7c1dd | |||
bacf9122de | |||
2fdc1eac94 | |||
5fd4391cd9 | |||
6991358428 | |||
b050fde276 | |||
32444c9851 | |||
b93dcc43ad | |||
6ff6ff1673 | |||
e1ff86820c | |||
7d22c361d1 | |||
951cccb6b0 | |||
438e425838 | |||
ddb5ad071e | |||
38060d986c | |||
8c74396459 | |||
a09d63e8f8 | |||
d74af9a73d | |||
60310693d3 | |||
5d08821c9b | |||
3316e40e7b | |||
dfe5985326 | |||
b27ad17c59 | |||
14b8b24e14 | |||
711fc5835f | |||
028be22dec | |||
3b5dc09285 | |||
8596e05df3 | |||
1aee8f53a7 | |||
a187d07807 | |||
3096dd9513 | |||
150b07f3ef | |||
ad7778e78d | |||
c8e776bbea | |||
c66dc8bf95 | |||
ea87b9c788 | |||
aa3378fd73 | |||
2cebf9b8a3 | |||
572aeacf5b | |||
b5592b0fb5 | |||
9adf35a444 | |||
39ff31e3e3 | |||
7e82ec6d70 | |||
f4d6a243cd | |||
31b5027b1e | |||
7750314058 | |||
16c134fc1e | |||
f00e81a976 | |||
32a4039f7c | |||
ba09bc32d3 | |||
d7195d5276 | |||
6a6fb8d41a | |||
c853adc760 | |||
ca041f2e0d | |||
87078d7a44 | |||
c300df5742 | |||
2ba56fda15 | |||
36b53d2cf0 | |||
2d4686a5f3 | |||
31861bd475 | |||
c3e163741f | |||
1c715bc889 | |||
35ef42246b | |||
cd3962ca32 | |||
da16c55427 | |||
bd8bacb6d5 | |||
0d393a5c92 | |||
136bb525a5 | |||
e85737d855 | |||
8882317080 | |||
5c02205a4f | |||
45f7e20233 | |||
b116e62f37 | |||
fa6282d0e2 | |||
80bdf04fde | |||
3caa37fdf2 | |||
807efcbc46 | |||
03d1e3d3e8 | |||
664e2b4893 | |||
4cf36bf203 | |||
92f3728d80 | |||
29d3ae0b67 | |||
df91f7faac | |||
9a69ae2599 | |||
02321c35bc | |||
7c6316d824 | |||
776b0c4036 | |||
fa653a8859 | |||
b6b7db7327 | |||
d4b4303b8e | |||
102fb1a32f | |||
c77ba3ecf0 | |||
760f5f9469 | |||
0135e9c7f4 | |||
2426c256cc | |||
93eed08d14 | |||
5a164780d8 | |||
272d39c1d1 | |||
828abc8308 | |||
6455a6acc0 | |||
51cb03dc32 | |||
4d25a33cb0 | |||
18b3f23c69 | |||
11e48b0181 | |||
3a07669e30 | |||
b3d390076b | |||
f75820fbd3 | |||
8b0d84a9a4 | |||
d582e43413 | |||
75082bc73f | |||
f7e9ee56d2 | |||
22af7f16ea | |||
9076d054b9 | |||
4eaa1a72b5 | |||
4c1ae8f3ce | |||
0733133510 | |||
423b7b276f | |||
cbd4a7cef4 | |||
8ce7425f73 | |||
1f63806c3f | |||
6cb822d56f | |||
9dee5acec6 |
5
.github/pull_request_template.md
vendored
5
.github/pull_request_template.md
vendored
@ -1,8 +1,3 @@
|
||||
### Link to related issue (if applicable)
|
||||
|
||||
### Summary of proposed changes
|
||||
|
||||
### Checklist
|
||||
- [ ] Use `develop` as the base branch
|
||||
- [ ] Exclude the gulp build (`/dist` changes) from the PR
|
||||
- [ ] Test on [supported browsers](https://github.com/sampotts/plyr#browser-support)
|
||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -2,8 +2,8 @@ node_modules
|
||||
.DS_Store
|
||||
credentials.json
|
||||
*.mp4
|
||||
!dist/blank.mp4
|
||||
npm-debug.log
|
||||
yarn-error.log
|
||||
*.webm
|
||||
.idea/
|
||||
dist/
|
||||
|
@ -7,6 +7,6 @@ credentials.json
|
||||
deploy.json
|
||||
yarn.lock
|
||||
package-lock.json
|
||||
*.mp4
|
||||
*.webm
|
||||
*.mp4
|
||||
!dist/blank.mp4
|
||||
|
@ -1,6 +1,7 @@
|
||||
{
|
||||
"plugins": ["stylelint-selector-bem-pattern", "stylelint-scss"],
|
||||
"extends": ["stylelint-config-recommended", "stylelint-config-sass-guidelines", "stylelint-config-prettier"],
|
||||
"plugins": ["stylelint-selector-bem-pattern"],
|
||||
"extends": ["stylelint-config-sass-guidelines", "stylelint-config-prettier"],
|
||||
"customSyntax": "postcss-scss",
|
||||
"rules": {
|
||||
"selector-class-pattern": null,
|
||||
"selector-no-qualifying-type": [
|
||||
@ -9,10 +10,7 @@
|
||||
"ignore": ["attribute", "class"]
|
||||
}
|
||||
],
|
||||
"string-no-newline": null,
|
||||
"indentation": 2,
|
||||
"string-quotes": "single",
|
||||
"max-nesting-depth": 2,
|
||||
"max-nesting-depth": 4,
|
||||
"plugin/selector-bem-pattern": {
|
||||
"preset": "bem",
|
||||
"componentName": "(([a-z0-9]+(?!-$)-?)+)",
|
||||
|
@ -1,8 +0,0 @@
|
||||
language: node_js
|
||||
node_js: lts/*
|
||||
|
||||
script:
|
||||
- bash .travis/prevent-base-master.sh
|
||||
- bash .travis/omit-dist.sh
|
||||
- npm run lint
|
||||
- npm run build
|
@ -1,5 +0,0 @@
|
||||
#!/bin/bash
|
||||
if [ $TRAVIS_BRANCH == "develop" ] && $(git diff --name-only $TRAVIS_COMMIT_RANGE | grep -qE "^(demo/)?dist/"); then
|
||||
echo 'Build output ("dist" and "demo/dist") not permitted in develop' >&2
|
||||
exit 1
|
||||
fi
|
@ -1,5 +0,0 @@
|
||||
#!/bin/bash
|
||||
if [ "$TRAVIS_PULL_REQUEST" != "false" ] && [ $TRAVIS_BRANCH == "master" ] && $(git diff --name-only $TRAVIS_COMMIT_RANGE | grep -q "^src/"); then
|
||||
echo 'The base branch for pull requests must be "develop"' >&2
|
||||
exit 1
|
||||
fi
|
101
CHANGELOG.md
101
CHANGELOG.md
@ -1,3 +1,80 @@
|
||||
## 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
|
||||
|
||||
- Typings: add FullscreenOptions.container to typing files (thanks @MeguminSama!)
|
||||
- Fix: added iPadOS detection to isIos util (thanks @Benny739!)
|
||||
- Fix: issues with Vimeo fullscreen
|
||||
|
||||
### v3.6.7
|
||||
|
||||
- Fix: remove regression caused by optional chaining and nullish coalescing in check for `window.CSS` check for aspect-ratio (fixes #2174)
|
||||
|
||||
### v3.6.6
|
||||
|
||||
- Improvements to how aspect ratio is handled. Use `aspect-ratio` CSS property instead of the legacy method (still used as fallback). Also automatically determined aspect ratios are rounded to the nearast standard ratio. This fixes issues with the YouTube embeds showing a 1-2px black bar.
|
||||
- Hide the YouTube poster image container when paused so that the controls underneath can be used.
|
||||
|
||||
### v3.6.5
|
||||
|
||||
- Migrate color formatting to colorette (thanks @jorgebucaran)
|
||||
- Fix: issue with IE detection
|
||||
- Fix: missing styles for embeds
|
||||
- Fix: regression regarding poster image
|
||||
- Add all required props to vimeo iframe allow attribute - fixes #2151 (thanks @didrip)
|
||||
|
||||
### v3.6.4
|
||||
|
||||
- Remove unnecessary calc from media query (thanks @naomiaz)
|
||||
- Enhance types (thanks @lunika)
|
||||
- Fix: Object.values for the providers must be used (thanks @syteknet-core)
|
||||
- Fix: Improve support inside iframes (thanks @ajgagnon)
|
||||
- Added --plyr-video-background for having control over the background of a video with alpha channel (webm) or a poster image with alpha channel (thanks @nepomuc)
|
||||
- Fix issue with not entering iosfullscreen of vimeo videos with playsinline=true (thanks @lordon and @Frosch)
|
||||
- fix: use new syntax for iframe allow attribute
|
||||
- chore: package updates
|
||||
- chore: add @babel/plugin-proposal-class-properties
|
||||
- fix: use bound arrow functions in classes
|
||||
|
||||
### v3.6.3
|
||||
|
||||
- Fix volume when unmuting from volume 0 using YouTube (thanks @stephanefbouchard)
|
||||
@ -10,7 +87,7 @@
|
||||
- Fix "A `ReferenceError: _classCallCheck is not defined` error has occurred." error (thanks @hex-ci)
|
||||
- Fix issue with CSS custom property check (thanks @syedhusain-appspace)
|
||||
- Fix for slow loading videos not autoplaying (thanks @DanielHuntleySBG)
|
||||
- Fix for betwork requests are not cancelled after the player is destroyed (thanks @DanielHuntleySBG)
|
||||
- Fix for network requests are not cancelled after the player is destroyed (thanks @DanielHuntleySBG)
|
||||
- Added option to disable custom controls for YouTube and Vimeo
|
||||
|
||||
### v3.6.2
|
||||
@ -55,7 +132,7 @@
|
||||
### v3.5.8
|
||||
|
||||
- Added `flex-direction` property to fix some issues introduced in v3.5.7 when using custom CSS
|
||||
- Cleaned up the organisation of some of the SCSS files (should not effect CSS output)
|
||||
- Cleaned up the organization of some of the SCSS files (should not effect CSS output)
|
||||
- Added `referrerPolicy` option for Vimeo to prevent an issue present in the demo site
|
||||
- Remove all Vimeo controls for Pro & Premium accounts
|
||||
- Improve thumbnail size calculations when size is set per css (thanks @ydylla)
|
||||
@ -70,7 +147,7 @@
|
||||
- Accessibility tweak for the play button (thanks @lunika)
|
||||
- Fix for ads configuration (thanks @SoftCreatR)
|
||||
- Fix handling listener return value (thanks @taion)
|
||||
- Added localisation key for PIP (picture-in-picture) (thanks @lmislm)
|
||||
- Added localization key for PIP (picture-in-picture) (thanks @lmislm)
|
||||
- Preserve viewBox attribute in SVG sprite symbols (thanks @bseib)
|
||||
- Fix being unable to unmute autoplayed video on iOS (thanks @sumanbh)
|
||||
- Fixed Plyr container not resizing responsively (thanks @shravan2x)
|
||||
@ -104,7 +181,7 @@ _Note:_ This update contains CSS changes.
|
||||
### v3.5.4
|
||||
|
||||
- Added: Set download URL via new setter
|
||||
- Improvement: The order of the `controls` option now effects the order in the DOM - i.e. you can re-order the controls - Note: this may break any custom CSS you have setup. Please see the changes in the PR to the default SASS
|
||||
- Improvement: The order of the `controls` option now effects the order in the DOM - i.e. you can re-order the controls - Note: this may break any custom CSS you have setup. Please see the changes in the PR to the default Sass
|
||||
- Fixed issue with empty controls and preview thumbs
|
||||
- Fixed issue with setGutter call (from Sentry)
|
||||
- Fixed issue with initial selected speed not working
|
||||
@ -467,7 +544,7 @@ This is a massive release. A _mostly_ complete rewrite in ES6. What started out
|
||||
|
||||
### Other stuff
|
||||
|
||||
- Now using SASS exclusively. Sorry, LESS folk it just made sense to maintain one method as SASS is what the cool kids use. It may come back if we work out an automated way to convert the SASS
|
||||
- Now using Sass exclusively. Sorry, LESS folk it just made sense to maintain one method as Sass is what the cool kids use. It may come back if we work out an automated way to convert the Sass
|
||||
- Moved to ES6. All the rage these days. You'll need to look at polyfills. The demo uses [polyfill.io](https://polyfill.io)
|
||||
- Added basic looping support
|
||||
- Added an aspect ratio option for those that can't leave the 90s and want 4:3
|
||||
@ -700,7 +777,7 @@ And some other changes and bug fixes:
|
||||
|
||||
## v1.7.0
|
||||
|
||||
- SASS cleanup (fixes #265)
|
||||
- Sass cleanup (fixes #265)
|
||||
- Docs tidy up to help quick start (fixes #253)
|
||||
- Fix for issues with data attribute options passing (fixes #257)
|
||||
- **_(Important)_** Removed the requirement for a wrapper div to setup Plyr and removed the dependency on the `plyr` classname as a JS hook. By default it will now look for `<video>`, `<audio>` and `[data-type]` elements. If you are just calling `setup()` with a `<div class="plyr">` you may want to give it a good test after upgrading. You can probably remove the wrapper div. The reason behind this is to make setup easier for newcomers and prevent the styling being used on unsupported players (because the plyr classname was used as a CSS and JS hook - which isn't ideal)
|
||||
@ -822,7 +899,7 @@ And some other changes and bug fixes:
|
||||
### v1.5.18
|
||||
|
||||
- Added 'ready' event for initial setup complete or source change occurs
|
||||
- Fixed SASS stylesheet references to transparentize
|
||||
- Fixed Sass stylesheet references to transparentize
|
||||
- Added default font stack to controls
|
||||
- Docs fixes inc controls HTML (fixes #180)
|
||||
|
||||
@ -859,7 +936,7 @@ And some other changes and bug fixes:
|
||||
|
||||
- iOS embed bug fixes (fixes #166)
|
||||
- Hide IE/Edge <input type='range'> tooltip (since we have a styled one) (fixes #160)
|
||||
- SASS bug fix for default values (fixes #158)
|
||||
- Sass bug fix for default values (fixes #158)
|
||||
|
||||
### v1.5.9
|
||||
|
||||
@ -881,7 +958,7 @@ And some other changes and bug fixes:
|
||||
### v1.5.6
|
||||
|
||||
- Seek tooltip (option for tooltips changed, please check docs)
|
||||
- SASS compile error fixes (fixes #148)
|
||||
- Sass compile error fixes (fixes #148)
|
||||
- Fullscreen fixes for controls not always hiding/showing (fixes #149)
|
||||
- Screen reader icon fixes (title was being read twice due to the tooltip/hidden label)
|
||||
|
||||
@ -958,7 +1035,7 @@ And some other changes and bug fixes:
|
||||
|
||||
### v1.2.6
|
||||
|
||||
- SASS updates and fixes (cheers @ChristianPV)
|
||||
- Sass updates and fixes (cheers @ChristianPV)
|
||||
|
||||
### v1.2.5
|
||||
|
||||
@ -1073,7 +1150,7 @@ And some other changes and bug fixes:
|
||||
|
||||
### v1.0.26
|
||||
|
||||
- Fixes for SASS (cheers @brunowego)
|
||||
- Fixes for Sass (cheers @brunowego)
|
||||
- Indentation reset to 4 spaces
|
||||
|
||||
### v1.0.25
|
||||
@ -1118,7 +1195,7 @@ And some other changes and bug fixes:
|
||||
|
||||
### v1.0.17
|
||||
|
||||
- SASS support added (thanks to @brunowego)
|
||||
- Sass support added (thanks to @brunowego)
|
||||
- Docs completely separated to avoid any confusion
|
||||
- New gulp tasks (will add more documentation for this)
|
||||
|
||||
|
@ -36,8 +36,8 @@ Please follow the instructions in our issue templates. Don't use github issues t
|
||||
You can use Gitpod (a free online VS Code-like IDE) for contributing. With a single click it will launch a workspace and automatically:
|
||||
|
||||
- clone the plyr repo.
|
||||
- install the dependencies.
|
||||
- run `gulp` to the start the server.
|
||||
- install the dependencies with `yarn install` in root directory and "demo" directory.
|
||||
- run `gulp` in root directory to start the dev server.
|
||||
|
||||
So that you can start straight away.
|
||||
|
||||
@ -49,6 +49,6 @@ So that you can start straight away.
|
||||
|
||||
- If your modifications changes the documented behavior or add new features, document these changes in [README.md](README.md).
|
||||
|
||||
- When finished, push the changes to your GitHub repository and send a pull request to **develop**. Describe what your PR does.
|
||||
- When finished, push the changes to your GitHub repository and send a pull request. Describe what your PR does.
|
||||
|
||||
- If the Travis build fails, or if you get a code review with change requests, you can fix these by pushing new or rebased commits to the branch.
|
||||
|
54
CONTROLS.md
54
CONTROLS.md
@ -2,11 +2,11 @@
|
||||
|
||||
This is the markup that is rendered for the Plyr controls. You can use the default controls or provide a customized version of markup based on your needs. You can pass the following to the `controls` option:
|
||||
|
||||
- `Array` of options (this builds the default controls based on your choices)
|
||||
- `Element` with the controls
|
||||
- `String` containing the desired HTML
|
||||
- `false` (or empty string or array) to disable all controls
|
||||
- `Function` that will be executed and should return one of the above
|
||||
- `Array` of options (this builds the default controls based on your choices)
|
||||
- `Element` with the controls
|
||||
- `String` containing the desired HTML
|
||||
- `false` (or empty string or array) to disable all controls
|
||||
- `Function` that will be executed and should return one of the above
|
||||
|
||||
## Using default controls
|
||||
|
||||
@ -14,28 +14,28 @@ If you want to use the standard controls as they are, you don't need to pass any
|
||||
|
||||
```javascript
|
||||
controls: [
|
||||
'play-large', // The large play button in the center
|
||||
'restart', // Restart playback
|
||||
'rewind', // Rewind by the seek time (default 10 seconds)
|
||||
'play', // Play/pause playback
|
||||
'fast-forward', // Fast forward by the seek time (default 10 seconds)
|
||||
'progress', // The progress bar and scrubber for playback and buffering
|
||||
'current-time', // The current time of playback
|
||||
'duration', // The full duration of the media
|
||||
'mute', // Toggle mute
|
||||
'volume', // Volume control
|
||||
'captions', // Toggle captions
|
||||
'settings', // Settings menu
|
||||
'pip', // Picture-in-picture (currently Safari only)
|
||||
'airplay', // Airplay (currently Safari only)
|
||||
'download', // Show a download button with a link to either the current source or a custom URL you specify in your options
|
||||
'fullscreen', // Toggle fullscreen
|
||||
'play-large', // The large play button in the center
|
||||
'restart', // Restart playback
|
||||
'rewind', // Rewind by the seek time (default 10 seconds)
|
||||
'play', // Play/pause playback
|
||||
'fast-forward', // Fast forward by the seek time (default 10 seconds)
|
||||
'progress', // The progress bar and scrubber for playback and buffering
|
||||
'current-time', // The current time of playback
|
||||
'duration', // The full duration of the media
|
||||
'mute', // Toggle mute
|
||||
'volume', // Volume control
|
||||
'captions', // Toggle captions
|
||||
'settings', // Settings menu
|
||||
'pip', // Picture-in-picture (currently Safari only)
|
||||
'airplay', // Airplay (currently Safari only)
|
||||
'download', // Show a download button with a link to either the current source or a custom URL you specify in your options
|
||||
'fullscreen', // Toggle fullscreen
|
||||
];
|
||||
```
|
||||
|
||||
### Internationalization using default controls
|
||||
|
||||
You can provide an `i18n` object as one of your options when initialising the plugin which we be used when rendering the controls.
|
||||
You can provide an `i18n` object as one of your options when initializing the plugin which we be used when rendering the controls.
|
||||
|
||||
#### Example
|
||||
|
||||
@ -84,14 +84,14 @@ The classes and data attributes used in your template should match the `selector
|
||||
|
||||
You need to add several placeholders to your HTML template that are replaced when rendering:
|
||||
|
||||
- `{id}` - the dynamically generated ID for the player (for form controls)
|
||||
- `{seektime}` - the seek time specified in options for fast forward and rewind
|
||||
- `{title}` - the title of your media, if specified
|
||||
- `{id}` - the dynamically generated ID for the player (for form controls)
|
||||
- `{seektime}` - the seek time specified in options for fast forward and rewind
|
||||
- `{title}` - the title of your media, if specified
|
||||
|
||||
### Limitations
|
||||
|
||||
- Currently the settings menus are not supported with custom controls HTML
|
||||
- AirPlay and PiP buttons can be added but you will have to manage feature detection
|
||||
- Currently the settings menus are not supported with custom controls HTML
|
||||
- AirPlay and PiP buttons can be added but you will have to manage feature detection
|
||||
|
||||
### Example
|
||||
|
||||
|
135
README.md
135
README.md
@ -1,3 +1,6 @@
|
||||
| 🎉 | [Plyr is merging into Vidstack](https://github.com/sampotts/plyr/issues/2408) | 🎉 |
|
||||
| :-: | :---------------------------------------------------------------------------: | :-- |
|
||||
|
||||
Plyr is a simple, lightweight, accessible and customizable HTML5, YouTube and Vimeo media player that supports [_modern_](#browser-support) browsers.
|
||||
|
||||
[Checkout the demo](https://plyr.io) - [Donate](#donate) - [Slack](https://bit.ly/plyr--chat)
|
||||
@ -27,7 +30,7 @@ Plyr is a simple, lightweight, accessible and customizable HTML5, YouTube and Vi
|
||||
- 🌎 **i18n support** - support for internationalization of controls
|
||||
- 👌 **[Preview thumbnails](#preview-thumbnails)** - support for displaying preview thumbnails
|
||||
- 🤟 **No frameworks** - written in "vanilla" ES6 JavaScript, no jQuery required
|
||||
- 💁♀️ **SASS** - to include in your build processes
|
||||
- 💁♀️ **Sass** - to include in your build processes
|
||||
|
||||
### Demos
|
||||
|
||||
@ -131,21 +134,21 @@ Alternatively you can include the `plyr.js` script before the closing `</body>`
|
||||
|
||||
See [initialising](#initialising) for more information on advanced setups.
|
||||
|
||||
You can use our CDN (provided by [Fastly](https://www.fastly.com/)) for the JavaScript. There's 2 versions; one with and one without [polyfills](#polyfills). My recommendation would be to manage polyfills seperately as part of your application but to make life easier you can use the polyfilled build.
|
||||
You can use our CDN (provided by [Fastly](https://www.fastly.com/)) for the JavaScript. There's 2 versions; one with and one without [polyfills](#polyfills). My recommendation would be to manage polyfills separately as part of your application but to make life easier you can use the polyfilled build.
|
||||
|
||||
```html
|
||||
<script src="https://cdn.plyr.io/3.6.3/plyr.js"></script>
|
||||
<script src="https://cdn.plyr.io/3.7.0/plyr.js"></script>
|
||||
```
|
||||
|
||||
...or...
|
||||
|
||||
```html
|
||||
<script src="https://cdn.plyr.io/3.6.3/plyr.polyfilled.js"></script>
|
||||
<script src="https://cdn.plyr.io/3.7.0/plyr.polyfilled.js"></script>
|
||||
```
|
||||
|
||||
## CSS
|
||||
|
||||
Include the `plyr.css` stylsheet into your `<head>`.
|
||||
Include the `plyr.css` stylesheet into your `<head>`.
|
||||
|
||||
```html
|
||||
<link rel="stylesheet" href="path/to/plyr.css" />
|
||||
@ -154,13 +157,13 @@ Include the `plyr.css` stylsheet into your `<head>`.
|
||||
If you want to use our CDN (provided by [Fastly](https://www.fastly.com/)) for the default CSS, you can use the following:
|
||||
|
||||
```html
|
||||
<link rel="stylesheet" href="https://cdn.plyr.io/3.6.3/plyr.css" />
|
||||
<link rel="stylesheet" href="https://cdn.plyr.io/3.7.0/plyr.css" />
|
||||
```
|
||||
|
||||
## SVG Sprite
|
||||
|
||||
The SVG sprite is loaded automatically from our CDN (provided by [Fastly](https://www.fastly.com/)). To change this, see the [options](#options) below. For
|
||||
reference, the CDN hosted SVG sprite can be found at `https://cdn.plyr.io/3.6.3/plyr.svg`.
|
||||
reference, the CDN hosted SVG sprite can be found at `https://cdn.plyr.io/3.7.0/plyr.svg`.
|
||||
|
||||
# Ads
|
||||
|
||||
@ -184,42 +187,43 @@ Here's a list of the properties and what they are used for:
|
||||
|
||||
| Name | Description | Default / Fallback |
|
||||
| ---------------------------------------------- | ------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
|
||||
| `--plyr-color-main` | The primary UI color. |  `#00b3ff` |
|
||||
| `--plyr-color-main` | The primary UI color. |  `#00b3ff` |
|
||||
| `--plyr-video-background` | The background color of video and poster wrappers for using alpha channel videos and poster images. | `rgba(0, 0, 0, 1)` |
|
||||
| `--plyr-tab-focus-color` | The color used for the dotted outline when an element is `:focus-visible` (equivalent) keyboard focus. | `--plyr-color-main` |
|
||||
| `--plyr-badge-background` | The background color for badges in the menu. |  `#4a5464` |
|
||||
| `--plyr-badge-text-color` | The text color for badges. |  `#ffffff` |
|
||||
| `--plyr-badge-background` | The background color for badges in the menu. |  `#4a5464` |
|
||||
| `--plyr-badge-text-color` | The text color for badges. |  `#ffffff` |
|
||||
| `--plyr-badge-border-radius` | The border radius used for badges. | `2px` |
|
||||
| `--plyr-tab-focus-color` | The color used to highlight tab (keyboard) focus. | `--plyr-color-main` |
|
||||
| `--plyr-captions-background` | The color for the background of captions. | `rgba(0, 0, 0, 0.8)` |
|
||||
| `--plyr-captions-text-color` | The color used for the captions text. |  `#ffffff` |
|
||||
| `--plyr-captions-text-color` | The color used for the captions text. |  `#ffffff` |
|
||||
| `--plyr-control-icon-size` | The size of the icons used in the controls. | `18px` |
|
||||
| `--plyr-control-spacing` | The space between controls (sometimes used in a multiple - e.g. `10px / 2 = 5px`). | `10px` |
|
||||
| `--plyr-control-padding` | The padding inside controls. | `--plyr-control-spacing * 0.7` (`7px`) |
|
||||
| `--plyr-control-radius` | The border radius used on controls. | `3px` |
|
||||
| `--plyr-control-toggle-checked-background` | The background color used for checked menu items. | `--plyr-color-main` |
|
||||
| `--plyr-video-controls-background` | The background for the video controls. | `linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.75))` |
|
||||
| `--plyr-video-control-color` | The text/icon color for video controls. |  `#ffffff` |
|
||||
| `--plyr-video-control-color-hover` | The text/icon color used when video controls are `:hover`, `:focus` and `:focus-visible` (equivalent). |  `#ffffff` |
|
||||
| `--plyr-video-control-color` | The text/icon color for video controls. |  `#ffffff` |
|
||||
| `--plyr-video-control-color-hover` | The text/icon color used when video controls are `:hover`, `:focus` and `:focus-visible` (equivalent). |  `#ffffff` |
|
||||
| `--plyr-video-control-background-hover` | The background color used when video controls are `:hover`, `:focus` and `:focus-visible` (equivalent). | `--plyr-color-main` |
|
||||
| `--plyr-audio-controls-background` | The background for the audio controls. |  `#ffffff` |
|
||||
| `--plyr-audio-control-color` | The text/icon color for audio controls. |  `#4a5464` |
|
||||
| `--plyr-audio-control-color-hover` | The text/icon color used when audio controls are `:hover`, `:focus` and `:focus-visible` (equivalent). |  `#ffffff` |
|
||||
| `--plyr-audio-controls-background` | The background for the audio controls. |  `#ffffff` |
|
||||
| `--plyr-audio-control-color` | The text/icon color for audio controls. |  `#4a5464` |
|
||||
| `--plyr-audio-control-color-hover` | The text/icon color used when audio controls are `:hover`, `:focus` and `:focus-visible` (equivalent). |  `#ffffff` |
|
||||
| `--plyr-audio-control-background-hover` | The background color used when video controls are `:hover`, `:focus` and `:focus-visible` (equivalent). | `--plyr-color-main` |
|
||||
| `--plyr-menu-background` | The background color for menus. | `rgba(255, 255, 255, 0.9)` |
|
||||
| `--plyr-menu-color` | The text/icon color for menu items. |  `#4a5464` |
|
||||
| `--plyr-menu-color` | The text/icon color for menu items. |  `#4a5464` |
|
||||
| `--plyr-menu-shadow` | The shadow used on menus. | `0 1px 2px rgba(0, 0, 0, 0.15)` |
|
||||
| `--plyr-menu-radius` | The border radius on the menu. | `4px` |
|
||||
| `--plyr-menu-arrow-size` | The size of the arrow on the bottom of the menu. | `6px` |
|
||||
| `--plyr-menu-item-arrow-color` | The color of the arrows in the menu. |  `#728197` |
|
||||
| `--plyr-menu-item-arrow-color` | The color of the arrows in the menu. |  `#728197` |
|
||||
| `--plyr-menu-item-arrow-size` | The size of the arrows in the menu. | `4px` |
|
||||
| `--plyr-menu-border-color` | The border color for the bottom of the back button in the top of the sub menu pages. |  `#dcdfe5` |
|
||||
| `--plyr-menu-border-shadow-color` | The shadow below the border of the back button in the top of the sub menu pages. |  `#ffffff` |
|
||||
| `--plyr-menu-border-color` | The border color for the bottom of the back button in the top of the sub menu pages. |  `#dcdfe5` |
|
||||
| `--plyr-menu-border-shadow-color` | The shadow below the border of the back button in the top of the sub menu pages. |  `#ffffff` |
|
||||
| `--plyr-progress-loading-size` | The size of the stripes in the loading state in the scrubber. | `25px` |
|
||||
| `--plyr-progress-loading-background` | The background color on the loading state in the scrubber. | `rgba(35, 40, 47, 0.6)` |
|
||||
| `--plyr-video-progress-buffered-background` | The fill color for the buffer indication in the scrubber for video. | `rgba(255, 255, 255, 0.25)` |
|
||||
| `--plyr-audio-progress-buffered-background` | The fill color for the buffer indication in the scrubber for audio. | `rgba(193, 200, 209, 0.6)` |
|
||||
| `--plyr-range-thumb-height` | The height of the scrubber handle/thumb. | `13px` |
|
||||
| `--plyr-range-thumb-background` | The background of the scrubber handle/thumb. |  `#ffffff` |
|
||||
| `--plyr-range-thumb-background` | The background of the scrubber handle/thumb. |  `#ffffff` |
|
||||
| `--plyr-range-thumb-shadow` | The shadow of the scrubber handle/thumb. | `0 1px 1px rgba(215, 26, 18, 0.15), 0 0 0 1px rgba(215, 26, 18, 0.2)` |
|
||||
| `--plyr-range-thumb-active-shadow-width` | The width of the shadow when the scrubber handle/thumb is `:active` (pressed). | `3px` |
|
||||
| `--plyr-range-track-height` | The height of the scrubber/progress track. | `5px` |
|
||||
@ -229,7 +233,7 @@ Here's a list of the properties and what they are used for:
|
||||
| `--plyr-audio-range-track-background` | The background of the scrubber/progress. | `--plyr-video-progress-buffered-background` |
|
||||
| `--plyr-audio-range-thumb-active-shadow-color` | The color of the shadow when the audio scrubber handle/thumb is `:active` (pressed). | `rgba(215, 26, 18, 0.1)` |
|
||||
| `--plyr-tooltip-background` | The background color for tooltips. | `rgba(255, 255, 255, 0.9)` |
|
||||
| `--plyr-tooltip-color` | The text color for tooltips. |  `#4a5464` |
|
||||
| `--plyr-tooltip-color` | The text color for tooltips. |  `#4a5464` |
|
||||
| `--plyr-tooltip-padding` | The padding for tooltips. | `calc(var(--plyr-control-spacing) / 2))` |
|
||||
| `--plyr-tooltip-arrow-size` | The size of the arrow under tooltips. | `4px` |
|
||||
| `--plyr-tooltip-radius` | The border radius on tooltips. | `3px` |
|
||||
@ -266,14 +270,12 @@ You can set them in your CSS for all players:
|
||||
...or in your HTML:
|
||||
|
||||
```html
|
||||
<video class="player" style="--plyr-color-main: #1ac266;">
|
||||
...
|
||||
</video>
|
||||
<video class="player" style="--plyr-color-main: #1ac266;">...</video>
|
||||
```
|
||||
|
||||
### SASS
|
||||
### Sass
|
||||
|
||||
You can use `plyr.scss` file included in `/src/sass` as part of your build and change variables to suit your design. The SASS requires you to
|
||||
You can use `plyr.scss` file included in `/src/sass` as part of your build and change variables to suit your design. The Sass requires you to
|
||||
use [autoprefixer](https://www.npmjs.com/package/gulp-autoprefixer) (you should be already!) as all declarations use the W3C definitions.
|
||||
|
||||
The HTML markup uses the BEM methodology with `plyr` as the block, e.g. `.plyr__controls`. You can change the class hooks in the options to match any custom CSS
|
||||
@ -343,7 +345,7 @@ The HTMLElement or string selector can be the target `<video>`, `<audio>`, or `<
|
||||
You have two choices here. You can either use a simple array loop to map the constructor:
|
||||
|
||||
```javascript
|
||||
const players = Array.from(document.querySelectorAll('.js-player')).map(p => new Plyr(p));
|
||||
const players = Array.from(document.querySelectorAll('.js-player')).map((p) => new Plyr(p));
|
||||
```
|
||||
|
||||
...or use a static method where you can pass a [CSS string selector](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors), a [NodeList](https://developer.mozilla.org/en-US/docs/Web/API/NodeList), an [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) of [HTMLElement](https://developer.mozilla.org/en/docs/Web/API/HTMLElement), or a [JQuery](https://jquery.com) object:
|
||||
@ -399,11 +401,11 @@ Note the single quotes encapsulating the JSON and double quotes on the object ke
|
||||
| `invertTime` | Boolean | `true` | Display the current time as a countdown rather than an incremental counter. |
|
||||
| `toggleInvert` | Boolean | `true` | Allow users to click to toggle the above. |
|
||||
| `listeners` | Object | `null` | Allows binding of event listeners to the controls before the default handlers. See the `defaults.js` for available listeners. If your handler prevents default on the event (`event.preventDefault()`), the default handler will not fire. |
|
||||
| `captions` | Object | `{ active: false, language: 'auto', update: false }` | `active`: Toggles if captions should be active by default. `language`: Sets the default language to load (if available). 'auto' uses the browser language. `update`: Listen to changes to tracks and update menu. This is needed for some streaming libraries, but can result in unselectable language options). |
|
||||
| `captions` | Object | `{ active: false, language: 'auto', update: false }` | `active`: Toggles if captions should be active by default. `language`: Sets the default language to load (if available). 'auto' uses the browser language. `update`: Listen to changes to tracks and update menu. This is needed for some streaming libraries, but can result in non-selectable language options). |
|
||||
| `fullscreen` | Object | `{ enabled: true, fallback: true, iosNative: false, container: null }` | `enabled`: Toggles whether fullscreen should be enabled. `fallback`: Allow fallback to a full-window solution (`true`/`false`/`'force'`). `iosNative`: whether to use native iOS fullscreen when entering fullscreen (no custom controls). `container`: A selector for an ancestor of the player element, allows contextual content to remain visual in fullscreen mode. Non-ancestors are ignored. |
|
||||
| `ratio` | String | `null` | Force an aspect ratio for all videos. The format is `'w:h'` - e.g. `'16:9'` or `'4:3'`. If this is not specified then the default for HTML5 and Vimeo is to use the native resolution of the video. As dimensions are not available from YouTube via SDK, 16:9 is forced as a sensible default. |
|
||||
| `storage` | Object | `{ enabled: true, key: 'plyr' }` | `enabled`: Allow use of local storage to store user settings. `key`: The key name to use. |
|
||||
| `speed` | Object | `{ selected: 1, options: [0.5, 0.75, 1, 1.25, 1.5, 1.75, 2] }` | `selected`: The default speed for playback. `options`: The speed options to display in the UI. YouTube and Vimeo will ignore any options outside of the 0.5-2 range, so options outside of this range will be hidden automatically. |
|
||||
| `speed` | Object | `{ selected: 1, options: [0.5, 0.75, 1, 1.25, 1.5, 1.75, 2, 4] }` | `selected`: The default speed for playback. `options`: The speed options to display in the UI. YouTube and Vimeo will ignore any options outside of the 0.5-2 range, so options outside of this range will be hidden automatically. |
|
||||
| `quality` | Object | `{ default: 576, options: [4320, 2880, 2160, 1440, 1080, 720, 576, 480, 360, 240] }` | `default` is the default quality level (if it exists in your sources). `options` are the options to display. This is used to filter the available sources. |
|
||||
| `loop` | Object | `{ active: false }` | `active`: Whether to loop the current video. If the `loop` attribute is present on a `<video>` or `<audio>` element, this will be automatically set to true This is an object to support future functionality. |
|
||||
| `ads` | Object | `{ enabled: false, publisherId: '', tagUrl: '' }` | `enabled`: Whether to enable advertisements. `publisherId`: Your unique [vi.ai](https://vi.ai/publisher-video-monetization/?aid=plyrio) publisher ID. `tagUrl` is a URL for a custom VAST tag if you're not using Vi. |
|
||||
@ -411,6 +413,8 @@ Note the single quotes encapsulating the JSON and double quotes on the object ke
|
||||
| `vimeo` | Object | `{ byline: false, portrait: false, title: false, speed: true, transparent: false }` | See [Vimeo embed options](https://github.com/vimeo/player.js/#embed-options). Some are set automatically based on other config options, namely: `loop`, `autoplay`, `muted`, `gesture`, `playsinline` |
|
||||
| `youtube` | Object | `{ noCookie: false, rel: 0, showinfo: 0, iv_load_policy: 3, modestbranding: 1 }` | See [YouTube embed options](https://developers.google.com/youtube/player_parameters#Parameters). The only custom option is `noCookie` to use an alternative to YouTube that doesn't use cookies (useful for GDPR, etc). Some are set automatically based on other config options, namely: `autoplay`, `hl`, `controls`, `disablekb`, `playsinline`, `cc_load_policy`, `cc_lang_pref`, `widget_referrer` |
|
||||
| `previewThumbnails` | Object | `{ enabled: false, src: '' }` | `enabled`: Whether to enable the preview thumbnails (they must be generated by you). `src` must be either a string or an array of strings representing URLs for the VTT files containing the image URL(s). Learn more about [preview thumbnails](#preview-thumbnails) below. |
|
||||
| `mediaMetadata` | Object | `{ title: '', artist: '', album: '', artwork: [] }` | The [MediaMetadata](https://developer.mozilla.org/en-US/docs/Web/API/MediaMetadata) interface of the Media Session API allows a web page to provide rich media metadata for display in a platform UI. |
|
||||
| `markers` | Object | `{ enabled: false, points: [] }` | `enabled`: Whether to enable markers. `points` is an array of `{ time: number; label: string; }` objects where `time` represents the marker position in seconds and `label` is the HTML string to be displayed. |
|
||||
|
||||
1. Vimeo only
|
||||
2. Autoplay is generally not recommended as it is seen as a negative user experience. It is also disabled in many browsers. Before raising issues, do your homework. More info can be found here:
|
||||
@ -436,7 +440,7 @@ const player = new Plyr('#player', {
|
||||
You can also access the object through any events:
|
||||
|
||||
```javascript
|
||||
element.addEventListener('ready', event => {
|
||||
element.addEventListener('ready', (event) => {
|
||||
const player = event.detail.plyr;
|
||||
});
|
||||
```
|
||||
@ -450,28 +454,29 @@ player.play(); // Start playback
|
||||
player.fullscreen.enter(); // Enter fullscreen
|
||||
```
|
||||
|
||||
| Method | Parameters | Description |
|
||||
| -------------------------- | ---------------- | ---------------------------------------------------------------------------------------------------------- |
|
||||
| `play()`¹ | - | Start playback. |
|
||||
| `pause()` | - | Pause playback. |
|
||||
| `togglePlay(toggle)`¹ | Boolean | Toggle playback, if no parameters are passed, it will toggle based on current status. |
|
||||
| `stop()` | - | Stop playback and reset to start. |
|
||||
| `restart()` | - | Restart playback. |
|
||||
| `rewind(seekTime)` | Number | Rewind playback by the specified seek time. If no parameter is passed, the default seek time will be used. |
|
||||
| `forward(seekTime)` | Number | Fast forward by the specified seek time. If no parameter is passed, the default seek time will be used. |
|
||||
| `increaseVolume(step)` | Number | Increase volume by the specified step. If no parameter is passed, the default step will be used. |
|
||||
| `decreaseVolume(step)` | Number | Increase volume by the specified step. If no parameter is passed, the default step will be used. |
|
||||
| `toggleCaptions(toggle)` | Boolean | Toggle captions display. If no parameter is passed, it will toggle based on current status. |
|
||||
| `fullscreen.enter()` | - | Enter fullscreen. If fullscreen is not supported, a fallback "full window/viewport" is used instead. |
|
||||
| `fullscreen.exit()` | - | Exit fullscreen. |
|
||||
| `fullscreen.toggle()` | - | Toggle fullscreen. |
|
||||
| `airplay()` | - | Trigger the airplay dialog on supported devices. |
|
||||
| `toggleControls(toggle)` | Boolean | Toggle the controls (video only). Takes optional truthy value to force it on/off. |
|
||||
| `on(event, function)` | String, Function | Add an event listener for the specified event. |
|
||||
| `once(event, function)` | String, Function | Add an event listener for the specified event once. |
|
||||
| `off(event, function)` | String, Function | Remove an event listener for the specified event. |
|
||||
| `supports(type)` | String | Check support for a mime type. |
|
||||
| `destroy()` | - | Destroy the instance and garbage collect any elements. |
|
||||
| Method | Parameters | Description |
|
||||
| -------------------------------------------------------- | ---------------- | ---------------------------------------------------------------------------------------------------------- |
|
||||
| `play()`¹ | - | Start playback. |
|
||||
| `pause()` | - | Pause playback. |
|
||||
| `togglePlay(toggle)`¹ | Boolean | Toggle playback, if no parameters are passed, it will toggle based on current status. |
|
||||
| `stop()` | - | Stop playback and reset to start. |
|
||||
| `restart()` | - | Restart playback. |
|
||||
| `rewind(seekTime)` | Number | Rewind playback by the specified seek time. If no parameter is passed, the default seek time will be used. |
|
||||
| `forward(seekTime)` | Number | Fast forward by the specified seek time. If no parameter is passed, the default seek time will be used. |
|
||||
| `increaseVolume(step)` | Number | Increase volume by the specified step. If no parameter is passed, the default step will be used. |
|
||||
| `decreaseVolume(step)` | Number | Increase volume by the specified step. If no parameter is passed, the default step will be used. |
|
||||
| `toggleCaptions(toggle)` | Boolean | Toggle captions display. If no parameter is passed, it will toggle based on current status. |
|
||||
| `fullscreen.enter()` | - | Enter fullscreen. If fullscreen is not supported, a fallback "full window/viewport" is used instead. |
|
||||
| `fullscreen.exit()` | - | Exit fullscreen. |
|
||||
| `fullscreen.toggle()` | - | Toggle fullscreen. |
|
||||
| `airplay()` | - | Trigger the airplay dialog on supported devices. |
|
||||
| `setPreviewThumbnails(source: PreviewThumbnailsOptions)` | - | Sets the preview thumbnails for the current source. |
|
||||
| `toggleControls(toggle)` | Boolean | Toggle the controls (video only). Takes optional truthy value to force it on/off. |
|
||||
| `on(event, function)` | String, Function | Add an event listener for the specified event. |
|
||||
| `once(event, function)` | String, Function | Add an event listener for the specified event once. |
|
||||
| `off(event, function)` | String, Function | Remove an event listener for the specified event. |
|
||||
| `supports(type)` | String | Check support for a mime type. |
|
||||
| `destroy()` | - | Destroy the instance and garbage collect any elements. |
|
||||
|
||||
1. For HTML5 players, `play()` will return a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) for most browsers - e.g. Chrome, Firefox, Opera, Safari and Edge [according to MDN](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/play) at time of writing.
|
||||
|
||||
@ -512,6 +517,7 @@ player.fullscreen.active; // false;
|
||||
| `loop` | ✓ | ✓ | Gets or sets the current loop state of the player. The setter accepts a boolean. |
|
||||
| `source` | ✓ | ✓ | Gets or sets the current source for the player. The setter accepts an object. See [source setter](#the-source-setter) below for examples. |
|
||||
| `poster` | ✓ | ✓ | Gets or sets the current poster image for the player. The setter accepts a string; the URL for the updated poster image. |
|
||||
| `previewThumbnails` | ✓ | ✓ | Gets or sets the current preview thumbnail source for the player. The setter accepts a string |
|
||||
| `autoplay` | ✓ | ✓ | Gets or sets the autoplay state of the player. The setter accepts a boolean. |
|
||||
| `currentTrack` | ✓ | ✓ | Gets or sets the caption track by index. `-1` means the track is missing or captions is not active |
|
||||
| `language` | ✓ | ✓ | Gets or sets the preferred captions language for the player. The setter accepts an ISO two-letter language code. Support for the languages is dependent on the captions you include. If your captions don't have any language data, or if you have multiple tracks with the same language, you may want to use `currentTrack` instead. |
|
||||
@ -634,7 +640,7 @@ reference to the instance, you can use the `on()` API method or `addEventListene
|
||||
property. Here's an example:
|
||||
|
||||
```javascript
|
||||
player.on('ready', event => {
|
||||
player.on('ready', (event) => {
|
||||
const instance = event.detail.plyr;
|
||||
});
|
||||
```
|
||||
@ -781,16 +787,16 @@ If a User Agent is disabled but supports `<video>` and `<audio>` natively, it wi
|
||||
|
||||
Some awesome folks have made plugins for CMSs and Components for JavaScript frameworks:
|
||||
|
||||
| Type | Maintainer | Link |
|
||||
| --------- | ------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- |
|
||||
| WordPress | Brandon Lavigne ([@drrobotnik](https://github.com/drrobotnik)) | [https://wordpress.org/plugins/plyr/](https://wordpress.org/plugins/plyr/) |
|
||||
| Angular | Simon Bobrov ([@smnbbrv](https://github.com/smnbbrv)) | [https://github.com/smnbbrv/ngx-plyr](https://github.com/smnbbrv/ngx-plyr) |
|
||||
| React | Chintan Prajapati ([@chintan9](https://github.com/chintan9)) | [https://github.com/chintan9/plyr-react](https://github.com/chintan9/plyr-react) |
|
||||
| Vue | Gabe Dunn ([@redxtech](https://github.com/redxtech)) | [https://github.com/redxtech/vue-plyr](https://github.com/redxtech/vue-plyr) |
|
||||
| Neos | Jon Uhlmann ([@jonnitto](https://github.com/jonnitto)) | [https://packagist.org/packages/jonnitto/plyr](https://packagist.org/packages/jonnitto/plyr) |
|
||||
| Kirby | Dominik Pschenitschni ([@dpschen](https://github.com/dpschen)) | [https://github.com/dpschen/kirby-plyrtag](https://github.com/dpschen/kirby-plyrtag) |
|
||||
| REDAXO | FriendsOfRedaxo / skerbis ([@skerbis](https://friendsofredaxo.github.io)) | [https://github.com/FriendsOfREDAXO/plyr](https://github.com/FriendsOfREDAXO/plyr) |
|
||||
| svelte-plyr | Ben Woodward / benwoodward ([@benwoodward](https://github.com/benwoodward)) | [https://github.com/benwoodward](https://github.com/benwoodward) |
|
||||
| Type | Maintainer | Link |
|
||||
| ----------- | --------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- |
|
||||
| WordPress | Brandon Lavigne ([@drrobotnik](https://github.com/drrobotnik)) | [https://wordpress.org/plugins/plyr/](https://wordpress.org/plugins/plyr/) |
|
||||
| Angular | Simon Bobrov ([@smnbbrv](https://github.com/smnbbrv)) | [https://github.com/smnbbrv/ngx-plyr](https://github.com/smnbbrv/ngx-plyr) |
|
||||
| React | Chintan Prajapati ([@chintan9](https://github.com/chintan9)) | [https://github.com/chintan9/plyr-react](https://github.com/chintan9/plyr-react) |
|
||||
| Vue | Gabe Dunn ([@redxtech](https://github.com/redxtech)) | [https://github.com/redxtech/vue-plyr](https://github.com/redxtech/vue-plyr) |
|
||||
| Neos | Jon Uhlmann ([@jonnitto](https://github.com/jonnitto)) | [https://packagist.org/packages/jonnitto/plyr](https://packagist.org/packages/jonnitto/plyr) |
|
||||
| Kirby | Dominik Pschenitschni ([@dpschen](https://github.com/dpschen)) | [https://github.com/dpschen/kirby-plyrtag](https://github.com/dpschen/kirby-plyrtag) |
|
||||
| REDAXO | FriendsOfRedaxo / skerbis ([@skerbis](https://friendsofredaxo.github.io)) | [https://github.com/FriendsOfREDAXO/plyr](https://github.com/FriendsOfREDAXO/plyr) |
|
||||
| svelte-plyr | Ben Woodward / benwoodward ([@benwoodward](https://github.com/benwoodward)) | [https://github.com/benwoodward/svelte-plyr](https://github.com/benwoodward/svelte-plyr) |
|
||||
|
||||
# Issues
|
||||
|
||||
@ -838,6 +844,7 @@ Plyr costs money to run, not only my time. I donate my time for free as I enjoy
|
||||
- [Rutheneum-Bote](https://gymnasium-rutheneum.de/content/newspaper/kreativwettbewerb.php)
|
||||
- [pressakey.com | Blog-Magazin für Videospiele](https://pressakey.com)
|
||||
- [STROLLÿN: Work with a View](https://strollyn.com)
|
||||
- [CFDA Runway360](https://runway360.cfda.com/)
|
||||
|
||||
If you want to be added to the list, open a pull request. It'd be awesome to see how you're using Plyr 😎
|
||||
|
||||
|
34
cspell.json
Normal file
34
cspell.json
Normal file
@ -0,0 +1,34 @@
|
||||
{
|
||||
"version": "0.2",
|
||||
"ignorePaths": ["package.json", "dist/*", "demo/node_modules/*"],
|
||||
"dictionaryDefinitions": [],
|
||||
"dictionaries": [],
|
||||
"words": [
|
||||
"autopause",
|
||||
"autoplay",
|
||||
"bote",
|
||||
"cfda",
|
||||
"classname",
|
||||
"digbmx",
|
||||
"fastly",
|
||||
"fullscreen",
|
||||
"gordita",
|
||||
"magazin",
|
||||
"menuitemradio",
|
||||
"noupe",
|
||||
"playsinline",
|
||||
"plyr",
|
||||
"rutheneum",
|
||||
"seektime",
|
||||
"selz",
|
||||
"sparkk",
|
||||
"srclang",
|
||||
"strol",
|
||||
"stylelint",
|
||||
"unmute",
|
||||
"videospiele",
|
||||
"xywh"
|
||||
],
|
||||
"ignoreWords": [],
|
||||
"import": []
|
||||
}
|
1
demo/dist/demo.css
vendored
1
demo/dist/demo.css
vendored
File diff suppressed because one or more lines are too long
29688
demo/dist/demo.js
vendored
29688
demo/dist/demo.js
vendored
File diff suppressed because it is too large
Load Diff
19
demo/dist/demo.min.js
vendored
19
demo/dist/demo.min.js
vendored
File diff suppressed because one or more lines are too long
1
demo/dist/demo.min.js.map
vendored
1
demo/dist/demo.min.js.map
vendored
File diff suppressed because one or more lines are too long
1
demo/dist/demo.svg
vendored
1
demo/dist/demo.svg
vendored
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 5.6 KiB |
1
demo/dist/error.css
vendored
1
demo/dist/error.css
vendored
File diff suppressed because one or more lines are too long
@ -105,14 +105,6 @@
|
||||
</button>
|
||||
</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">
|
||||
<a href="https://github.com/sampotts/plyr" target="_blank" class="button js-shr">
|
||||
<svg class="icon" role="presentation">
|
||||
|
@ -65,6 +65,34 @@ import toggleClass from './toggle-class';
|
||||
// Prevent Vimeo blocking plyr.io demo site
|
||||
referrerPolicy: 'no-referrer',
|
||||
},
|
||||
mediaMetadata: {
|
||||
title: 'View From A Blue Moon',
|
||||
album: 'Sports',
|
||||
artist: 'Brainfarm',
|
||||
artwork: [
|
||||
{
|
||||
src: 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.jpg',
|
||||
type: 'image/jpeg',
|
||||
},
|
||||
],
|
||||
},
|
||||
markers: {
|
||||
enabled: true,
|
||||
points: [
|
||||
{
|
||||
time: 10,
|
||||
label: 'first marker',
|
||||
},
|
||||
{
|
||||
time: 40,
|
||||
label: 'second marker',
|
||||
},
|
||||
{
|
||||
time: 120,
|
||||
label: '<strong>third</strong> marker',
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
// Expose for tinkering in the console
|
||||
|
@ -2,8 +2,8 @@
|
||||
// Plyr.io Demo Page
|
||||
// ==========================================================================
|
||||
@charset 'UTF-8';
|
||||
|
||||
@import '../../../../src/sass/lib/css-vars';
|
||||
|
||||
$css-vars-use-native: true;
|
||||
|
||||
// Settings
|
||||
|
@ -45,7 +45,7 @@
|
||||
}
|
||||
|
||||
&.tab-focus {
|
||||
@include tab-focus();
|
||||
@include tab-focus;
|
||||
}
|
||||
|
||||
&:active {
|
||||
@ -64,7 +64,7 @@
|
||||
|
||||
// Count bubble
|
||||
.button__count {
|
||||
animation: fadein 0.2s ease;
|
||||
animation: fade-in 0.2s ease;
|
||||
background: $color-button-count-background;
|
||||
color: $color-button-count-text;
|
||||
margin-left: ($spacing-base * 0.75);
|
||||
|
@ -7,7 +7,7 @@ header {
|
||||
text-align: center;
|
||||
|
||||
h1 span {
|
||||
animation: shrinkHide 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) 2s forwards;
|
||||
animation: shrink-hide 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) 2s forwards;
|
||||
display: inline-block;
|
||||
font-weight: $font-weight-light;
|
||||
opacity: 0.5;
|
||||
|
@ -2,6 +2,8 @@
|
||||
// Icons
|
||||
// ==========================================================================
|
||||
|
||||
@use 'sass:math';
|
||||
|
||||
// Base size icon styles
|
||||
.icon {
|
||||
fill: currentColor;
|
||||
@ -19,5 +21,5 @@ label svg {
|
||||
|
||||
a .icon,
|
||||
.btn .icon {
|
||||
margin-right: ($spacing-base / 2);
|
||||
margin-right: math.div($spacing-base, 4);
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
// Make a <button> look like an <a>
|
||||
button.faux-link {
|
||||
@extend a; // stylelint-disable-line
|
||||
@include cancel-button-styles();
|
||||
@include cancel-button-styles;
|
||||
}
|
||||
|
||||
// Links
|
||||
@ -39,7 +39,7 @@ a {
|
||||
}
|
||||
|
||||
&.tab-focus {
|
||||
@include tab-focus();
|
||||
@include tab-focus;
|
||||
}
|
||||
|
||||
&.no-border::after {
|
||||
|
@ -2,6 +2,8 @@
|
||||
// Examples
|
||||
// ==========================================================================
|
||||
|
||||
@use 'sass:math';
|
||||
|
||||
// Example players
|
||||
.plyr {
|
||||
border-radius: $border-radius-large;
|
||||
@ -31,6 +33,6 @@
|
||||
color: $color-gray-500;
|
||||
|
||||
.icon {
|
||||
margin-right: ceil($spacing-base / 6);
|
||||
margin-right: math.div($spacing-base, 6);
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,8 @@
|
||||
// Core
|
||||
// ==========================================================================
|
||||
|
||||
@use 'sass:math';
|
||||
|
||||
html,
|
||||
body {
|
||||
display: flex;
|
||||
@ -46,7 +48,7 @@ aside {
|
||||
|
||||
.icon {
|
||||
fill: $color-twitter;
|
||||
margin-right: ($spacing-base / 2);
|
||||
margin-right: math.div($spacing-base, 2);
|
||||
}
|
||||
|
||||
p {
|
||||
|
@ -3,23 +3,26 @@
|
||||
// ==========================================================================
|
||||
|
||||
// Fade
|
||||
@keyframes fadein {
|
||||
@keyframes fade-in {
|
||||
0% {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
100% {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes shrinkHide {
|
||||
@keyframes shrink-hide {
|
||||
0% {
|
||||
opacity: 0.5;
|
||||
width: 38px;
|
||||
}
|
||||
|
||||
20% {
|
||||
width: 45px;
|
||||
}
|
||||
|
||||
100% {
|
||||
opacity: 0;
|
||||
width: 0;
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
@font-face {
|
||||
font-display: swap;
|
||||
font-family: 'Gordita';
|
||||
font-family: Gordita;
|
||||
font-style: normal;
|
||||
font-weight: $font-weight-light;
|
||||
src: url('https://cdn.plyr.io/static/fonts/gordita-light.woff2') format('woff2'),
|
||||
@ -13,7 +13,7 @@
|
||||
|
||||
@font-face {
|
||||
font-display: swap;
|
||||
font-family: 'Gordita';
|
||||
font-family: Gordita;
|
||||
font-style: normal;
|
||||
font-weight: $font-weight-regular;
|
||||
src: url('https://cdn.plyr.io/static/fonts/gordita-regular.woff2') format('woff2'),
|
||||
@ -22,7 +22,7 @@
|
||||
|
||||
@font-face {
|
||||
font-display: swap;
|
||||
font-family: 'Gordita';
|
||||
font-family: Gordita;
|
||||
font-style: normal;
|
||||
font-weight: $font-weight-medium;
|
||||
src: url('https://cdn.plyr.io/static/fonts/gordita-medium.woff2') format('woff2'),
|
||||
@ -31,7 +31,7 @@
|
||||
|
||||
@font-face {
|
||||
font-display: swap;
|
||||
font-family: 'Gordita';
|
||||
font-family: Gordita;
|
||||
font-style: normal;
|
||||
font-weight: $font-weight-bold;
|
||||
src: url('https://cdn.plyr.io/static/fonts/gordita-bold.woff2') format('woff2'),
|
||||
@ -40,7 +40,7 @@
|
||||
|
||||
@font-face {
|
||||
font-display: swap;
|
||||
font-family: 'Gordita';
|
||||
font-family: Gordita;
|
||||
font-style: normal;
|
||||
font-weight: $font-weight-black;
|
||||
src: url('https://cdn.plyr.io/static/fonts/gordita-black.woff2') format('woff2'),
|
||||
|
@ -2,6 +2,8 @@
|
||||
// Mixins
|
||||
// ==========================================================================
|
||||
|
||||
@use 'sass:math';
|
||||
|
||||
// Convert a <button> into an <a>
|
||||
// ---------------------------------------
|
||||
@mixin cancel-button-styles() {
|
||||
@ -16,7 +18,7 @@
|
||||
position: relative;
|
||||
text-align: inherit;
|
||||
text-shadow: inherit;
|
||||
-moz-user-select: text; // stylelint-disable-line
|
||||
user-select: text;
|
||||
vertical-align: baseline;
|
||||
width: auto;
|
||||
}
|
||||
@ -32,7 +34,7 @@
|
||||
// Leave <body> at 100%/16px
|
||||
// ---------------------------------------
|
||||
@function calculate-rem($size) {
|
||||
$rem: $size / 16;
|
||||
$rem: math.div($size, 16);
|
||||
@return #{$rem}rem;
|
||||
}
|
||||
|
||||
|
17
demo/src/sass/lib/normalize.scss
vendored
17
demo/src/sass/lib/normalize.scss
vendored
@ -11,8 +11,7 @@
|
||||
|
||||
html {
|
||||
line-height: 1.15; /* 1 */
|
||||
-ms-text-size-adjust: 100%; /* 2 */
|
||||
-webkit-text-size-adjust: 100%; /* 2 */
|
||||
text-size-adjust: 100%; /* 2 */
|
||||
}
|
||||
|
||||
/* Sections
|
||||
@ -89,7 +88,7 @@ hr {
|
||||
*/
|
||||
|
||||
pre {
|
||||
font-family: monospace, monospace; /* 1 */
|
||||
font-family: monospace; /* 1 */
|
||||
font-size: 1em; /* 2 */
|
||||
}
|
||||
|
||||
@ -103,7 +102,7 @@ pre {
|
||||
|
||||
a {
|
||||
background-color: transparent; /* 1 */
|
||||
-webkit-text-decoration-skip: objects; /* 2 */
|
||||
text-decoration-skip: objects; /* 2 */
|
||||
}
|
||||
|
||||
/**
|
||||
@ -112,7 +111,7 @@ a {
|
||||
*/
|
||||
|
||||
abbr[title] {
|
||||
border-bottom: none; /* 1 */
|
||||
border-bottom: 0; /* 1 */
|
||||
text-decoration: underline; /* 2 */
|
||||
text-decoration: underline dotted; /* 2 */
|
||||
}
|
||||
@ -281,7 +280,7 @@ button,
|
||||
html [type='button'],
|
||||
[type='reset'],
|
||||
[type='submit'] {
|
||||
-webkit-appearance: button; /* 2 */
|
||||
appearance: button; /* 2 */
|
||||
}
|
||||
|
||||
/**
|
||||
@ -375,7 +374,7 @@ textarea {
|
||||
*/
|
||||
|
||||
[type='search'] {
|
||||
-webkit-appearance: textfield; /* 1 */
|
||||
appearance: textfield; /* 1 */
|
||||
outline-offset: -2px; /* 2 */
|
||||
}
|
||||
|
||||
@ -385,7 +384,7 @@ textarea {
|
||||
|
||||
[type='search']::-webkit-search-cancel-button,
|
||||
[type='search']::-webkit-search-decoration {
|
||||
-webkit-appearance: none;
|
||||
appearance: none;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -394,7 +393,7 @@ textarea {
|
||||
*/
|
||||
|
||||
::-webkit-file-upload-button {
|
||||
-webkit-appearance: button; /* 1 */
|
||||
appearance: button; /* 1 */
|
||||
font: inherit; /* 2 */
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
// ==========================================================================
|
||||
|
||||
// Grayscale
|
||||
$color-gray-900: hsl(210, 15%, 16%);
|
||||
$color-gray-900: hsl(210deg 15% 16%);
|
||||
$color-gray-800: lighten($color-gray-900, 9%);
|
||||
$color-gray-700: lighten($color-gray-800, 9%);
|
||||
$color-gray-600: lighten($color-gray-700, 9%);
|
||||
@ -15,7 +15,7 @@ $color-gray-100: lighten($color-gray-200, 9%);
|
||||
$color-gray-50: lighten($color-gray-100, 9%);
|
||||
|
||||
// Branding
|
||||
$color-brand-primary: hsl(198, 100%, 50%);
|
||||
$color-brand-primary: hsl(198deg 100% 50%);
|
||||
|
||||
// Text
|
||||
$color-text: $color-gray-700;
|
||||
@ -28,13 +28,13 @@ $color-twitter: #4baaf4;
|
||||
$color-link: $color-brand-primary;
|
||||
|
||||
// Background
|
||||
$color-background-from: hsl(198, 100%, 94%);
|
||||
$color-background-to: hsl(198, 100%, 98%);
|
||||
$color-background-from: hsl(198deg 100% 94%);
|
||||
$color-background-to: hsl(198deg 100% 98%);
|
||||
|
||||
// Buttons
|
||||
$color-button-background: $color-brand-primary;
|
||||
$color-button-text: #fff;
|
||||
$color-button-background-hover: hsl(198, 100%, 55%);
|
||||
$color-button-background-hover: hsl(198deg 100% 55%);
|
||||
$color-button-count-background: #fff;
|
||||
$color-button-count-text: $color-gray-600;
|
||||
|
||||
|
@ -2,4 +2,4 @@
|
||||
// Layout
|
||||
// ==========================================================================
|
||||
|
||||
$container-max-width: 1260px;
|
||||
$container-max-width: 1240px;
|
||||
|
@ -4,18 +4,14 @@
|
||||
|
||||
$font-sans-serif: 'Gordita', 'Avenir', 'Helvetica Neue', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji',
|
||||
'Segoe UI Symbol';
|
||||
|
||||
$font-size-base: 15;
|
||||
$font-size-small: 13;
|
||||
$font-size-large: 18;
|
||||
$font-size-h1: 64;
|
||||
|
||||
$font-weight-light: 300;
|
||||
$font-weight-regular: 400;
|
||||
$font-weight-medium: 500;
|
||||
$font-weight-bold: 600;
|
||||
$font-weight-black: 900;
|
||||
|
||||
$line-height-base: 1.75;
|
||||
|
||||
$letter-spacing-headings: -0.025em;
|
||||
|
@ -8,8 +8,9 @@ html {
|
||||
}
|
||||
|
||||
body {
|
||||
@include font-smoothing();
|
||||
@include font-smoothing;
|
||||
@include font-size($font-size-base);
|
||||
|
||||
color: $color-text;
|
||||
font-family: $font-sans-serif;
|
||||
font-weight: $font-weight-medium;
|
||||
@ -30,5 +31,6 @@ small {
|
||||
|
||||
small {
|
||||
@include font-size($font-size-small);
|
||||
|
||||
display: block;
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
h1 {
|
||||
@include font-size($font-size-h1);
|
||||
|
||||
color: $color-headings;
|
||||
font-weight: $font-weight-bold;
|
||||
letter-spacing: $letter-spacing-headings;
|
||||
|
BIN
dist/blank.mp4
vendored
BIN
dist/blank.mp4
vendored
Binary file not shown.
1
dist/plyr.css
vendored
1
dist/plyr.css
vendored
File diff suppressed because one or more lines are too long
9349
dist/plyr.js
vendored
9349
dist/plyr.js
vendored
File diff suppressed because it is too large
Load Diff
4
dist/plyr.min.js
vendored
4
dist/plyr.min.js
vendored
File diff suppressed because one or more lines are too long
1
dist/plyr.min.js.map
vendored
1
dist/plyr.min.js.map
vendored
File diff suppressed because one or more lines are too long
3
dist/plyr.min.mjs
vendored
3
dist/plyr.min.mjs
vendored
File diff suppressed because one or more lines are too long
1
dist/plyr.min.mjs.map
vendored
1
dist/plyr.min.mjs.map
vendored
File diff suppressed because one or more lines are too long
9341
dist/plyr.mjs
vendored
9341
dist/plyr.mjs
vendored
File diff suppressed because it is too large
Load Diff
15829
dist/plyr.polyfilled.js
vendored
15829
dist/plyr.polyfilled.js
vendored
File diff suppressed because it is too large
Load Diff
4
dist/plyr.polyfilled.min.js
vendored
4
dist/plyr.polyfilled.min.js
vendored
File diff suppressed because one or more lines are too long
1
dist/plyr.polyfilled.min.js.map
vendored
1
dist/plyr.polyfilled.min.js.map
vendored
File diff suppressed because one or more lines are too long
3
dist/plyr.polyfilled.min.mjs
vendored
3
dist/plyr.polyfilled.min.mjs
vendored
File diff suppressed because one or more lines are too long
1
dist/plyr.polyfilled.min.mjs.map
vendored
1
dist/plyr.polyfilled.min.mjs.map
vendored
File diff suppressed because one or more lines are too long
15821
dist/plyr.polyfilled.mjs
vendored
15821
dist/plyr.polyfilled.mjs
vendored
File diff suppressed because it is too large
Load Diff
1
dist/plyr.svg
vendored
1
dist/plyr.svg
vendored
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 5.6 KiB |
74
package.json
74
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "plyr",
|
||||
"version": "3.6.3",
|
||||
"version": "3.7.0",
|
||||
"description": "A simple, accessible and customizable HTML5, YouTube and Vimeo media player",
|
||||
"homepage": "https://plyr.io",
|
||||
"author": "Sam Potts <sam@potts.es>",
|
||||
@ -31,67 +31,67 @@
|
||||
"browserslist": "> 1%",
|
||||
"scripts": {
|
||||
"build": "gulp build",
|
||||
"lint": "eslint src/js && npm run-script remark",
|
||||
"lint:fix": "eslint --fix src/js",
|
||||
"lint": "eslint src/js && npm run remark && stylelint **/*.scss",
|
||||
"lint:fix": "eslint --fix src/js && stylelint **/*.scss --fix",
|
||||
"remark": "remark -f --use 'validate-links=repository:\"sampotts/plyr\"' '{,!(node_modules),.?**/}*.md'",
|
||||
"deploy": "yarn lint && gulp version && gulp build && gulp deploy",
|
||||
"format": "prettier --write \"./{src,demo/src}/**/*.{js,scss}\"",
|
||||
"spellcheck": "cspell \"**/*.{js,md,scss,json}\" --no-must-find-files",
|
||||
"start": "gulp"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sampotts/eslint-config": "1.1.5",
|
||||
"ansi-colors": "^4.1.1",
|
||||
"autoprefixer": "^10.0.2",
|
||||
"aws-sdk": "^2.773.0",
|
||||
"@babel/core": "^7.12.3",
|
||||
"@babel/preset-env": "^7.12.1",
|
||||
"@babel/core": "^7.17.9",
|
||||
"@babel/plugin-proposal-class-properties": "^7.16.7",
|
||||
"@babel/preset-env": "^7.16.11",
|
||||
"@sampotts/eslint-config": "1.1.7",
|
||||
"autoprefixer": "^10.4.4",
|
||||
"aws-sdk": "^2.1116.0",
|
||||
"babel-eslint": "^10.1.0",
|
||||
"browser-sync": "^2.26.13",
|
||||
"browser-sync": "^2.27.9",
|
||||
"colorette": "2.0.16",
|
||||
"cspell": "^5.19.7",
|
||||
"cssnano": "^5.1.7",
|
||||
"del": "^6.0.0",
|
||||
"eslint": "^7.3.1",
|
||||
"fancy-log": "^1.3.3",
|
||||
"fastly-purge": "^1.0.1",
|
||||
"eslint": "^7.23.0",
|
||||
"fancy-log": "^2.0.0",
|
||||
"git-branch": "^2.0.1",
|
||||
"gulp": "^4.0.2",
|
||||
"gulp-awspublish": "^4.1.2",
|
||||
"gulp-awspublish": "^6.0.2",
|
||||
"gulp-better-rollup": "^4.0.1",
|
||||
"gulp-filter": "^6.0.0",
|
||||
"gulp-filter": "^7.0.0",
|
||||
"gulp-header": "^2.0.9",
|
||||
"gulp-hub": "^4.2.0",
|
||||
"gulp-if": "^3.0.0",
|
||||
"gulp-imagemin": "^7.1.0",
|
||||
"gulp-open": "^3.0.1",
|
||||
"gulp-plumber": "^1.2.1",
|
||||
"gulp-postcss": "^9.0.0",
|
||||
"gulp-postcss": "^9.0.1",
|
||||
"gulp-rename": "^2.0.0",
|
||||
"gulp-replace": "^1.0.0",
|
||||
"gulp-sass": "^4.1.0",
|
||||
"gulp-size": "^3.0.0",
|
||||
"gulp-replace": "^1.1.3",
|
||||
"gulp-sass": "^5.1.0",
|
||||
"gulp-size": "^4.0.1",
|
||||
"gulp-sourcemaps": "^3.0.0",
|
||||
"gulp-svgstore": "^7.0.1",
|
||||
"gulp-terser": "^1.4.1",
|
||||
"postcss": "^8.1.7",
|
||||
"postcss-clean": "^1.1.0",
|
||||
"postcss-custom-properties": "^10.0.0",
|
||||
"prettier-eslint": "^11.0.0",
|
||||
"gulp-svgstore": "^9.0.0",
|
||||
"gulp-terser": "^2.1.0",
|
||||
"postcss": "^8.4.12",
|
||||
"postcss-custom-properties": "^12.1.7",
|
||||
"postcss-scss": "^4.0.3",
|
||||
"prettier-eslint": "^12.0.0",
|
||||
"prettier-stylelint": "^0.4.2",
|
||||
"remark-cli": "^9.0.0",
|
||||
"remark-validate-links": "^10.0.2",
|
||||
"rollup": "^2.33.1",
|
||||
"remark-cli": "^10.0.1",
|
||||
"remark-validate-links": "^11.0.2",
|
||||
"rollup": "^2.70.2",
|
||||
"rollup-plugin-babel": "^4.4.0",
|
||||
"rollup-plugin-commonjs": "^10.1.0",
|
||||
"rollup-plugin-node-resolve": "^5.2.0",
|
||||
"stylelint": "^13.7.2",
|
||||
"stylelint-config-prettier": "^8.0.2",
|
||||
"stylelint-config-recommended": "^3.0.0",
|
||||
"stylelint-config-sass-guidelines": "^7.1.0",
|
||||
"stylelint-order": "^4.1.0",
|
||||
"stylelint-scss": "^3.18.0",
|
||||
"stylelint-selector-bem-pattern": "^2.1.0",
|
||||
"through2": "^4.0.2"
|
||||
"sass": "^1.50.0",
|
||||
"stylelint": "^14.7.1",
|
||||
"stylelint-config-prettier": "^9.0.3",
|
||||
"stylelint-config-sass-guidelines": "^9.0.1",
|
||||
"stylelint-selector-bem-pattern": "^2.1.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"core-js": "^3.7.0",
|
||||
"core-js": "^3.22.0",
|
||||
"custom-event-polyfill": "^1.0.7",
|
||||
"loadjs": "^4.2.0",
|
||||
"rangetouch": "^2.0.1",
|
||||
|
@ -12,7 +12,9 @@
|
||||
|
||||
// Linting
|
||||
"stylelint.enable": true,
|
||||
"stylelint.validate": ["css", "scss"],
|
||||
"css.validate": false,
|
||||
"less.validate": false,
|
||||
"scss.validate": false,
|
||||
"javascript.validate.enable": false,
|
||||
|
||||
|
@ -154,7 +154,9 @@ const captions = {
|
||||
}
|
||||
|
||||
// Enable or disable captions based on track length
|
||||
toggleClass(this.elements.container, this.config.classNames.captions.enabled, !is.empty(tracks));
|
||||
if (this.elements) {
|
||||
toggleClass(this.elements.container, this.config.classNames.captions.enabled, !is.empty(tracks));
|
||||
}
|
||||
|
||||
// Update available languages in list
|
||||
if (
|
||||
|
@ -61,7 +61,7 @@ const defaults = {
|
||||
// Sprite (for icons)
|
||||
loadSprite: true,
|
||||
iconPrefix: 'plyr',
|
||||
iconUrl: 'https://cdn.plyr.io/3.6.3/plyr.svg',
|
||||
iconUrl: 'https://cdn.plyr.io/3.7.0/plyr.svg',
|
||||
|
||||
// Blank video (used to prevent errors on source change)
|
||||
blankVideo: 'https://cdn.plyr.io/static/blank.mp4',
|
||||
@ -350,6 +350,7 @@ const defaults = {
|
||||
hover: 'plyr--hover',
|
||||
tooltip: 'plyr__tooltip',
|
||||
cues: 'plyr__cues',
|
||||
marker: 'plyr__progress__marker',
|
||||
hidden: 'plyr__sr-only',
|
||||
hideControls: 'plyr--hide-controls',
|
||||
isIos: 'plyr--is-ios',
|
||||
@ -398,6 +399,7 @@ const defaults = {
|
||||
embed: {
|
||||
provider: 'data-plyr-provider',
|
||||
id: 'data-plyr-embed-id',
|
||||
hash: 'data-plyr-embed-hash',
|
||||
},
|
||||
},
|
||||
|
||||
@ -440,6 +442,20 @@ const defaults = {
|
||||
customControls: true,
|
||||
noCookie: false, // Whether to use an alternative version of YouTube without cookies
|
||||
},
|
||||
|
||||
// Media Metadata
|
||||
mediaMetadata: {
|
||||
title: '',
|
||||
artist: '',
|
||||
album: '',
|
||||
artwork: [],
|
||||
},
|
||||
|
||||
// Markers
|
||||
markers: {
|
||||
enabled: false,
|
||||
points: [],
|
||||
},
|
||||
};
|
||||
|
||||
export default defaults;
|
||||
|
118
src/js/controls.js
vendored
118
src/js/controls.js
vendored
@ -38,7 +38,8 @@ const controls = {
|
||||
// Get icon URL
|
||||
getIconUrl() {
|
||||
const url = new URL(this.config.iconUrl, window.location);
|
||||
const cors = url.host !== window.location.host || (browser.isIE && !window.svg4everybody);
|
||||
const host = window.location.host ? window.location.host : window.top.location.host;
|
||||
const cors = url.host !== host || (browser.isIE && !window.svg4everybody);
|
||||
|
||||
return {
|
||||
url: this.config.iconUrl,
|
||||
@ -483,7 +484,7 @@ const controls = {
|
||||
|
||||
menuItem.appendChild(flex);
|
||||
|
||||
// Replicate radio button behaviour
|
||||
// Replicate radio button behavior
|
||||
Object.defineProperty(menuItem, 'checked', {
|
||||
enumerable: true,
|
||||
get() {
|
||||
@ -697,8 +698,9 @@ const controls = {
|
||||
return;
|
||||
}
|
||||
|
||||
const tipElement = this.elements.display.seekTooltip;
|
||||
const visible = `${this.config.classNames.tooltip}--visible`;
|
||||
const toggle = (show) => toggleClass(this.elements.display.seekTooltip, visible, show);
|
||||
const toggle = (show) => toggleClass(tipElement, visible, show);
|
||||
|
||||
// Hide on touch
|
||||
if (this.touch) {
|
||||
@ -712,8 +714,8 @@ const controls = {
|
||||
|
||||
if (is.event(event)) {
|
||||
percent = (100 / clientRect.width) * (event.pageX - clientRect.left);
|
||||
} else if (hasClass(this.elements.display.seekTooltip, visible)) {
|
||||
percent = parseFloat(this.elements.display.seekTooltip.style.left, 10);
|
||||
} else if (hasClass(tipElement, visible)) {
|
||||
percent = parseFloat(tipElement.style.left, 10);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
@ -725,11 +727,21 @@ const controls = {
|
||||
percent = 100;
|
||||
}
|
||||
|
||||
const time = (this.duration / 100) * percent;
|
||||
|
||||
// Display the time a click would seek to
|
||||
controls.updateTimeDisplay.call(this, this.elements.display.seekTooltip, (this.duration / 100) * percent);
|
||||
tipElement.innerText = controls.formatTime(time);
|
||||
|
||||
// Get marker point for time
|
||||
const point = this.config.markers?.points?.find(({ time: t }) => t === Math.round(time));
|
||||
|
||||
// Append the point label to the tooltip
|
||||
if (point) {
|
||||
tipElement.insertAdjacentHTML('afterbegin', `${point.label}<br>`);
|
||||
}
|
||||
|
||||
// Set position
|
||||
this.elements.display.seekTooltip.style.left = `${percent}%`;
|
||||
tipElement.style.left = `${percent}%`;
|
||||
|
||||
// Show/hide the tooltip
|
||||
// If the event is a moues in/out and percentage is inside bounds
|
||||
@ -795,6 +807,10 @@ const controls = {
|
||||
controls.updateTimeDisplay.call(this, this.elements.display.duration, this.duration);
|
||||
}
|
||||
|
||||
if (this.config.markers.enabled) {
|
||||
controls.setMarkers.call(this);
|
||||
}
|
||||
|
||||
// Update the tooltip (if visible)
|
||||
controls.updateSeekTooltip.call(this);
|
||||
},
|
||||
@ -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;
|
||||
|
@ -57,6 +57,8 @@ class Fullscreen {
|
||||
|
||||
// Update the UI
|
||||
this.update();
|
||||
|
||||
// this.toggle = this.toggle.bind(this);
|
||||
}
|
||||
|
||||
// Determine if native supported
|
||||
@ -122,7 +124,9 @@ class Fullscreen {
|
||||
return hasClass(this.target, this.player.config.classNames.fullscreen.fallback);
|
||||
}
|
||||
|
||||
const element = !this.prefix ? document.fullscreenElement : document[`${this.prefix}${this.property}Element`];
|
||||
const element = !this.prefix
|
||||
? this.target.getRootNode().fullscreenElement
|
||||
: this.target.getRootNode()[`${this.prefix}${this.property}Element`];
|
||||
|
||||
return element && element.shadowRoot ? element === this.target.getRootNode().host : element === this.target;
|
||||
}
|
||||
@ -134,7 +138,7 @@ class Fullscreen {
|
||||
: this.player.elements.fullscreen || this.player.elements.container;
|
||||
}
|
||||
|
||||
onChange() {
|
||||
onChange = () => {
|
||||
if (!this.enabled) {
|
||||
return;
|
||||
}
|
||||
@ -149,9 +153,9 @@ class Fullscreen {
|
||||
const target = this.target === this.player.media ? this.target : this.player.elements.container;
|
||||
// Trigger an event
|
||||
triggerEvent.call(this.player, target, this.active ? 'enterfullscreen' : 'exitfullscreen', true);
|
||||
}
|
||||
};
|
||||
|
||||
toggleFallback(toggle = false) {
|
||||
toggleFallback = (toggle = false) => {
|
||||
// Store or restore scroll position
|
||||
if (toggle) {
|
||||
this.scrollPosition = {
|
||||
@ -198,10 +202,10 @@ class Fullscreen {
|
||||
|
||||
// Toggle button and fire events
|
||||
this.onChange();
|
||||
}
|
||||
};
|
||||
|
||||
// Trap focus inside container
|
||||
trapFocus(event) {
|
||||
trapFocus = (event) => {
|
||||
// Bail if iOS, not active, not the tab key
|
||||
if (browser.isIos || !this.active || event.key !== 'Tab' || event.keyCode !== 9) {
|
||||
return;
|
||||
@ -222,10 +226,10 @@ class Fullscreen {
|
||||
last.focus();
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Update UI
|
||||
update() {
|
||||
update = () => {
|
||||
if (this.enabled) {
|
||||
let mode;
|
||||
|
||||
@ -244,17 +248,21 @@ class Fullscreen {
|
||||
|
||||
// Add styling hook to show button
|
||||
toggleClass(this.player.elements.container, this.player.config.classNames.fullscreen.enabled, this.enabled);
|
||||
}
|
||||
};
|
||||
|
||||
// Make an element fullscreen
|
||||
enter() {
|
||||
enter = () => {
|
||||
if (!this.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
// iOS native fullscreen doesn't need the request step
|
||||
if (browser.isIos && this.player.config.fullscreen.iosNative) {
|
||||
this.target.webkitEnterFullscreen();
|
||||
if (this.player.isVimeo) {
|
||||
this.player.embed.requestFullscreen();
|
||||
} else {
|
||||
this.target.webkitEnterFullscreen();
|
||||
}
|
||||
} else if (!Fullscreen.native || this.forceFallback) {
|
||||
this.toggleFallback(true);
|
||||
} else if (!this.prefix) {
|
||||
@ -262,10 +270,10 @@ class Fullscreen {
|
||||
} else if (!is.empty(this.prefix)) {
|
||||
this.target[`${this.prefix}Request${this.property}`]();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Bail from fullscreen
|
||||
exit() {
|
||||
exit = () => {
|
||||
if (!this.enabled) {
|
||||
return;
|
||||
}
|
||||
@ -282,16 +290,16 @@ class Fullscreen {
|
||||
const action = this.prefix === 'moz' ? 'Cancel' : 'Exit';
|
||||
document[`${this.prefix}${action}${this.property}`]();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Toggle state
|
||||
toggle() {
|
||||
toggle = () => {
|
||||
if (!this.active) {
|
||||
this.enter();
|
||||
} else {
|
||||
this.exit();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export default Fullscreen;
|
||||
|
@ -73,7 +73,7 @@ const html5 = {
|
||||
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)) {
|
||||
player.config.quality.onChange(input);
|
||||
} else {
|
||||
|
@ -10,7 +10,7 @@ import { getElement, getElements, matches, toggleClass } from './utils/elements'
|
||||
import { off, on, once, toggleListener, triggerEvent } from './utils/events';
|
||||
import is from './utils/is';
|
||||
import { silencePromise } from './utils/promise';
|
||||
import { getAspectRatio, setAspectRatio } from './utils/style';
|
||||
import { getAspectRatio, getViewportSize, supportsCSS } from './utils/style';
|
||||
|
||||
class Listeners {
|
||||
constructor(player) {
|
||||
@ -149,16 +149,16 @@ class Listeners {
|
||||
break;
|
||||
|
||||
/* case 73:
|
||||
this.setLoop('start');
|
||||
break;
|
||||
this.setLoop('start');
|
||||
break;
|
||||
|
||||
case 76:
|
||||
this.setLoop();
|
||||
break;
|
||||
case 76:
|
||||
this.setLoop();
|
||||
break;
|
||||
|
||||
case 79:
|
||||
this.setLoop('end');
|
||||
break; */
|
||||
case 79:
|
||||
this.setLoop('end');
|
||||
break; */
|
||||
|
||||
default:
|
||||
break;
|
||||
@ -183,7 +183,7 @@ class Listeners {
|
||||
}
|
||||
|
||||
// Device is touch enabled
|
||||
firstTouch() {
|
||||
firstTouch = () => {
|
||||
const { player } = this;
|
||||
const { elements } = player;
|
||||
|
||||
@ -191,9 +191,9 @@ class Listeners {
|
||||
|
||||
// Add touch class
|
||||
toggleClass(elements.container, player.config.classNames.isTouch, true);
|
||||
}
|
||||
};
|
||||
|
||||
setTabFocus(event) {
|
||||
setTabFocus = (event) => {
|
||||
const { player } = this;
|
||||
const { elements } = player;
|
||||
|
||||
@ -241,10 +241,10 @@ class Listeners {
|
||||
toggleClass(document.activeElement, player.config.classNames.tabFocus, true);
|
||||
}, 10);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Global window & document listeners
|
||||
global(toggle = true) {
|
||||
global = (toggle = true) => {
|
||||
const { player } = this;
|
||||
|
||||
// Keyboard shortcuts
|
||||
@ -260,10 +260,10 @@ class Listeners {
|
||||
|
||||
// Tab focus detection
|
||||
toggleListener.call(player, document.body, 'keydown focus blur focusout', this.setTabFocus, toggle, false, true);
|
||||
}
|
||||
};
|
||||
|
||||
// Container listeners
|
||||
container() {
|
||||
container = () => {
|
||||
const { player } = this;
|
||||
const { config, elements, timers } = player;
|
||||
|
||||
@ -305,39 +305,49 @@ class Listeners {
|
||||
);
|
||||
|
||||
// Set a gutter for Vimeo
|
||||
const setGutter = (ratio, padding, toggle) => {
|
||||
const setGutter = () => {
|
||||
if (!player.isVimeo || player.config.vimeo.premium) {
|
||||
return;
|
||||
}
|
||||
|
||||
const target = player.elements.wrapper.firstChild;
|
||||
const [, y] = ratio;
|
||||
const [videoX, videoY] = getAspectRatio.call(player);
|
||||
const target = elements.wrapper;
|
||||
const { active } = player.fullscreen;
|
||||
const [videoWidth, videoHeight] = getAspectRatio.call(player);
|
||||
const useNativeAspectRatio = supportsCSS(`aspect-ratio: ${videoWidth} / ${videoHeight}`);
|
||||
|
||||
target.style.maxWidth = toggle ? `${(y / videoY) * videoX}px` : null;
|
||||
target.style.margin = toggle ? '0 auto' : null;
|
||||
};
|
||||
|
||||
// Resize on fullscreen change
|
||||
const setPlayerSize = (measure) => {
|
||||
// If we don't need to measure the viewport
|
||||
if (!measure) {
|
||||
return setAspectRatio.call(player);
|
||||
// If not active, remove styles
|
||||
if (!active) {
|
||||
if (useNativeAspectRatio) {
|
||||
target.style.width = null;
|
||||
target.style.height = null;
|
||||
} else {
|
||||
target.style.maxWidth = null;
|
||||
target.style.margin = null;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const rect = elements.container.getBoundingClientRect();
|
||||
const { width, height } = rect;
|
||||
// Determine which dimension will overflow and constrain view
|
||||
const [viewportWidth, viewportHeight] = getViewportSize();
|
||||
const overflow = viewportWidth / viewportHeight > videoWidth / videoHeight;
|
||||
|
||||
return setAspectRatio.call(player, `${width}:${height}`);
|
||||
if (useNativeAspectRatio) {
|
||||
target.style.width = overflow ? 'auto' : '100%';
|
||||
target.style.height = overflow ? '100%' : 'auto';
|
||||
} else {
|
||||
target.style.maxWidth = overflow ? `${(viewportHeight / videoHeight) * videoWidth}px` : null;
|
||||
target.style.margin = overflow ? '0 auto' : null;
|
||||
}
|
||||
};
|
||||
|
||||
// Handle resizing
|
||||
const resized = () => {
|
||||
clearTimeout(timers.resized);
|
||||
timers.resized = setTimeout(setPlayerSize, 50);
|
||||
timers.resized = setTimeout(setGutter, 50);
|
||||
};
|
||||
|
||||
on.call(player, elements.container, 'enterfullscreen exitfullscreen', (event) => {
|
||||
const { target, usingNative } = player.fullscreen;
|
||||
const { target } = player.fullscreen;
|
||||
|
||||
// Ignore events not from target
|
||||
if (target !== elements.container) {
|
||||
@ -349,31 +359,17 @@ class Listeners {
|
||||
return;
|
||||
}
|
||||
|
||||
const isEnter = event.type === 'enterfullscreen';
|
||||
// Set the player size when entering fullscreen to viewport size
|
||||
const { padding, ratio } = setPlayerSize(isEnter);
|
||||
|
||||
// Set Vimeo gutter
|
||||
setGutter(ratio, padding, isEnter);
|
||||
setGutter();
|
||||
|
||||
// Horrible hack for Safari 14 not repainting properly on entering fullscreen
|
||||
if (isEnter) {
|
||||
setTimeout(() => repaint(elements.container), 100);
|
||||
}
|
||||
|
||||
// If not using native browser fullscreen API, we need to check for resizes of viewport
|
||||
if (!usingNative) {
|
||||
if (isEnter) {
|
||||
on.call(player, window, 'resize', resized);
|
||||
} else {
|
||||
off.call(player, window, 'resize', resized);
|
||||
}
|
||||
}
|
||||
// Watch for resizes
|
||||
const method = event.type === 'enterfullscreen' ? on : off;
|
||||
method.call(player, window, 'resize', resized);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// Listen for media events
|
||||
media() {
|
||||
media = () => {
|
||||
const { player } = this;
|
||||
const { elements } = player;
|
||||
|
||||
@ -514,10 +510,10 @@ class Listeners {
|
||||
|
||||
triggerEvent.call(player, elements.container, event.type, true, detail);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// Run default and custom handlers
|
||||
proxy(event, defaultHandler, customHandlerKey) {
|
||||
proxy = (event, defaultHandler, customHandlerKey) => {
|
||||
const { player } = this;
|
||||
const customHandler = player.config.listeners[customHandlerKey];
|
||||
const hasCustomHandler = is.function(customHandler);
|
||||
@ -532,10 +528,10 @@ class Listeners {
|
||||
if (returned !== false && is.function(defaultHandler)) {
|
||||
defaultHandler.call(player, event);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Trigger custom and default handlers
|
||||
bind(element, type, defaultHandler, customHandlerKey, passive = true) {
|
||||
bind = (element, type, defaultHandler, customHandlerKey, passive = true) => {
|
||||
const { player } = this;
|
||||
const customHandler = player.config.listeners[customHandlerKey];
|
||||
const hasCustomHandler = is.function(customHandler);
|
||||
@ -547,10 +543,10 @@ class Listeners {
|
||||
(event) => this.proxy(event, defaultHandler, customHandlerKey),
|
||||
passive && !hasCustomHandler,
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
// Listen for control events
|
||||
controls() {
|
||||
controls = () => {
|
||||
const { player } = this;
|
||||
const { elements } = player;
|
||||
// IE doesn't support input event, so we fallback to change
|
||||
@ -845,7 +841,9 @@ class Listeners {
|
||||
.filter((c) => !c.contains(elements.container))
|
||||
.forEach((child) => {
|
||||
this.bind(child, 'mouseenter mouseleave', (event) => {
|
||||
elements.controls.hover = !player.touch && event.type === 'mouseenter';
|
||||
if (elements.controls) {
|
||||
elements.controls.hover = !player.touch && event.type === 'mouseenter';
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -905,7 +903,7 @@ class Listeners {
|
||||
'volume',
|
||||
false,
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export default Listeners;
|
||||
|
@ -41,7 +41,6 @@ const media = {
|
||||
// Poster image container
|
||||
this.elements.poster = createElement('div', {
|
||||
class: this.config.classNames.poster,
|
||||
hidden: '',
|
||||
});
|
||||
|
||||
this.elements.wrapper.appendChild(this.elements.poster);
|
||||
|
@ -77,7 +77,7 @@ class Ads {
|
||||
/**
|
||||
* Load the IMA SDK
|
||||
*/
|
||||
load() {
|
||||
load = () => {
|
||||
if (!this.enabled) {
|
||||
return;
|
||||
}
|
||||
@ -95,12 +95,12 @@ class Ads {
|
||||
} else {
|
||||
this.ready();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the ads instance ready
|
||||
*/
|
||||
ready() {
|
||||
ready = () => {
|
||||
// Double check we're enabled
|
||||
if (!this.enabled) {
|
||||
destroy(this);
|
||||
@ -120,7 +120,7 @@ class Ads {
|
||||
|
||||
// Setup the IMA SDK
|
||||
this.setupIMA();
|
||||
}
|
||||
};
|
||||
|
||||
// Build the tag URL
|
||||
get tagUrl() {
|
||||
@ -153,7 +153,7 @@ class Ads {
|
||||
* properly place mid-rolls. After we create the ad display container, we initialize it. On
|
||||
* mobile devices, this initialization is done as the result of a user action.
|
||||
*/
|
||||
setupIMA() {
|
||||
setupIMA = () => {
|
||||
// Create the container for our advertisements
|
||||
this.elements.container = createElement('div', {
|
||||
class: this.player.config.classNames.ads,
|
||||
@ -186,12 +186,12 @@ class Ads {
|
||||
|
||||
// Request video ads to be pre-loaded
|
||||
this.requestAds();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Request advertisements
|
||||
*/
|
||||
requestAds() {
|
||||
requestAds = () => {
|
||||
const { container } = this.player.elements;
|
||||
|
||||
try {
|
||||
@ -213,16 +213,16 @@ class Ads {
|
||||
request.setAdWillPlayMuted(!this.player.muted);
|
||||
|
||||
this.loader.requestAds(request);
|
||||
} catch (e) {
|
||||
this.onAdError(e);
|
||||
} catch (error) {
|
||||
this.onAdError(error);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Update the ad countdown
|
||||
* @param {Boolean} start
|
||||
*/
|
||||
pollCountdown(start = false) {
|
||||
pollCountdown = (start = false) => {
|
||||
if (!start) {
|
||||
clearInterval(this.countdownTimer);
|
||||
this.elements.container.removeAttribute('data-badge-text');
|
||||
@ -236,13 +236,13 @@ class Ads {
|
||||
};
|
||||
|
||||
this.countdownTimer = setInterval(update, 100);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* This method is called whenever the ads are ready inside the AdDisplayContainer
|
||||
* @param {Event} adsManagerLoadedEvent
|
||||
*/
|
||||
onAdsManagerLoaded(event) {
|
||||
onAdsManagerLoaded = (event) => {
|
||||
// Load could occur after a source change (race condition)
|
||||
if (!this.enabled) {
|
||||
return;
|
||||
@ -273,9 +273,9 @@ class Ads {
|
||||
|
||||
// Resolve our adsManager
|
||||
this.trigger('loaded');
|
||||
}
|
||||
};
|
||||
|
||||
addCuePoints() {
|
||||
addCuePoints = () => {
|
||||
// Add advertisement cue's within the time line if available
|
||||
if (!is.empty(this.cuePoints)) {
|
||||
this.cuePoints.forEach((cuePoint) => {
|
||||
@ -294,7 +294,7 @@ class Ads {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* This is where all the event handling takes place. Retrieve the ad from the event. Some
|
||||
@ -302,7 +302,7 @@ class Ads {
|
||||
* https://developers.google.com/interactive-media-ads/docs/sdks/html5/v3/apis#ima.AdEvent.Type
|
||||
* @param {Event} event
|
||||
*/
|
||||
onAdEvent(event) {
|
||||
onAdEvent = (event) => {
|
||||
const { container } = this.player.elements;
|
||||
// Retrieve the ad from the event. Some events (e.g. ALL_ADS_COMPLETED)
|
||||
// don't have ad object associated
|
||||
@ -410,23 +410,23 @@ class Ads {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Any ad error handling comes through here
|
||||
* @param {Event} event
|
||||
*/
|
||||
onAdError(event) {
|
||||
onAdError = (event) => {
|
||||
this.cancel();
|
||||
this.player.debug.warn('Ads error', event);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Setup hooks for Plyr and window events. This ensures
|
||||
* the mid- and post-roll launch at the correct time. And
|
||||
* resize the advertisement when the player resizes
|
||||
*/
|
||||
listeners() {
|
||||
listeners = () => {
|
||||
const { container } = this.player.elements;
|
||||
let time;
|
||||
|
||||
@ -464,12 +464,12 @@ class Ads {
|
||||
this.manager.resize(container.offsetWidth, container.offsetHeight, google.ima.ViewMode.NORMAL);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize the adsManager and start playing advertisements
|
||||
*/
|
||||
play() {
|
||||
play = () => {
|
||||
const { container } = this.player.elements;
|
||||
|
||||
if (!this.managerPromise) {
|
||||
@ -503,12 +503,12 @@ class Ads {
|
||||
}
|
||||
})
|
||||
.catch(() => {});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Resume our video
|
||||
*/
|
||||
resumeContent() {
|
||||
resumeContent = () => {
|
||||
// Hide the advertisement container
|
||||
this.elements.container.style.zIndex = '';
|
||||
|
||||
@ -517,12 +517,12 @@ class Ads {
|
||||
|
||||
// Play video
|
||||
silencePromise(this.player.media.play());
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Pause our video
|
||||
*/
|
||||
pauseContent() {
|
||||
pauseContent = () => {
|
||||
// Show the advertisement container
|
||||
this.elements.container.style.zIndex = 3;
|
||||
|
||||
@ -531,7 +531,7 @@ class Ads {
|
||||
|
||||
// Pause our video.
|
||||
this.player.media.pause();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Destroy the adsManager so we can grab new ads after this. If we don't then we're not
|
||||
@ -539,7 +539,7 @@ class Ads {
|
||||
* video requests. https://developers.google.com/interactive-
|
||||
* media-ads/docs/sdks/android/faq#8
|
||||
*/
|
||||
cancel() {
|
||||
cancel = () => {
|
||||
// Pause our video
|
||||
if (this.initialized) {
|
||||
this.resumeContent();
|
||||
@ -550,12 +550,12 @@ class Ads {
|
||||
|
||||
// Re-create our adsManager
|
||||
this.loadAds();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Re-create our adsManager
|
||||
*/
|
||||
loadAds() {
|
||||
loadAds = () => {
|
||||
// Tell our adsManager to go bye bye
|
||||
this.managerPromise
|
||||
.then(() => {
|
||||
@ -576,13 +576,13 @@ class Ads {
|
||||
this.requestAds();
|
||||
})
|
||||
.catch(() => {});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Handles callbacks after an ad event was invoked
|
||||
* @param {String} event - Event type
|
||||
*/
|
||||
trigger(event, ...args) {
|
||||
trigger = (event, ...args) => {
|
||||
const handlers = this.events[event];
|
||||
|
||||
if (is.array(handlers)) {
|
||||
@ -592,7 +592,7 @@ class Ads {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Add event listeners
|
||||
@ -600,7 +600,7 @@ class Ads {
|
||||
* @param {Function} callback - Callback for when event occurs
|
||||
* @return {Ads}
|
||||
*/
|
||||
on(event, callback) {
|
||||
on = (event, callback) => {
|
||||
if (!is.array(this.events[event])) {
|
||||
this.events[event] = [];
|
||||
}
|
||||
@ -608,7 +608,7 @@ class Ads {
|
||||
this.events[event].push(callback);
|
||||
|
||||
return this;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Setup a safety timer for when the ad network doesn't respond for whatever reason.
|
||||
@ -618,27 +618,27 @@ class Ads {
|
||||
* @param {Number} time
|
||||
* @param {String} from
|
||||
*/
|
||||
startSafetyTimer(time, from) {
|
||||
startSafetyTimer = (time, from) => {
|
||||
this.player.debug.log(`Safety timer invoked from: ${from}`);
|
||||
|
||||
this.safetyTimer = setTimeout(() => {
|
||||
this.cancel();
|
||||
this.clearSafetyTimer('startSafetyTimer()');
|
||||
}, time);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Clear our safety timer(s)
|
||||
* @param {String} from
|
||||
*/
|
||||
clearSafetyTimer(from) {
|
||||
clearSafetyTimer = (from) => {
|
||||
if (!is.nullOrUndefined(this.safetyTimer)) {
|
||||
this.player.debug.log(`Safety timer cleared from: ${from}`);
|
||||
|
||||
clearTimeout(this.safetyTimer);
|
||||
this.safetyTimer = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export default Ads;
|
||||
|
@ -103,7 +103,7 @@ class PreviewThumbnails {
|
||||
return this.player.isHTML5 && this.player.isVideo && this.player.config.previewThumbnails.enabled;
|
||||
}
|
||||
|
||||
load() {
|
||||
load = () => {
|
||||
// Toggle the regular seek tooltip
|
||||
if (this.player.elements.display.seekTooltip) {
|
||||
this.player.elements.display.seekTooltip.hidden = this.enabled;
|
||||
@ -126,10 +126,10 @@ class PreviewThumbnails {
|
||||
|
||||
this.loaded = true;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// Download VTT files and parse them
|
||||
getThumbnails() {
|
||||
getThumbnails = () => {
|
||||
return new Promise((resolve) => {
|
||||
const { src } = this.player.config.previewThumbnails;
|
||||
|
||||
@ -164,10 +164,10 @@ class PreviewThumbnails {
|
||||
Promise.all(promises).then(sortAndResolve);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// Process individual VTT file
|
||||
getThumbnail(url) {
|
||||
getThumbnail = (url) => {
|
||||
return new Promise((resolve) => {
|
||||
fetch(url).then((response) => {
|
||||
const thumbnail = {
|
||||
@ -202,9 +202,9 @@ class PreviewThumbnails {
|
||||
tempImage.src = thumbnail.urlPrefix + thumbnail.frames[0].text;
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
startMove(event) {
|
||||
startMove = (event) => {
|
||||
if (!this.loaded) {
|
||||
return;
|
||||
}
|
||||
@ -241,17 +241,26 @@ class PreviewThumbnails {
|
||||
|
||||
// Set time text inside image container
|
||||
this.elements.thumb.time.innerText = formatTime(this.seekTime);
|
||||
|
||||
// Get marker point for time
|
||||
const point = this.player.config.markers?.points?.find(({ time: t }) => t === Math.round(this.seekTime));
|
||||
|
||||
// Append the point label to the tooltip
|
||||
if (point) {
|
||||
// this.elements.thumb.time.innerText.concat('\n');
|
||||
this.elements.thumb.time.insertAdjacentHTML('afterbegin', `${point.label}<br>`);
|
||||
}
|
||||
}
|
||||
|
||||
// Download and show image
|
||||
this.showImageAtCurrentTime();
|
||||
}
|
||||
};
|
||||
|
||||
endMove() {
|
||||
endMove = () => {
|
||||
this.toggleThumbContainer(false, true);
|
||||
}
|
||||
};
|
||||
|
||||
startScrubbing(event) {
|
||||
startScrubbing = (event) => {
|
||||
// Only act on left mouse button (0), or touch device (event.button does not exist or is false)
|
||||
if (is.nullOrUndefined(event.button) || event.button === false || event.button === 0) {
|
||||
this.mouseDown = true;
|
||||
@ -265,9 +274,9 @@ class PreviewThumbnails {
|
||||
this.showImageAtCurrentTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
endScrubbing() {
|
||||
endScrubbing = () => {
|
||||
this.mouseDown = false;
|
||||
|
||||
// Hide scrubbing preview. But wait until the video has successfully seeked before hiding the scrubbing preview
|
||||
@ -283,12 +292,12 @@ class PreviewThumbnails {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Setup hooks for Plyr and window events
|
||||
*/
|
||||
listeners() {
|
||||
listeners = () => {
|
||||
// Hide thumbnail preview - on mouse click, mouse leave (in listeners.js for now), and video play/seek. All four are required, e.g., for buffering
|
||||
this.player.on('play', () => {
|
||||
this.toggleThumbContainer(false, true);
|
||||
@ -301,12 +310,12 @@ class PreviewThumbnails {
|
||||
this.player.on('timeupdate', () => {
|
||||
this.lastTime = this.player.media.currentTime;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Create HTML elements for image containers
|
||||
*/
|
||||
render() {
|
||||
render = () => {
|
||||
// Create HTML element: plyr__preview-thumbnail-container
|
||||
this.elements.thumb.container = createElement('div', {
|
||||
class: this.player.config.classNames.previewThumbnails.thumbContainer,
|
||||
@ -326,7 +335,7 @@ class PreviewThumbnails {
|
||||
this.elements.thumb.time = createElement('span', {}, '00:00');
|
||||
timeContainer.appendChild(this.elements.thumb.time);
|
||||
|
||||
this.elements.thumb.container.appendChild(timeContainer);
|
||||
this.elements.thumb.imageContainer.appendChild(timeContainer);
|
||||
|
||||
// Inject the whole thumb
|
||||
if (is.element(this.player.elements.progress)) {
|
||||
@ -339,18 +348,18 @@ class PreviewThumbnails {
|
||||
});
|
||||
|
||||
this.player.elements.wrapper.appendChild(this.elements.scrubbing.container);
|
||||
}
|
||||
};
|
||||
|
||||
destroy() {
|
||||
destroy = () => {
|
||||
if (this.elements.thumb.container) {
|
||||
this.elements.thumb.container.remove();
|
||||
}
|
||||
if (this.elements.scrubbing.container) {
|
||||
this.elements.scrubbing.container.remove();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
showImageAtCurrentTime() {
|
||||
showImageAtCurrentTime = () => {
|
||||
if (this.mouseDown) {
|
||||
this.setScrubbingContainerSize();
|
||||
} else {
|
||||
@ -387,10 +396,10 @@ class PreviewThumbnails {
|
||||
this.showingThumb = thumbNum;
|
||||
this.loadImage(qualityIndex);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Show the image that's currently specified in this.showingThumb
|
||||
loadImage(qualityIndex = 0) {
|
||||
loadImage = (qualityIndex = 0) => {
|
||||
const thumbNum = this.showingThumb;
|
||||
const thumbnail = this.thumbnails[qualityIndex];
|
||||
const { urlPrefix } = thumbnail;
|
||||
@ -426,9 +435,9 @@ class PreviewThumbnails {
|
||||
this.currentImageElement.dataset.index = thumbNum;
|
||||
this.removeOldImages(this.currentImageElement);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
showImage(previewImage, frame, qualityIndex, thumbNum, thumbFilename, newImage = true) {
|
||||
showImage = (previewImage, frame, qualityIndex, thumbNum, thumbFilename, newImage = true) => {
|
||||
this.player.debug.log(
|
||||
`Showing thumb: ${thumbFilename}. num: ${thumbNum}. qual: ${qualityIndex}. newimg: ${newImage}`,
|
||||
);
|
||||
@ -449,10 +458,10 @@ class PreviewThumbnails {
|
||||
this.preloadNearby(thumbNum, true)
|
||||
.then(this.preloadNearby(thumbNum, false))
|
||||
.then(this.getHigherQuality(qualityIndex, previewImage, frame, thumbFilename));
|
||||
}
|
||||
};
|
||||
|
||||
// Remove all preview images that aren't the designated current image
|
||||
removeOldImages(currentImage) {
|
||||
removeOldImages = (currentImage) => {
|
||||
// Get a list of all images, convert it from a DOM list to an array
|
||||
Array.from(this.currentImageContainer.children).forEach((image) => {
|
||||
if (image.tagName.toLowerCase() !== 'img') {
|
||||
@ -476,11 +485,11 @@ class PreviewThumbnails {
|
||||
}, removeDelay);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// Preload images before and after the current one. Only if the user is still hovering/seeking the same frame
|
||||
// This will only preload the lowest quality
|
||||
preloadNearby(thumbNum, forward = true) {
|
||||
preloadNearby = (thumbNum, forward = true) => {
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(() => {
|
||||
const oldThumbFilename = this.thumbnails[0].frames[thumbNum].text;
|
||||
@ -527,10 +536,10 @@ class PreviewThumbnails {
|
||||
}
|
||||
}, 300);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// If user has been hovering current image for half a second, look for a higher quality one
|
||||
getHigherQuality(currentQualityIndex, previewImage, frame, thumbFilename) {
|
||||
getHigherQuality = (currentQualityIndex, previewImage, frame, thumbFilename) => {
|
||||
if (currentQualityIndex < this.thumbnails.length - 1) {
|
||||
// Only use the higher quality version if it's going to look any better - if the current thumb is of a lower pixel density than the thumbnail container
|
||||
let previewImageHeight = previewImage.naturalHeight;
|
||||
@ -550,7 +559,7 @@ class PreviewThumbnails {
|
||||
}, 300);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
get currentImageContainer() {
|
||||
if (this.mouseDown) {
|
||||
@ -605,7 +614,7 @@ class PreviewThumbnails {
|
||||
}
|
||||
}
|
||||
|
||||
toggleThumbContainer(toggle = false, clearShowing = false) {
|
||||
toggleThumbContainer = (toggle = false, clearShowing = false) => {
|
||||
const className = this.player.config.classNames.previewThumbnails.thumbContainerShown;
|
||||
this.elements.thumb.container.classList.toggle(className, toggle);
|
||||
|
||||
@ -613,9 +622,9 @@ class PreviewThumbnails {
|
||||
this.showingThumb = null;
|
||||
this.showingThumbFilename = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
toggleScrubbingContainer(toggle = false) {
|
||||
toggleScrubbingContainer = (toggle = false) => {
|
||||
const className = this.player.config.classNames.previewThumbnails.scrubbingContainerShown;
|
||||
this.elements.scrubbing.container.classList.toggle(className, toggle);
|
||||
|
||||
@ -623,17 +632,17 @@ class PreviewThumbnails {
|
||||
this.showingThumb = null;
|
||||
this.showingThumbFilename = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
determineContainerAutoSizing() {
|
||||
determineContainerAutoSizing = () => {
|
||||
if (this.elements.thumb.imageContainer.clientHeight > 20 || this.elements.thumb.imageContainer.clientWidth > 20) {
|
||||
// This will prevent auto sizing in this.setThumbContainerSizeAndPos()
|
||||
this.sizeSpecifiedInCSS = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 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 = () => {
|
||||
if (!this.sizeSpecifiedInCSS) {
|
||||
const thumbWidth = Math.floor(this.thumbContainerHeight * this.thumbAspectRatio);
|
||||
this.elements.thumb.imageContainer.style.height = `${this.thumbContainerHeight}px`;
|
||||
@ -653,9 +662,9 @@ class PreviewThumbnails {
|
||||
}
|
||||
|
||||
this.setThumbContainerPos();
|
||||
}
|
||||
};
|
||||
|
||||
setThumbContainerPos() {
|
||||
setThumbContainerPos = () => {
|
||||
const seekbarRect = this.player.elements.progress.getBoundingClientRect();
|
||||
const plyrRect = this.player.elements.container.getBoundingClientRect();
|
||||
const { container } = this.elements.thumb;
|
||||
@ -674,20 +683,20 @@ class PreviewThumbnails {
|
||||
}
|
||||
|
||||
container.style.left = `${previewPos}px`;
|
||||
}
|
||||
};
|
||||
|
||||
// Can't use 100% width, in case the video is a different aspect ratio to the video container
|
||||
setScrubbingContainerSize() {
|
||||
setScrubbingContainerSize = () => {
|
||||
const { width, height } = fitRatio(this.thumbAspectRatio, {
|
||||
width: this.player.media.clientWidth,
|
||||
height: this.player.media.clientHeight,
|
||||
});
|
||||
this.elements.scrubbing.container.style.width = `${width}px`;
|
||||
this.elements.scrubbing.container.style.height = `${height}px`;
|
||||
}
|
||||
};
|
||||
|
||||
// Sprites need to be offset to the correct location
|
||||
setImageSizeAndOffset(previewImage, frame) {
|
||||
setImageSizeAndOffset = (previewImage, frame) => {
|
||||
if (!this.usingSprites) {
|
||||
return;
|
||||
}
|
||||
@ -703,7 +712,7 @@ class PreviewThumbnails {
|
||||
previewImage.style.left = `-${frame.x * multiplier}px`;
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
previewImage.style.top = `-${frame.y * multiplier}px`;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export default PreviewThumbnails;
|
||||
|
@ -11,7 +11,7 @@ import fetch from '../utils/fetch';
|
||||
import is from '../utils/is';
|
||||
import loadScript from '../utils/load-script';
|
||||
import { format, stripHTML } from '../utils/strings';
|
||||
import { setAspectRatio } from '../utils/style';
|
||||
import { roundAspectRatio, setAspectRatio } from '../utils/style';
|
||||
import { buildUrlParams } from '../utils/urls';
|
||||
|
||||
// Parse Vimeo ID from URL
|
||||
@ -28,6 +28,21 @@ function parseId(url) {
|
||||
return url.match(regex) ? RegExp.$2 : url;
|
||||
}
|
||||
|
||||
// Try to extract a hash for private videos from the URL
|
||||
function parseHash(url) {
|
||||
/* This regex matches a hexadecimal hash if given in any of these forms:
|
||||
* - [https://player.]vimeo.com/video/{id}/{hash}[?params]
|
||||
* - [https://player.]vimeo.com/video/{id}?h={hash}[¶ms]
|
||||
* - [https://player.]vimeo.com/video/{id}?[params]&h={hash}
|
||||
* - video/{id}/{hash}
|
||||
* If matched, the hash is available in 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)
|
||||
function assurePlaybackState(play) {
|
||||
if (play && !this.embed.hasPlayed) {
|
||||
@ -71,6 +86,18 @@ const vimeo = {
|
||||
const player = this;
|
||||
const config = player.config.vimeo;
|
||||
const { premium, referrerPolicy, ...frameParams } = config;
|
||||
// Get the source URL or ID
|
||||
let source = player.media.getAttribute('src');
|
||||
let hash = '';
|
||||
// Get from <div> if needed
|
||||
if (is.empty(source)) {
|
||||
source = player.media.getAttribute(player.config.attributes.embed.id);
|
||||
// hash can also be set as attribute on the <div>
|
||||
hash = player.media.getAttribute(player.config.attributes.embed.hash);
|
||||
} else {
|
||||
hash = parseHash(source);
|
||||
}
|
||||
const hashParam = hash ? { h: hash } : {};
|
||||
|
||||
// If the owner has a pro or premium account then we can hide controls etc
|
||||
if (premium) {
|
||||
@ -87,24 +114,21 @@ const vimeo = {
|
||||
muted: player.muted,
|
||||
gesture: 'media',
|
||||
playsinline: !this.config.fullscreen.iosNative,
|
||||
// hash has to be added to iframe-URL
|
||||
...hashParam,
|
||||
...frameParams,
|
||||
});
|
||||
|
||||
// Get the source URL or ID
|
||||
let source = player.media.getAttribute('src');
|
||||
|
||||
// Get from <div> if needed
|
||||
if (is.empty(source)) {
|
||||
source = player.media.getAttribute(player.config.attributes.embed.id);
|
||||
}
|
||||
|
||||
const id = parseId(source);
|
||||
// Build an iframe
|
||||
const iframe = createElement('iframe');
|
||||
const src = format(player.config.urls.vimeo.iframe, id, params);
|
||||
iframe.setAttribute('src', src);
|
||||
iframe.setAttribute('allowfullscreen', '');
|
||||
iframe.setAttribute('allow', 'autoplay,fullscreen,picture-in-picture');
|
||||
iframe.setAttribute(
|
||||
'allow',
|
||||
['autoplay', 'fullscreen', 'picture-in-picture', 'encrypted-media', 'accelerometer', 'gyroscope'].join('; '),
|
||||
);
|
||||
|
||||
// Set the referrer policy if required
|
||||
if (!is.empty(referrerPolicy)) {
|
||||
@ -291,7 +315,7 @@ const vimeo = {
|
||||
// Set aspect ratio based on video size
|
||||
Promise.all([player.embed.getVideoWidth(), player.embed.getVideoHeight()]).then((dimensions) => {
|
||||
const [width, height] = dimensions;
|
||||
player.embed.ratio = [width, height];
|
||||
player.embed.ratio = roundAspectRatio(width, height);
|
||||
setAspectRatio.call(this);
|
||||
});
|
||||
|
||||
|
@ -11,7 +11,7 @@ import loadImage from '../utils/load-image';
|
||||
import loadScript from '../utils/load-script';
|
||||
import { extend } from '../utils/objects';
|
||||
import { format, generateId } from '../utils/strings';
|
||||
import { setAspectRatio } from '../utils/style';
|
||||
import { roundAspectRatio, setAspectRatio } from '../utils/style';
|
||||
|
||||
// Parse YouTube ID from URL
|
||||
function parseId(url) {
|
||||
@ -90,7 +90,7 @@ const youtube = {
|
||||
ui.setTitle.call(this);
|
||||
|
||||
// Set aspect ratio
|
||||
this.embed.ratio = [width, height];
|
||||
this.embed.ratio = roundAspectRatio(width, height);
|
||||
}
|
||||
|
||||
setAspectRatio.call(this);
|
||||
|
70
src/js/plyr.d.ts
vendored
70
src/js/plyr.d.ts
vendored
@ -138,10 +138,15 @@ declare class Plyr {
|
||||
*/
|
||||
ratio?: string;
|
||||
|
||||
/**
|
||||
* Access Elements cache
|
||||
*/
|
||||
elements: Plyr.Elements;
|
||||
|
||||
/**
|
||||
* Returns the current video Provider
|
||||
*/
|
||||
readonly provider: 'html5' | 'vimeo' | 'youtube';
|
||||
readonly provider: Plyr.Provider;
|
||||
|
||||
/**
|
||||
* Returns the native API for Vimeo or Youtube players
|
||||
@ -206,6 +211,11 @@ declare class Plyr {
|
||||
*/
|
||||
airplay(): void;
|
||||
|
||||
/**
|
||||
* Sets the preview thubmnails for the current source.
|
||||
*/
|
||||
setPreviewThumbnails(source: Plyr.PreviewThumbnailsOptions): void;
|
||||
|
||||
/**
|
||||
* Toggle the controls (video only). Takes optional truthy value to force it on/off.
|
||||
*/
|
||||
@ -233,8 +243,10 @@ declare class Plyr {
|
||||
|
||||
/**
|
||||
* Destroy lib instance
|
||||
* @param {Function} callback - Callback for when destroy is complete
|
||||
* @param {Boolean} soft - Whether it's a soft destroy (for source changes etc)
|
||||
*/
|
||||
destroy(): void;
|
||||
destroy(callback?: (...args: any[]) => void, soft?: boolean): void;
|
||||
}
|
||||
|
||||
declare namespace Plyr {
|
||||
@ -447,7 +459,7 @@ declare namespace Plyr {
|
||||
* Allows binding of event listeners to the controls before the default handlers. See the defaults.js for available listeners.
|
||||
* If your handler prevents default on the event (event.preventDefault()), the default handler will not fire.
|
||||
*/
|
||||
listeners?: { [key: string]: (error: PlyrEvent) => void };
|
||||
listeners?: {[key: string]: (error: PlyrEvent) => void};
|
||||
|
||||
/**
|
||||
* active: Toggles if captions should be active by default. language: Sets the default language to load (if available). 'auto' uses the browser language.
|
||||
@ -506,10 +518,17 @@ declare namespace Plyr {
|
||||
* Preview Thumbnails Options.
|
||||
*/
|
||||
previewThumbnails?: PreviewThumbnailsOptions;
|
||||
|
||||
/**
|
||||
* Media Metadata Options.
|
||||
*/
|
||||
mediaMetadata?: MediaMetadataOptions;
|
||||
}
|
||||
|
||||
interface QualityOptions {
|
||||
default: number;
|
||||
forced?: boolean;
|
||||
onChange?: (quality: number) => void;
|
||||
options: number[];
|
||||
}
|
||||
|
||||
@ -519,7 +538,8 @@ declare namespace Plyr {
|
||||
|
||||
interface AdOptions {
|
||||
enabled: boolean;
|
||||
publisherId: string;
|
||||
publisherId?: string;
|
||||
tagUrl?: string;
|
||||
}
|
||||
|
||||
interface SpeedOptions {
|
||||
@ -542,6 +562,7 @@ declare namespace Plyr {
|
||||
fallback?: boolean | 'force';
|
||||
allowAudio?: boolean;
|
||||
iosNative?: boolean;
|
||||
container?: string;
|
||||
}
|
||||
|
||||
interface CaptionOptions {
|
||||
@ -560,6 +581,40 @@ declare namespace Plyr {
|
||||
src?: string | string[];
|
||||
}
|
||||
|
||||
interface MediaMetadataArtwork {
|
||||
src: string;
|
||||
sizes?: string;
|
||||
type: string;
|
||||
}
|
||||
|
||||
interface MediaMetadataOptions {
|
||||
title?: string;
|
||||
artist?: string;
|
||||
album?: string;
|
||||
artwork?: MediaMetadataArtwork[];
|
||||
}
|
||||
|
||||
export interface Elements {
|
||||
buttons: {
|
||||
airplay?: HTMLButtonElement;
|
||||
captions?: HTMLButtonElement;
|
||||
download?: HTMLButtonElement;
|
||||
fastForward?: HTMLButtonElement;
|
||||
fullscreen?: HTMLButtonElement;
|
||||
mute?: HTMLButtonElement;
|
||||
pip?: HTMLButtonElement;
|
||||
play?: HTMLButtonElement | HTMLButtonElement[];
|
||||
restart?: HTMLButtonElement;
|
||||
rewind?: HTMLButtonElement;
|
||||
settings?: HTMLButtonElement;
|
||||
};
|
||||
captions: HTMLElement | null;
|
||||
container: HTMLElement | null;
|
||||
controls: HTMLElement | null;
|
||||
fullscreen: HTMLElement | null;
|
||||
wrapper: HTMLElement | null;
|
||||
}
|
||||
|
||||
interface SourceInfo {
|
||||
/**
|
||||
* Note: YouTube and Vimeo are currently not supported as audio sources.
|
||||
@ -587,6 +642,11 @@ declare namespace Plyr {
|
||||
* Booleans are converted to HTML5 value-less attributes.
|
||||
*/
|
||||
tracks?: Track[];
|
||||
|
||||
/**
|
||||
* Enable or disable preview thumbnails for current source
|
||||
*/
|
||||
previewThumbnails?: Plyr.PreviewThumbnailsOptions;
|
||||
}
|
||||
|
||||
interface Source {
|
||||
@ -625,7 +685,7 @@ declare namespace Plyr {
|
||||
}
|
||||
|
||||
interface PlyrEvent extends CustomEvent {
|
||||
readonly detail: { readonly plyr: Plyr };
|
||||
readonly detail: {readonly plyr: Plyr};
|
||||
}
|
||||
|
||||
enum YoutubeState {
|
||||
|
@ -1,6 +1,6 @@
|
||||
// ==========================================================================
|
||||
// Plyr
|
||||
// plyr.js v3.6.3
|
||||
// plyr.js v3.7.0
|
||||
// https://github.com/sampotts/plyr
|
||||
// License: The MIT License (MIT)
|
||||
// ==========================================================================
|
||||
@ -29,7 +29,7 @@ import loadSprite from './utils/load-sprite';
|
||||
import { clamp } from './utils/numbers';
|
||||
import { cloneDeep, extend } from './utils/objects';
|
||||
import { silencePromise } from './utils/promise';
|
||||
import { getAspectRatio, reduceAspectRatio, setAspectRatio, validateRatio } from './utils/style';
|
||||
import { getAspectRatio, reduceAspectRatio, setAspectRatio, validateAspectRatio } from './utils/style';
|
||||
import { parseUrl } from './utils/urls';
|
||||
|
||||
// Private properties
|
||||
@ -72,7 +72,7 @@ class Plyr {
|
||||
(() => {
|
||||
try {
|
||||
return JSON.parse(this.media.getAttribute('data-plyr-config'));
|
||||
} catch (e) {
|
||||
} catch (_) {
|
||||
return {};
|
||||
}
|
||||
})(),
|
||||
@ -206,7 +206,7 @@ class Plyr {
|
||||
}
|
||||
|
||||
// Unsupported or missing provider
|
||||
if (is.empty(this.provider) || !Object.keys(providers).includes(this.provider)) {
|
||||
if (is.empty(this.provider) || !Object.values(providers).includes(this.provider)) {
|
||||
this.debug.error('Setup failed: Invalid provider');
|
||||
return;
|
||||
}
|
||||
@ -355,7 +355,7 @@ class Plyr {
|
||||
/**
|
||||
* Play the media, or play the advertisement (if they are not blocked)
|
||||
*/
|
||||
play() {
|
||||
play = () => {
|
||||
if (!is.function(this.media.play)) {
|
||||
return null;
|
||||
}
|
||||
@ -367,18 +367,18 @@ class Plyr {
|
||||
|
||||
// Return the promise (for HTML5)
|
||||
return this.media.play();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Pause the media
|
||||
*/
|
||||
pause() {
|
||||
pause = () => {
|
||||
if (!this.playing || !is.function(this.media.pause)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return this.media.pause();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Get playing state
|
||||
@ -412,7 +412,7 @@ class Plyr {
|
||||
* Toggle playback based on current status
|
||||
* @param {Boolean} input
|
||||
*/
|
||||
togglePlay(input) {
|
||||
togglePlay = (input) => {
|
||||
// Toggle based on current state if nothing passed
|
||||
const toggle = is.boolean(input) ? input : !this.playing;
|
||||
|
||||
@ -421,42 +421,42 @@ class Plyr {
|
||||
}
|
||||
|
||||
return this.pause();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Stop playback
|
||||
*/
|
||||
stop() {
|
||||
stop = () => {
|
||||
if (this.isHTML5) {
|
||||
this.pause();
|
||||
this.restart();
|
||||
} else if (is.function(this.media.stop)) {
|
||||
this.media.stop();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Restart playback
|
||||
*/
|
||||
restart() {
|
||||
restart = () => {
|
||||
this.currentTime = 0;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Rewind
|
||||
* @param {Number} seekTime - how far to rewind in seconds. Defaults to the config.seekTime
|
||||
*/
|
||||
rewind(seekTime) {
|
||||
rewind = (seekTime) => {
|
||||
this.currentTime -= is.number(seekTime) ? seekTime : this.config.seekTime;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Fast forward
|
||||
* @param {Number} seekTime - how far to fast forward in seconds. Defaults to the config.seekTime
|
||||
*/
|
||||
forward(seekTime) {
|
||||
forward = (seekTime) => {
|
||||
this.currentTime += is.number(seekTime) ? seekTime : this.config.seekTime;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Seek to a time
|
||||
@ -582,18 +582,18 @@ class Plyr {
|
||||
* Increase volume
|
||||
* @param {Boolean} step - How much to decrease by (between 0 and 1)
|
||||
*/
|
||||
increaseVolume(step) {
|
||||
increaseVolume = (step) => {
|
||||
const volume = this.media.muted ? 0 : this.volume;
|
||||
this.volume = volume + (is.number(step) ? step : 0);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Decrease volume
|
||||
* @param {Boolean} step - How much to decrease by (between 0 and 1)
|
||||
*/
|
||||
decreaseVolume(step) {
|
||||
decreaseVolume = (step) => {
|
||||
this.increaseVolume(-step);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Set muted state
|
||||
@ -675,7 +675,9 @@ class Plyr {
|
||||
|
||||
// Set media speed
|
||||
setTimeout(() => {
|
||||
this.media.playbackRate = speed;
|
||||
if (this.media) {
|
||||
this.media.playbackRate = speed;
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
|
||||
@ -916,12 +918,12 @@ class Plyr {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!is.string(input) || !validateRatio(input)) {
|
||||
if (!is.string(input) || !validateAspectRatio(input)) {
|
||||
this.debug.error(`Invalid aspect ratio specified (${input})`);
|
||||
return;
|
||||
}
|
||||
|
||||
this.config.ratio = input;
|
||||
this.config.ratio = reduceAspectRatio(input);
|
||||
|
||||
setAspectRatio.call(this);
|
||||
}
|
||||
@ -956,6 +958,7 @@ class Plyr {
|
||||
*/
|
||||
set currentTrack(input) {
|
||||
captions.set.call(this, input, false);
|
||||
captions.setup.call(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1029,22 +1032,39 @@ class Plyr {
|
||||
return this.media === document.pictureInPictureElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the preview thubmnails for the current source
|
||||
*/
|
||||
setPreviewThumbnails(thumbnailSource) {
|
||||
if (this.previewThumbnails && this.previewThumbnails.loaded) {
|
||||
this.previewThumbnails.destroy();
|
||||
this.previewThumbnails = null;
|
||||
}
|
||||
|
||||
Object.assign(this.config.previewThumbnails, thumbnailSource);
|
||||
|
||||
// Create new instance if it is still enabled
|
||||
if (this.config.previewThumbnails.enabled) {
|
||||
this.previewThumbnails = new PreviewThumbnails(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger the airplay dialog
|
||||
* TODO: update player with state, support, enabled
|
||||
*/
|
||||
airplay() {
|
||||
airplay = () => {
|
||||
// Show dialog if supported
|
||||
if (support.airplay) {
|
||||
this.media.webkitShowPlaybackTargetPicker();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Toggle the player controls
|
||||
* @param {Boolean} [toggle] - Whether to show the controls
|
||||
*/
|
||||
toggleControls(toggle) {
|
||||
toggleControls = (toggle) => {
|
||||
// Don't toggle if missing UI support or if it's audio
|
||||
if (this.supported.ui && !this.isAudio) {
|
||||
// Get state before change
|
||||
@ -1074,34 +1094,34 @@ class Plyr {
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Add event listeners
|
||||
* @param {String} event - Event type
|
||||
* @param {Function} callback - Callback for when event occurs
|
||||
*/
|
||||
on(event, callback) {
|
||||
on = (event, callback) => {
|
||||
on.call(this, this.elements.container, event, callback);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Add event listeners once
|
||||
* @param {String} event - Event type
|
||||
* @param {Function} callback - Callback for when event occurs
|
||||
*/
|
||||
once(event, callback) {
|
||||
once = (event, callback) => {
|
||||
once.call(this, this.elements.container, event, callback);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Remove event listeners
|
||||
* @param {String} event - Event type
|
||||
* @param {Function} callback - Callback for when event occurs
|
||||
*/
|
||||
off(event, callback) {
|
||||
off = (event, callback) => {
|
||||
off(this.elements.container, event, callback);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Destroy an instance
|
||||
@ -1110,7 +1130,7 @@ class Plyr {
|
||||
* @param {Function} callback - Callback for when destroy is complete
|
||||
* @param {Boolean} soft - Whether it's a soft destroy (for source changes etc)
|
||||
*/
|
||||
destroy(callback, soft = false) {
|
||||
destroy = (callback, soft = false) => {
|
||||
if (!this.ready) {
|
||||
return;
|
||||
}
|
||||
@ -1208,15 +1228,13 @@ class Plyr {
|
||||
// Vimeo does not always return
|
||||
setTimeout(done, 200);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Check for support for a mime type (HTML5 only)
|
||||
* @param {String} type - Mime type
|
||||
*/
|
||||
supports(type) {
|
||||
return support.mime.call(this, type);
|
||||
}
|
||||
supports = (type) => support.mime.call(this, type);
|
||||
|
||||
/**
|
||||
* Check for support
|
||||
|
@ -1,6 +1,6 @@
|
||||
// ==========================================================================
|
||||
// Plyr Polyfilled Build
|
||||
// plyr.js v3.6.3
|
||||
// plyr.js v3.7.0
|
||||
// https://github.com/sampotts/plyr
|
||||
// License: The MIT License (MIT)
|
||||
// ==========================================================================
|
||||
|
@ -26,12 +26,12 @@ class Storage {
|
||||
window.localStorage.removeItem(test);
|
||||
|
||||
return true;
|
||||
} catch (e) {
|
||||
} catch (_) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
get(key) {
|
||||
get = (key) => {
|
||||
if (!Storage.supported || !this.enabled) {
|
||||
return null;
|
||||
}
|
||||
@ -45,9 +45,9 @@ class Storage {
|
||||
const json = JSON.parse(store);
|
||||
|
||||
return is.string(key) && key.length ? json[key] : json;
|
||||
}
|
||||
};
|
||||
|
||||
set(object) {
|
||||
set = (object) => {
|
||||
// Bail if we don't have localStorage support or it's disabled
|
||||
if (!Storage.supported || !this.enabled) {
|
||||
return;
|
||||
@ -70,8 +70,12 @@ class Storage {
|
||||
extend(storage, object);
|
||||
|
||||
// Update storage
|
||||
window.localStorage.setItem(this.key, JSON.stringify(storage));
|
||||
}
|
||||
try {
|
||||
window.localStorage.setItem(this.key, JSON.stringify(storage));
|
||||
} catch (_) {
|
||||
// Do nothing
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export default Storage;
|
||||
|
@ -88,7 +88,7 @@ const support = {
|
||||
|
||||
try {
|
||||
return Boolean(type && this.media.canPlayType(type).replace(/no/, ''));
|
||||
} catch (e) {
|
||||
} catch (_) {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
12
src/js/ui.js
12
src/js/ui.js
@ -82,6 +82,9 @@ const ui = {
|
||||
// Reset time display
|
||||
controls.timeUpdate.call(this);
|
||||
|
||||
// Reset duration display
|
||||
controls.durationUpdate.call(this);
|
||||
|
||||
// Update the UI
|
||||
ui.checkPlaying.call(this);
|
||||
|
||||
@ -122,6 +125,11 @@ const ui = {
|
||||
if (this.config.duration) {
|
||||
controls.durationUpdate.call(this);
|
||||
}
|
||||
|
||||
// Media metadata
|
||||
if (this.config.mediaMetadata) {
|
||||
controls.setMediaMetadata.call(this);
|
||||
}
|
||||
},
|
||||
|
||||
// Setup aria attribute for play and iframe title
|
||||
@ -181,13 +189,13 @@ const ui = {
|
||||
.call(this)
|
||||
// Load image
|
||||
.then(() => loadImage(poster))
|
||||
.catch((err) => {
|
||||
.catch((error) => {
|
||||
// Hide poster on error unless it's been set by another call
|
||||
if (poster === this.poster) {
|
||||
ui.togglePoster.call(this, false);
|
||||
}
|
||||
// Rethrow
|
||||
throw err;
|
||||
throw error;
|
||||
})
|
||||
.then(() => {
|
||||
// Prevent race conditions
|
||||
|
@ -31,7 +31,7 @@ export function repaint(element, delay) {
|
||||
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
element.hidden = false;
|
||||
} catch (e) {
|
||||
} catch (_) {
|
||||
// Do nothing
|
||||
}
|
||||
}, delay);
|
||||
|
@ -4,11 +4,13 @@
|
||||
// ==========================================================================
|
||||
|
||||
const browser = {
|
||||
isIE: /* @cc_on!@ */ false || !!document.documentMode,
|
||||
isIE: Boolean(window.document.documentMode),
|
||||
isEdge: window.navigator.userAgent.includes('Edge'),
|
||||
isWebkit: 'WebkitAppearance' in document.documentElement.style && !/Edge/.test(navigator.userAgent),
|
||||
isIPhone: /(iPhone|iPod)/gi.test(navigator.platform),
|
||||
isIos: /(iPad|iPhone|iPod)/gi.test(navigator.platform),
|
||||
isIos:
|
||||
(navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1) ||
|
||||
/(iPad|iPhone|iPod)/gi.test(navigator.platform),
|
||||
};
|
||||
|
||||
export default browser;
|
||||
|
@ -19,7 +19,7 @@ const supportsPassiveListeners = (() => {
|
||||
});
|
||||
window.addEventListener('test', null, options);
|
||||
window.removeEventListener('test', null, options);
|
||||
} catch (e) {
|
||||
} catch (_) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ export default function fetch(url, responseType = 'text') {
|
||||
if (responseType === 'text') {
|
||||
try {
|
||||
resolve(JSON.parse(request.responseText));
|
||||
} catch (e) {
|
||||
} catch (_) {
|
||||
resolve(request.responseText);
|
||||
}
|
||||
} else {
|
||||
@ -35,8 +35,8 @@ export default function fetch(url, responseType = 'text') {
|
||||
request.responseType = responseType;
|
||||
|
||||
request.send();
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ const isFunction = (input) => getConstructor(input) === Function;
|
||||
const isArray = (input) => Array.isArray(input);
|
||||
const isWeakMap = (input) => instanceOf(input, WeakMap);
|
||||
const isNodeList = (input) => instanceOf(input, NodeList);
|
||||
const isElement = (input) => instanceOf(input, Element);
|
||||
const isTextNode = (input) => getConstructor(input) === Text;
|
||||
const isEvent = (input) => instanceOf(input, Event);
|
||||
const isKeyboardEvent = (input) => instanceOf(input, KeyboardEvent);
|
||||
@ -21,6 +20,13 @@ const isCue = (input) => instanceOf(input, window.TextTrackCue) || instanceOf(in
|
||||
const isTrack = (input) => instanceOf(input, TextTrack) || (!isNullOrUndefined(input) && isString(input.kind));
|
||||
const isPromise = (input) => instanceOf(input, Promise) && isFunction(input.then);
|
||||
|
||||
const isElement = (input) =>
|
||||
input !== null &&
|
||||
typeof input === 'object' &&
|
||||
input.nodeType === 1 &&
|
||||
typeof input.style === 'object' &&
|
||||
typeof input.ownerDocument === 'object';
|
||||
|
||||
const isEmpty = (input) =>
|
||||
isNullOrUndefined(input) ||
|
||||
((isString(input) || isArray(input) || isNodeList(input)) && !input.length) ||
|
||||
@ -45,7 +51,7 @@ const isUrl = (input) => {
|
||||
|
||||
try {
|
||||
return !isEmpty(new URL(string).hostname);
|
||||
} catch (e) {
|
||||
} catch (_) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
@ -60,12 +60,16 @@ export default function loadSprite(url, id) {
|
||||
}
|
||||
|
||||
if (useStorage) {
|
||||
window.localStorage.setItem(
|
||||
`${prefix}-${id}`,
|
||||
JSON.stringify({
|
||||
content: result,
|
||||
}),
|
||||
);
|
||||
try {
|
||||
window.localStorage.setItem(
|
||||
`${prefix}-${id}`,
|
||||
JSON.stringify({
|
||||
content: result,
|
||||
}),
|
||||
);
|
||||
} catch (_) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
|
||||
update(container, result);
|
||||
|
@ -33,7 +33,7 @@ export const replaceAll = (input = '', find = '', replace = '') =>
|
||||
|
||||
// Convert to title case
|
||||
export const toTitleCase = (input = '') =>
|
||||
input.toString().replace(/\w\S*/g, (text) => text.charAt(0).toUpperCase() + text.substr(1).toLowerCase());
|
||||
input.toString().replace(/\w\S*/g, (text) => text.charAt(0).toUpperCase() + text.slice(1).toLowerCase());
|
||||
|
||||
// Convert string to pascalCase
|
||||
export function toPascalCase(input = '') {
|
||||
|
@ -2,9 +2,39 @@
|
||||
// Style utils
|
||||
// ==========================================================================
|
||||
|
||||
import { closest } from './arrays';
|
||||
import is from './is';
|
||||
|
||||
export function validateRatio(input) {
|
||||
// Check support for a CSS declaration
|
||||
export function supportsCSS(declaration) {
|
||||
if (!window || !window.CSS) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return window.CSS.supports(declaration);
|
||||
}
|
||||
|
||||
// Standard/common aspect ratios
|
||||
const standardRatios = [
|
||||
[1, 1],
|
||||
[4, 3],
|
||||
[3, 4],
|
||||
[5, 4],
|
||||
[4, 5],
|
||||
[3, 2],
|
||||
[2, 3],
|
||||
[16, 10],
|
||||
[10, 16],
|
||||
[16, 9],
|
||||
[9, 16],
|
||||
[21, 9],
|
||||
[9, 21],
|
||||
[32, 9],
|
||||
[9, 32],
|
||||
].reduce((out, [x, y]) => ({ ...out, [x / y]: [x, y] }), {});
|
||||
|
||||
// Validate an aspect ratio
|
||||
export function validateAspectRatio(input) {
|
||||
if (!is.array(input) && (!is.string(input) || !input.includes(':'))) {
|
||||
return false;
|
||||
}
|
||||
@ -14,6 +44,7 @@ export function validateRatio(input) {
|
||||
return ratio.map(Number).every(is.number);
|
||||
}
|
||||
|
||||
// Reduce an aspect ratio to it's lowest form
|
||||
export function reduceAspectRatio(ratio) {
|
||||
if (!is.array(ratio) || !ratio.every(is.number)) {
|
||||
return null;
|
||||
@ -26,8 +57,9 @@ export function reduceAspectRatio(ratio) {
|
||||
return [width / divider, height / divider];
|
||||
}
|
||||
|
||||
// Calculate an aspect ratio
|
||||
export function getAspectRatio(input) {
|
||||
const parse = (ratio) => (validateRatio(ratio) ? ratio.split(':').map(Number) : null);
|
||||
const parse = (ratio) => (validateAspectRatio(ratio) ? ratio.split(':').map(Number) : null);
|
||||
// Try provided ratio
|
||||
let ratio = parse(input);
|
||||
|
||||
@ -44,10 +76,10 @@ export function getAspectRatio(input) {
|
||||
// Get from HTML5 video
|
||||
if (ratio === null && this.isHTML5) {
|
||||
const { videoWidth, videoHeight } = this.media;
|
||||
ratio = reduceAspectRatio([videoWidth, videoHeight]);
|
||||
ratio = [videoWidth, videoHeight];
|
||||
}
|
||||
|
||||
return ratio;
|
||||
return reduceAspectRatio(ratio);
|
||||
}
|
||||
|
||||
// Set aspect ratio for responsive container
|
||||
@ -58,10 +90,20 @@ export function setAspectRatio(input) {
|
||||
|
||||
const { wrapper } = this.elements;
|
||||
const ratio = getAspectRatio.call(this, input);
|
||||
const [w, h] = is.array(ratio) ? ratio : [0, 0];
|
||||
const padding = (100 / w) * h;
|
||||
|
||||
wrapper.style.paddingBottom = `${padding}%`;
|
||||
if (!is.array(ratio)) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const [x, y] = reduceAspectRatio(ratio);
|
||||
const useNative = supportsCSS(`aspect-ratio: ${x}/${y}`);
|
||||
const padding = (100 / x) * y;
|
||||
|
||||
if (useNative) {
|
||||
wrapper.style.aspectRatio = `${x}/${y}`;
|
||||
} else {
|
||||
wrapper.style.paddingBottom = `${padding}%`;
|
||||
}
|
||||
|
||||
// For Vimeo we have an extra <div> to hide the standard controls and UI
|
||||
if (this.isVimeo && !this.config.vimeo.premium && this.supported.ui) {
|
||||
@ -74,10 +116,30 @@ export function setAspectRatio(input) {
|
||||
this.media.style.transform = `translateY(-${offset}%)`;
|
||||
}
|
||||
} else if (this.isHTML5) {
|
||||
wrapper.classList.toggle(this.config.classNames.videoFixedRatio, ratio !== null);
|
||||
wrapper.classList.add(this.config.classNames.videoFixedRatio);
|
||||
}
|
||||
|
||||
return { padding, ratio };
|
||||
}
|
||||
|
||||
export default { setAspectRatio };
|
||||
// Round an aspect ratio to closest standard ratio
|
||||
export function roundAspectRatio(x, y, tolerance = 0.05) {
|
||||
const ratio = x / y;
|
||||
const closestRatio = closest(Object.keys(standardRatios), ratio);
|
||||
|
||||
// Check match is within tolerance
|
||||
if (Math.abs(closestRatio - ratio) <= tolerance) {
|
||||
return standardRatios[closestRatio];
|
||||
}
|
||||
|
||||
// No match
|
||||
return [x, y];
|
||||
}
|
||||
|
||||
// Get the size of the viewport
|
||||
// https://stackoverflow.com/questions/1248081/how-to-get-the-browser-viewport-dimensions
|
||||
export function getViewportSize() {
|
||||
const width = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0);
|
||||
const height = Math.max(document.documentElement.clientHeight || 0, window.innerHeight || 0);
|
||||
return [width, height];
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ export function parseUrl(input, safe = true) {
|
||||
|
||||
try {
|
||||
return new URL(url);
|
||||
} catch (e) {
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
// Base
|
||||
.plyr {
|
||||
@include plyr-font-smoothing($plyr-font-smoothing);
|
||||
|
||||
align-items: center;
|
||||
direction: ltr;
|
||||
display: flex;
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
// Tab focus
|
||||
&.plyr__tab-focus {
|
||||
@include plyr-tab-focus();
|
||||
@include plyr-tab-focus;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,6 +56,7 @@
|
||||
.plyr [data-plyr='fullscreen'] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.plyr--captions-enabled [data-plyr='captions'],
|
||||
.plyr--pip-supported [data-plyr='pip'],
|
||||
.plyr--airplay-supported [data-plyr='airplay'],
|
||||
|
@ -10,6 +10,7 @@
|
||||
.plyr__control svg {
|
||||
transition: transform 0.3s ease;
|
||||
}
|
||||
|
||||
.plyr__control[aria-expanded='true'] {
|
||||
svg {
|
||||
transform: rotate(90deg);
|
||||
@ -73,10 +74,7 @@
|
||||
color: $plyr-menu-color;
|
||||
display: flex;
|
||||
font-size: $plyr-font-size-menu;
|
||||
padding-bottom: calc(#{$plyr-control-padding} / 1.5);
|
||||
padding-left: calc(#{$plyr-control-padding} * 1.5);
|
||||
padding-right: calc(#{$plyr-control-padding} * 1.5);
|
||||
padding-top: calc(#{$plyr-control-padding} / 1.5);
|
||||
padding: calc(#{$plyr-control-padding} / 1.5) calc(#{$plyr-control-padding} * 1.5);
|
||||
user-select: none;
|
||||
width: 100%;
|
||||
|
||||
@ -176,6 +174,7 @@
|
||||
&::before {
|
||||
background: $plyr-control-toggle-checked-background;
|
||||
}
|
||||
|
||||
&::after {
|
||||
opacity: 1;
|
||||
transform: translateY(-50%) scale(1);
|
||||
|
@ -3,7 +3,7 @@
|
||||
// --------------------------------------------------------------
|
||||
|
||||
.plyr__poster {
|
||||
background-color: #000;
|
||||
background-color: var(--plyr-video-background, $plyr-video-background);
|
||||
background-position: 50% 50%;
|
||||
background-repeat: no-repeat;
|
||||
background-size: contain;
|
||||
@ -20,3 +20,8 @@
|
||||
.plyr--stopped.plyr__poster-enabled .plyr__poster {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
// Allow interaction with YouTube controls while paused
|
||||
.plyr--youtube.plyr--paused.plyr__poster-enabled:not(.plyr--stopped) .plyr__poster {
|
||||
display: none;
|
||||
}
|
||||
|
@ -24,8 +24,10 @@ $plyr-progress-offset: $plyr-range-thumb-height;
|
||||
|
||||
// Seek tooltip to show time
|
||||
.plyr__tooltip {
|
||||
font-size: $plyr-font-size-time;
|
||||
left: 0;
|
||||
max-width: 120px;
|
||||
overflow-wrap: break-word;
|
||||
white-space: normal;
|
||||
}
|
||||
}
|
||||
|
||||
@ -92,3 +94,15 @@ $plyr-progress-offset: $plyr-range-thumb-height;
|
||||
.plyr--audio.plyr--loading .plyr__progress__buffer {
|
||||
background-color: $plyr-audio-progress-buffered-background;
|
||||
}
|
||||
|
||||
// Markers
|
||||
.plyr__progress__marker {
|
||||
background-color: $plyr-progress-marker-background;
|
||||
border-radius: 1px;
|
||||
height: $plyr-range-track-height;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
width: $plyr-progress-marker-width;
|
||||
z-index: 3;
|
||||
}
|
||||
|
@ -3,10 +3,11 @@
|
||||
// --------------------------------------------------------------
|
||||
|
||||
.plyr--full-ui input[type='range'] {
|
||||
-webkit-appearance: none; /* stylelint-disable-line */
|
||||
appearance: none;
|
||||
background: transparent;
|
||||
border: 0;
|
||||
border-radius: calc(#{$plyr-range-thumb-height} * 2);
|
||||
|
||||
// `color` property is used in JS to populate lower fill for WebKit
|
||||
color: $plyr-range-fill-background;
|
||||
display: block;
|
||||
@ -18,23 +19,25 @@
|
||||
width: 100%;
|
||||
|
||||
&::-webkit-slider-runnable-track {
|
||||
@include plyr-range-track();
|
||||
@include plyr-range-track;
|
||||
|
||||
background-image: linear-gradient(to right, currentColor var(--value, 0%), transparent var(--value, 0%));
|
||||
}
|
||||
|
||||
&::-webkit-slider-thumb {
|
||||
@include plyr-range-thumb();
|
||||
-webkit-appearance: none; /* stylelint-disable-line */
|
||||
@include plyr-range-thumb;
|
||||
|
||||
appearance: none;
|
||||
margin-top: calc(((#{$plyr-range-thumb-height} - #{$plyr-range-track-height}) / 2) * -1);
|
||||
}
|
||||
|
||||
// Mozilla
|
||||
&::-moz-range-track {
|
||||
@include plyr-range-track();
|
||||
@include plyr-range-track;
|
||||
}
|
||||
|
||||
&::-moz-range-thumb {
|
||||
@include plyr-range-thumb();
|
||||
@include plyr-range-thumb;
|
||||
}
|
||||
|
||||
&::-moz-range-progress {
|
||||
@ -45,22 +48,24 @@
|
||||
|
||||
// Microsoft
|
||||
&::-ms-track {
|
||||
@include plyr-range-track();
|
||||
@include plyr-range-track;
|
||||
|
||||
color: transparent;
|
||||
}
|
||||
|
||||
&::-ms-fill-upper {
|
||||
@include plyr-range-track();
|
||||
@include plyr-range-track;
|
||||
}
|
||||
|
||||
&::-ms-fill-lower {
|
||||
@include plyr-range-track();
|
||||
@include plyr-range-track;
|
||||
|
||||
background: currentColor;
|
||||
}
|
||||
|
||||
&::-ms-thumb {
|
||||
@include plyr-range-thumb();
|
||||
@include plyr-range-thumb;
|
||||
|
||||
// For some reason, Edge uses the -webkit margin above
|
||||
margin-top: 0;
|
||||
}
|
||||
@ -70,25 +75,25 @@
|
||||
}
|
||||
|
||||
// Focus styles
|
||||
&:focus {
|
||||
outline: 0;
|
||||
}
|
||||
|
||||
&::-moz-focus-outer {
|
||||
border: 0;
|
||||
}
|
||||
|
||||
&:focus {
|
||||
outline: 0;
|
||||
}
|
||||
|
||||
&.plyr__tab-focus {
|
||||
&::-webkit-slider-runnable-track {
|
||||
@include plyr-tab-focus();
|
||||
@include plyr-tab-focus;
|
||||
}
|
||||
|
||||
&::-moz-range-track {
|
||||
@include plyr-tab-focus();
|
||||
@include plyr-tab-focus;
|
||||
}
|
||||
|
||||
&::-ms-track {
|
||||
@include plyr-tab-focus();
|
||||
@include plyr-tab-focus;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
margin-right: $plyr-control-spacing;
|
||||
}
|
||||
|
||||
@media (max-width: calc(#{$plyr-bp-md} - 1px)) {
|
||||
@media (max-width: ($plyr-bp-md - 1px)) {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
/* stylelint-disable selector-max-compound-selectors */
|
||||
// --------------------------------------------------------------
|
||||
// Tooltips
|
||||
// --------------------------------------------------------------
|
||||
|
@ -1,5 +1,8 @@
|
||||
// Downloaded from https://github.com/malyw/css-vars (and modified)
|
||||
|
||||
@use 'sass:list';
|
||||
@use 'sass:map';
|
||||
|
||||
// global map to be filled via variables
|
||||
$css-vars: ();
|
||||
|
||||
@ -21,36 +24,35 @@ $css-vars-use-native: false !default;
|
||||
|
||||
///
|
||||
// Emulates var() CSS native function behavior
|
||||
//
|
||||
// $args[0] {String} "--" + variable name
|
||||
// [$args[1]] Optional default value if variable is not assigned yet
|
||||
//
|
||||
// E.G.:
|
||||
// color: var(--main-color);
|
||||
// background: var(--main-background, green);
|
||||
///
|
||||
@function var($args...) {
|
||||
// CHECK PARAMS
|
||||
@if (length($args) ==0) {
|
||||
@if length($args) == 0 {
|
||||
@error 'Variable name is expected to be passed to the var() function';
|
||||
}
|
||||
@if (str-length(nth($args, 1)) < 2 or str-slice(nth($args, 1), 0, 2) != '--') {
|
||||
|
||||
@if str-length(nth($args, 1)) < 2 or str-slice(nth($args, 1), 0, 2) != '--' {
|
||||
@error "Variable name is expected to start from '--'";
|
||||
}
|
||||
|
||||
// PROCESS
|
||||
$var-name: nth($args, 1);
|
||||
$var-value: map-get($css-vars, $var-name);
|
||||
$var-name: list.nth($args, 1);
|
||||
$var-value: map.get($css-vars, $var-name);
|
||||
|
||||
@if ($css-vars-use-native) {
|
||||
@if $css-vars-use-native {
|
||||
// CSS variables
|
||||
// Native CSS: don't process function in case of native
|
||||
@return unquote('var(' + $args + ')');
|
||||
} @else {
|
||||
@if ($var-value == null) {
|
||||
@if not $var-value {
|
||||
// variable is not provided so far
|
||||
@if (length($args) == 2) {
|
||||
$var-value: nth($args, 2);
|
||||
@if length($args) == 2 {
|
||||
$var-value: list.nth($args, 2);
|
||||
}
|
||||
}
|
||||
|
||||
@ -60,7 +62,7 @@ $css-vars-use-native: false !default;
|
||||
}
|
||||
|
||||
///
|
||||
// SASS mixin to provide variables
|
||||
// Sass mixin to provide variables
|
||||
// E.G.:
|
||||
// @include css-vars((
|
||||
// --color: rebeccapurple,
|
||||
@ -70,20 +72,21 @@ $css-vars-use-native: false !default;
|
||||
///
|
||||
@mixin css-vars($var-map: null) {
|
||||
// CHECK PARAMS
|
||||
@if ($var-map == null) {
|
||||
@if not $var-map {
|
||||
@error 'Map of variables is expected, instead got: null';
|
||||
}
|
||||
@if (type_of($var-map) != map) {
|
||||
|
||||
@if type_of($var-map) != map {
|
||||
@error 'Map of variables is expected, instead got another type passed: #{type_of($var, ap)}';
|
||||
}
|
||||
|
||||
// PROCESS
|
||||
@if ($css-vars-use-native) {
|
||||
@if $css-vars-use-native {
|
||||
// CSS variables
|
||||
// Native CSS: assign CSS custom properties to the global scope
|
||||
@at-root :root {
|
||||
@each $var-name, $var-value in $var-map {
|
||||
@if (type_of($var-value) == string) {
|
||||
@if type_of($var-value) == string {
|
||||
#{$var-name}: $var-value; // to prevent quotes interpolation
|
||||
} @else {
|
||||
#{$var-name}: #{$var-value};
|
||||
|
@ -1,7 +1,3 @@
|
||||
// ==========================================================================
|
||||
// Useful functions
|
||||
// ==========================================================================
|
||||
|
||||
@function to-percentage($input) {
|
||||
@return $input * 1%;
|
||||
}
|
||||
|
@ -5,10 +5,8 @@
|
||||
// Nicer focus styles
|
||||
// ---------------------------------------
|
||||
@mixin plyr-tab-focus($color: $plyr-tab-focus-color) {
|
||||
outline-color: $color;
|
||||
outline: $color dotted 3px;
|
||||
outline-offset: 2px;
|
||||
outline-style: dotted;
|
||||
outline-width: 3px;
|
||||
}
|
||||
|
||||
// Font smoothing
|
||||
@ -59,17 +57,6 @@
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.plyr__video-wrapper {
|
||||
height: 100%;
|
||||
position: static;
|
||||
}
|
||||
|
||||
// Vimeo requires some different styling
|
||||
&.plyr--vimeo .plyr__video-wrapper {
|
||||
height: 0;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
// Display correct icon
|
||||
.plyr__control .icon--exit-fullscreen {
|
||||
display: block;
|
||||
|
@ -36,7 +36,7 @@
|
||||
z-index: 3;
|
||||
}
|
||||
|
||||
&::after:empty {
|
||||
&:empty::after {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
@ -47,10 +47,10 @@
|
||||
display: block;
|
||||
height: $plyr-range-track-height;
|
||||
left: 0;
|
||||
margin: -($plyr-range-track-height / 2) 0 0;
|
||||
opacity: 0.8;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
width: 3px;
|
||||
z-index: 3; // Between progress and thumb
|
||||
}
|
||||
|
@ -6,12 +6,12 @@
|
||||
|
||||
.plyr__preview-thumb {
|
||||
background-color: $plyr-preview-background;
|
||||
border-radius: 3px;
|
||||
border-radius: $plyr-preview-radius;
|
||||
bottom: 100%;
|
||||
box-shadow: $plyr-preview-shadow;
|
||||
margin-bottom: calc(#{$plyr-preview-padding} * 2);
|
||||
opacity: 0;
|
||||
padding: $plyr-preview-radius;
|
||||
padding: 3px;
|
||||
pointer-events: none;
|
||||
position: absolute;
|
||||
transform: translate(0, 10px) scale(0.8);
|
||||
@ -59,19 +59,20 @@
|
||||
|
||||
// Seek time text
|
||||
&__time-container {
|
||||
bottom: $plyr-preview-time-bottom-offset;
|
||||
background: $plyr-preview-time-container-background;
|
||||
border-bottom-left-radius: calc(#{$plyr-preview-radius} - 1px);
|
||||
border-bottom-right-radius: calc(#{$plyr-preview-radius} - 1px);
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
line-height: 1.1;
|
||||
padding: $plyr-preview-time-container-padding;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
white-space: nowrap;
|
||||
z-index: 3;
|
||||
|
||||
span {
|
||||
background-color: $plyr-preview-time-background;
|
||||
border-radius: calc(#{$plyr-preview-radius} - 1px);
|
||||
color: $plyr-preview-time-color;
|
||||
font-size: $plyr-preview-time-font-size;
|
||||
padding: $plyr-preview-time-padding;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,12 +4,14 @@
|
||||
|
||||
$plyr-preview-padding: $plyr-tooltip-padding !default;
|
||||
$plyr-preview-background: $plyr-tooltip-background !default;
|
||||
$plyr-preview-radius: $plyr-tooltip-radius !default;
|
||||
$plyr-preview-radius: 6px !default;
|
||||
$plyr-preview-shadow: $plyr-tooltip-shadow !default;
|
||||
$plyr-preview-arrow-size: $plyr-tooltip-arrow-size !default;
|
||||
$plyr-preview-image-background: $plyr-color-gray-200 !default;
|
||||
$plyr-preview-time-font-size: $plyr-font-size-time !default;
|
||||
$plyr-preview-time-padding: 3px 6px !default;
|
||||
$plyr-preview-time-background: rgba(0, 0, 0, 0.55);
|
||||
$plyr-preview-time-container-background: var(
|
||||
--plyr-video-controls-background,
|
||||
linear-gradient(rgba(#000, 0), rgba(#000, 0.75))
|
||||
) !default;
|
||||
$plyr-preview-time-container-padding: 20px 6px 6px !default;
|
||||
$plyr-preview-time-color: #fff;
|
||||
$plyr-preview-time-bottom-offset: 6px;
|
||||
$plyr-preview-time-font-size: $plyr-font-size-time !default;
|
||||
|
@ -4,15 +4,14 @@
|
||||
// TODO: Review use of BEM classnames
|
||||
// ==========================================================================
|
||||
@charset 'UTF-8';
|
||||
|
||||
@import 'lib/css-vars';
|
||||
|
||||
$css-vars-use-native: true;
|
||||
|
||||
@import 'settings/breakpoints';
|
||||
@import 'settings/colors';
|
||||
@import 'settings/cosmetics';
|
||||
@import 'settings/type';
|
||||
|
||||
@import 'settings/badges';
|
||||
@import 'settings/captions';
|
||||
@import 'settings/controls';
|
||||
@ -21,13 +20,10 @@ $css-vars-use-native: true;
|
||||
@import 'settings/progress';
|
||||
@import 'settings/sliders';
|
||||
@import 'settings/tooltips';
|
||||
|
||||
@import 'lib/animation';
|
||||
@import 'lib/functions';
|
||||
@import 'lib/mixins';
|
||||
|
||||
@import 'base';
|
||||
|
||||
@import 'components/badges';
|
||||
@import 'components/captions';
|
||||
@import 'components/control';
|
||||
@ -39,14 +35,10 @@ $css-vars-use-native: true;
|
||||
@import 'components/tooltips';
|
||||
@import 'components/progress';
|
||||
@import 'components/volume';
|
||||
|
||||
@import 'types/audio';
|
||||
@import 'types/video';
|
||||
|
||||
@import 'states/fullscreen';
|
||||
|
||||
@import 'plugins/ads';
|
||||
@import 'plugins/preview-thumbnails/index';
|
||||
|
||||
@import 'utils/animation';
|
||||
@import 'utils/hidden';
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
$plyr-captions-background: var(--plyr-captions-background, rgba(#000, 0.8)) !default;
|
||||
$plyr-captions-text-color: var(--plyr-captions-text-color, #fff) !default;
|
||||
|
||||
$plyr-font-size-captions-base: $plyr-font-size-base !default;
|
||||
$plyr-font-size-captions-small: $plyr-font-size-small !default;
|
||||
$plyr-font-size-captions-medium: $plyr-font-size-large !default;
|
||||
|
@ -2,16 +2,17 @@
|
||||
// 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, rgb(0 0 0 / 100%)) !default;
|
||||
|
||||
// Grayscale
|
||||
$plyr-color-gray-900: hsl(216, 15%, 16%) !default;
|
||||
$plyr-color-gray-800: hsl(216, 15%, 25%) !default;
|
||||
$plyr-color-gray-700: hsl(216, 15%, 34%) !default;
|
||||
$plyr-color-gray-600: hsl(216, 15%, 43%) !default;
|
||||
$plyr-color-gray-500: hsl(216, 15%, 52%) !default;
|
||||
$plyr-color-gray-400: hsl(216, 15%, 61%) !default;
|
||||
$plyr-color-gray-300: hsl(216, 15%, 70%) !default;
|
||||
$plyr-color-gray-200: hsl(216, 15%, 79%) !default;
|
||||
$plyr-color-gray-100: hsl(216, 15%, 88%) !default;
|
||||
$plyr-color-gray-50: hsl(216, 15%, 97%) !default;
|
||||
$plyr-color-gray-900: hsl(216deg 15% 16%) !default;
|
||||
$plyr-color-gray-800: hsl(216deg 15% 25%) !default;
|
||||
$plyr-color-gray-700: hsl(216deg 15% 34%) !default;
|
||||
$plyr-color-gray-600: hsl(216deg 15% 43%) !default;
|
||||
$plyr-color-gray-500: hsl(216deg 15% 52%) !default;
|
||||
$plyr-color-gray-400: hsl(216deg 15% 61%) !default;
|
||||
$plyr-color-gray-300: hsl(216deg 15% 70%) !default;
|
||||
$plyr-color-gray-200: hsl(216deg 15% 79%) !default;
|
||||
$plyr-color-gray-100: hsl(216deg 15% 88%) !default;
|
||||
$plyr-color-gray-50: hsl(216deg 15% 97%) !default;
|
||||
|
@ -7,12 +7,10 @@ $plyr-control-spacing: var(--plyr-control-spacing, 10px) !default;
|
||||
$plyr-control-padding: calc(#{$plyr-control-spacing} * 0.7);
|
||||
$plyr-control-padding: var(--plyr-control-padding, $plyr-control-padding) !default;
|
||||
$plyr-control-radius: var(--plyr-control-radius, 3px) !default;
|
||||
|
||||
$plyr-control-toggle-checked-background: var(
|
||||
--plyr-control-toggle-checked-background,
|
||||
var(--plyr-color-main, $plyr-color-main)
|
||||
) !default;
|
||||
|
||||
$plyr-video-controls-background: var(
|
||||
--plyr-video-controls-background,
|
||||
linear-gradient(rgba(#000, 0), rgba(#000, 0.75))
|
||||
@ -23,7 +21,6 @@ $plyr-video-control-background-hover: var(
|
||||
--plyr-video-control-background-hover,
|
||||
var(--plyr-color-main, $plyr-color-main)
|
||||
) !default;
|
||||
|
||||
$plyr-audio-controls-background: var(--plyr-audio-controls-background, #fff) !default;
|
||||
$plyr-audio-control-color: var(--plyr-audio-control-color, $plyr-color-gray-700) !default;
|
||||
$plyr-audio-control-color-hover: var(--plyr-audio-control-color-hover, #fff) !default;
|
||||
|
@ -7,9 +7,7 @@ $plyr-menu-radius: var(--plyr-menu-radius, 4px) !default;
|
||||
$plyr-menu-color: var(--plyr-menu-color, $plyr-color-gray-700) !default;
|
||||
$plyr-menu-shadow: var(--plyr-menu-shadow, 0 1px 2px rgba(#000, 0.15)) !default;
|
||||
$plyr-menu-arrow-size: var(--plyr-menu-arrow-size, 4px) !default;
|
||||
|
||||
$plyr-menu-item-arrow-size: var(--plyr-menu-item-arrow-size, 4px) !default;
|
||||
$plyr-menu-item-arrow-color: var(--plyr-menu-arrow-color, $plyr-color-gray-500) !default;
|
||||
|
||||
$plyr-menu-back-border-color: var(--plyr-menu-back-border-color, $plyr-color-gray-100) !default;
|
||||
$plyr-menu-back-border-shadow-color: var(--plyr-menu-back-border-shadow-color, #fff) !default;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user