Compare commits
30 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 | |||
1b835cb657 | |||
b4f24f90da | |||
e4a18a5c99 | |||
02d06c464c | |||
cec2474295 |
@ -1,6 +0,0 @@
|
||||
language: node_js
|
||||
node_js: lts/*
|
||||
|
||||
script:
|
||||
- npm run lint
|
||||
- npm run build
|
32
CHANGELOG.md
32
CHANGELOG.md
@ -1,3 +1,13 @@
|
||||
## 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)
|
||||
@ -6,7 +16,7 @@
|
||||
|
||||
- Fix: Replace `list.slash` added in 3.6.10 with `calc`
|
||||
- Chore: Package upgrades
|
||||
- Chore: SASS clean up
|
||||
- Chore: Sass clean up
|
||||
- Chore: Improvements to style linting
|
||||
|
||||
### v3.6.10
|
||||
@ -16,7 +26,7 @@
|
||||
|
||||
### v3.6.9
|
||||
|
||||
- Fix: SASS issue with division (thanks @ROL4ND909 and @le0pard)
|
||||
- Fix: Sass issue with division (thanks @ROL4ND909 and @le0pard)
|
||||
- Fix: Captions when switching sources (thanks @zexingguo)
|
||||
- Fix: Icons loading within iframes (thanks @ajgagnon)
|
||||
- Chore: Update TypeScript types (thanks @Jackie1210 and @AntLevin)
|
||||
@ -171,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
|
||||
@ -534,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
|
||||
@ -767,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)
|
||||
@ -889,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)
|
||||
|
||||
@ -926,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
|
||||
|
||||
@ -948,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)
|
||||
|
||||
@ -1025,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
|
||||
|
||||
@ -1140,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
|
||||
@ -1185,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)
|
||||
|
||||
|
21
README.md
21
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
|
||||
|
||||
@ -134,13 +137,13 @@ See [initialising](#initialising) for more information on advanced setups.
|
||||
You can use our CDN (provided by [Fastly](https://www.fastly.com/)) for the JavaScript. There's 2 versions; one with and one without [polyfills](#polyfills). My recommendation would be to manage polyfills 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.12/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.12/plyr.polyfilled.js"></script>
|
||||
<script src="https://cdn.plyr.io/3.7.0/plyr.polyfilled.js"></script>
|
||||
```
|
||||
|
||||
## CSS
|
||||
@ -154,13 +157,13 @@ Include the `plyr.css` stylesheet 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.12/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.12/plyr.svg`.
|
||||
reference, the CDN hosted SVG sprite can be found at `https://cdn.plyr.io/3.7.0/plyr.svg`.
|
||||
|
||||
# Ads
|
||||
|
||||
@ -270,9 +273,9 @@ You can set them in your CSS for all players:
|
||||
<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
|
||||
@ -402,7 +405,7 @@ Note the single quotes encapsulating the JSON and double quotes on the object ke
|
||||
| `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. |
|
||||
@ -410,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:
|
||||
|
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": []
|
||||
}
|
@ -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
|
||||
|
38
package.json
38
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "plyr",
|
||||
"version": "3.6.12",
|
||||
"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>",
|
||||
@ -36,25 +36,27 @@
|
||||
"remark": "remark -f --use 'validate-links=repository:\"sampotts/plyr\"' '{,!(node_modules),.?**/}*.md'",
|
||||
"deploy": "yarn lint && gulp version && gulp build && gulp deploy",
|
||||
"format": "prettier --write \"./{src,demo/src}/**/*.{js,scss}\"",
|
||||
"spellcheck": "cspell \"**/*.{js,md,scss,json}\" --no-must-find-files",
|
||||
"start": "gulp"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.16.5",
|
||||
"@babel/plugin-proposal-class-properties": "^7.16.5",
|
||||
"@babel/preset-env": "^7.16.5",
|
||||
"@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.0",
|
||||
"aws-sdk": "^2.1046.0",
|
||||
"autoprefixer": "^10.4.4",
|
||||
"aws-sdk": "^2.1116.0",
|
||||
"babel-eslint": "^10.1.0",
|
||||
"browser-sync": "^2.27.7",
|
||||
"browser-sync": "^2.27.9",
|
||||
"colorette": "2.0.16",
|
||||
"cssnano": "^5.0.13",
|
||||
"cspell": "^5.19.7",
|
||||
"cssnano": "^5.1.7",
|
||||
"del": "^6.0.0",
|
||||
"eslint": "^7.23.0",
|
||||
"fancy-log": "^1.3.3",
|
||||
"fancy-log": "^2.0.0",
|
||||
"git-branch": "^2.0.1",
|
||||
"gulp": "^4.0.2",
|
||||
"gulp-awspublish": "^4.1.2",
|
||||
"gulp-awspublish": "^6.0.2",
|
||||
"gulp-better-rollup": "^4.0.1",
|
||||
"gulp-filter": "^7.0.0",
|
||||
"gulp-header": "^2.0.9",
|
||||
@ -66,30 +68,30 @@
|
||||
"gulp-postcss": "^9.0.1",
|
||||
"gulp-rename": "^2.0.0",
|
||||
"gulp-replace": "^1.1.3",
|
||||
"gulp-sass": "^5.0.0",
|
||||
"gulp-sass": "^5.1.0",
|
||||
"gulp-size": "^4.0.1",
|
||||
"gulp-sourcemaps": "^3.0.0",
|
||||
"gulp-svgstore": "^9.0.0",
|
||||
"gulp-terser": "^2.1.0",
|
||||
"postcss": "^8.4.5",
|
||||
"postcss-custom-properties": "^12.0.1",
|
||||
"postcss-scss": "^4.0.2",
|
||||
"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": "^10.0.1",
|
||||
"remark-validate-links": "^11.0.2",
|
||||
"rollup": "^2.61.1",
|
||||
"rollup": "^2.70.2",
|
||||
"rollup-plugin-babel": "^4.4.0",
|
||||
"rollup-plugin-commonjs": "^10.1.0",
|
||||
"rollup-plugin-node-resolve": "^5.2.0",
|
||||
"sass": "^1.45.0",
|
||||
"stylelint": "^14.1.0",
|
||||
"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.20.0",
|
||||
"core-js": "^3.22.0",
|
||||
"custom-event-polyfill": "^1.0.7",
|
||||
"loadjs": "^4.2.0",
|
||||
"rangetouch": "^2.0.1",
|
||||
|
@ -61,7 +61,7 @@ const defaults = {
|
||||
// Sprite (for icons)
|
||||
loadSprite: true,
|
||||
iconPrefix: 'plyr',
|
||||
iconUrl: 'https://cdn.plyr.io/3.6.12/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',
|
||||
@ -441,6 +442,20 @@ const defaults = {
|
||||
customControls: true,
|
||||
noCookie: false, // Whether to use an alternative version of YouTube without cookies
|
||||
},
|
||||
|
||||
// Media Metadata
|
||||
mediaMetadata: {
|
||||
title: '',
|
||||
artist: '',
|
||||
album: '',
|
||||
artwork: [],
|
||||
},
|
||||
|
||||
// Markers
|
||||
markers: {
|
||||
enabled: false,
|
||||
points: [],
|
||||
},
|
||||
};
|
||||
|
||||
export default defaults;
|
||||
|
115
src/js/controls.js
vendored
115
src/js/controls.js
vendored
@ -484,7 +484,7 @@ const controls = {
|
||||
|
||||
menuItem.appendChild(flex);
|
||||
|
||||
// Replicate radio button behaviour
|
||||
// Replicate radio button behavior
|
||||
Object.defineProperty(menuItem, 'checked', {
|
||||
enumerable: true,
|
||||
get() {
|
||||
@ -698,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) {
|
||||
@ -713,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;
|
||||
}
|
||||
@ -726,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
|
||||
@ -796,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);
|
||||
},
|
||||
@ -1745,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;
|
||||
|
@ -241,6 +241,15 @@ class PreviewThumbnails {
|
||||
|
||||
// Set time text inside image container
|
||||
this.elements.thumb.time.innerText = formatTime(this.seekTime);
|
||||
|
||||
// Get marker point for time
|
||||
const point = this.player.config.markers?.points?.find(({ time: t }) => t === Math.round(this.seekTime));
|
||||
|
||||
// Append the point label to the tooltip
|
||||
if (point) {
|
||||
// this.elements.thumb.time.innerText.concat('\n');
|
||||
this.elements.thumb.time.insertAdjacentHTML('afterbegin', `${point.label}<br>`);
|
||||
}
|
||||
}
|
||||
|
||||
// Download and show image
|
||||
@ -326,7 +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)) {
|
||||
|
@ -35,12 +35,12 @@ function parseHash(url) {
|
||||
* - [https://player.]vimeo.com/video/{id}?h={hash}[¶ms]
|
||||
* - [https://player.]vimeo.com/video/{id}?[params]&h={hash}
|
||||
* - video/{id}/{hash}
|
||||
* If matched, the hash is available in the named group `hash`
|
||||
* If matched, the hash is available in capture group 4
|
||||
*/
|
||||
const regex = /^.*(?:vimeo.com\/|video\/)(?:\d+)(?:\?.*&*h=|\/)+(?<hash>[\d,a-f]+)/;
|
||||
const regex = /^.*(vimeo.com\/|video\/)(\d+)(\?.*&*h=|\/)+([\d,a-f]+)/;
|
||||
const found = url.match(regex);
|
||||
|
||||
return found ? found.groups.hash : null;
|
||||
return found && found.length === 5 ? found[4] : null;
|
||||
}
|
||||
|
||||
// Set playback state and trigger change (only on actual change)
|
||||
|
18
src/js/plyr.d.ts
vendored
18
src/js/plyr.d.ts
vendored
@ -518,6 +518,11 @@ declare namespace Plyr {
|
||||
* Preview Thumbnails Options.
|
||||
*/
|
||||
previewThumbnails?: PreviewThumbnailsOptions;
|
||||
|
||||
/**
|
||||
* Media Metadata Options.
|
||||
*/
|
||||
mediaMetadata?: MediaMetadataOptions;
|
||||
}
|
||||
|
||||
interface QualityOptions {
|
||||
@ -576,6 +581,19 @@ 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;
|
||||
|
@ -1,6 +1,6 @@
|
||||
// ==========================================================================
|
||||
// Plyr
|
||||
// plyr.js v3.6.12
|
||||
// plyr.js v3.7.0
|
||||
// https://github.com/sampotts/plyr
|
||||
// License: The MIT License (MIT)
|
||||
// ==========================================================================
|
||||
@ -958,7 +958,7 @@ class Plyr {
|
||||
*/
|
||||
set currentTrack(input) {
|
||||
captions.set.call(this, input, false);
|
||||
captions.setup();
|
||||
captions.setup.call(this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,6 @@
|
||||
// ==========================================================================
|
||||
// Plyr Polyfilled Build
|
||||
// plyr.js v3.6.12
|
||||
// plyr.js v3.7.0
|
||||
// https://github.com/sampotts/plyr
|
||||
// License: The MIT License (MIT)
|
||||
// ==========================================================================
|
||||
|
@ -125,6 +125,11 @@ const ui = {
|
||||
if (this.config.duration) {
|
||||
controls.durationUpdate.call(this);
|
||||
}
|
||||
|
||||
// Media metadata
|
||||
if (this.config.mediaMetadata) {
|
||||
controls.setMediaMetadata.call(this);
|
||||
}
|
||||
},
|
||||
|
||||
// Setup aria attribute for play and iframe title
|
||||
|
@ -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 = '') {
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -62,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,
|
||||
|
@ -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;
|
||||
|
@ -6,6 +6,10 @@
|
||||
$plyr-progress-loading-size: var(--plyr-progress-loading-size, 25px) !default;
|
||||
$plyr-progress-loading-background: var(--plyr-progress-loading-background, rgba($plyr-color-gray-900, 0.6)) !default;
|
||||
|
||||
// Markers
|
||||
$plyr-progress-marker-background: var(--plyr-progress-marker-background, #fff) !default;
|
||||
$plyr-progress-marker-width: var(--plyr-progress-marker-width, 3px) !default;
|
||||
|
||||
// Buffered
|
||||
$plyr-video-progress-buffered-background: var(--plyr-video-progress-buffered-background, rgba(#fff, 0.25)) !default;
|
||||
$plyr-audio-progress-buffered-background: var(
|
||||
|
Reference in New Issue
Block a user