Compare commits

..

38 Commits

Author SHA1 Message Date
b8c40ead0a chore(release): 3.7.5 2023-03-10 07:29:25 +11:00
874bb8d3e8 fix: replace pnpm with npm in scripts 2023-03-10 07:26:37 +11:00
2b3e483b36 chore(release): 3.7.4 2023-03-09 23:14:21 +11:00
69ef4ec827 chore: remove unused import 2023-03-09 23:11:39 +11:00
d6cc19f2d8 fix: remove erroneous scss 2023-03-09 23:09:01 +11:00
d67eea5942 docs: update screenshot 2023-03-09 23:02:18 +11:00
c4a566dbff feat: remove need for iOS-specific styling 2023-03-09 22:33:37 +11:00
185bb4c7cc docs: add section on self hosting 2023-03-09 22:33:37 +11:00
d9161212ff chore(cspell): add dictionaries 2023-03-09 22:33:37 +11:00
ed0b901d11 chore(build): use pnpm instead of yarn 2023-03-09 22:33:37 +11:00
62436d8e8e fix: fullscreen improvements for iOS & iPadOS 2023-03-09 22:33:21 +11:00
5731245f4f Update README.md 2023-03-08 22:00:41 +11:00
41e2454bd2 Call preview-thumbnails listeners() function on load (#2604)
The listeners() function in preview-thumbnails.js was never called, so some functionality was broken.

Fixes #2210.
2023-02-25 13:04:13 +11:00
9248e322fc chore(deps): bump json5 from 1.0.1 to 1.0.2 (#2600)
Bumps [json5](https://github.com/json5/json5) from 1.0.1 to 1.0.2.
- [Release notes](https://github.com/json5/json5/releases)
- [Changelog](https://github.com/json5/json5/blob/main/CHANGELOG.md)
- [Commits](https://github.com/json5/json5/compare/v1.0.1...v1.0.2)

---
updated-dependencies:
- dependency-name: json5
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-25 13:02:30 +11:00
fa634a1bbb fix(issue #2624): Changing player.embed function call from setVolume to setMuted in src/plugins/Vimeo.js. (#2628)
setVolume(0) used before by muted button, didn't work on IOS

Co-authored-by: Andre Fernandes Cristofolini Melo <andre.melo@dotgroup.com.br>
2023-02-25 13:02:06 +11:00
f7d2938f42 Fixed event key with space (#2581)
* Fixed event key with space

* Fixed spacebar `event.key` in `controls.js`
2022-12-31 11:15:13 +11:00
7c88b58a1a chore(deps): bump decode-uri-component from 0.2.0 to 0.2.2 (#2583)
Bumps [decode-uri-component](https://github.com/SamVerschueren/decode-uri-component) from 0.2.0 to 0.2.2.
- [Release notes](https://github.com/SamVerschueren/decode-uri-component/releases)
- [Commits](https://github.com/SamVerschueren/decode-uri-component/compare/v0.2.0...v0.2.2)

---
updated-dependencies:
- dependency-name: decode-uri-component
  dependency-type: indirect
...

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-31 11:14:39 +11:00
20bf5a8833 chore(release): 3.7.3 2022-11-17 17:36:00 +11:00
de0402bebf fix: simplify logic for isFunction assertion method 2022-11-17 12:23:41 +11:00
db1b89b1c1 chore: update types to include string for controls 2022-11-17 12:23:41 +11:00
ea3675fcdc fix: revert pip change for iphone and add comment 2022-11-17 12:23:41 +11:00
e8beabd6a8 chore: upgrade packages 2022-11-17 12:23:41 +11:00
433acd6f41 chore: use .node-version instead of .nvmrc 2022-11-17 12:23:41 +11:00
69ced1313a fix: force nowrap in progress tooltips 2022-11-17 12:23:41 +11:00
511a7db7c2 chore(deps): bump minimatch from 3.0.4 to 3.1.2 (#2573)
Bumps [minimatch](https://github.com/isaacs/minimatch) from 3.0.4 to 3.1.2.
- [Release notes](https://github.com/isaacs/minimatch/releases)
- [Commits](https://github.com/isaacs/minimatch/compare/v3.0.4...v3.1.2)

---
updated-dependencies:
- dependency-name: minimatch
  dependency-type: indirect
...

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-17 12:22:30 +11:00
6a62e3d085 i18n: Make captions autodetect text direction (#2540)
This uses browser mechanism for detecting appropiate direction for text, dir=auto.
2022-11-17 12:22:10 +11:00
aba00d0ab6 plyr.io used on Thousands of Index Websites (#2516) 2022-11-17 12:21:27 +11:00
c115dfc6a6 fixed menu border radius bug (#2548) 2022-11-17 12:13:40 +11:00
6030b300f6 fix iPhone no PIP bug (#2533) 2022-11-17 11:57:04 +11:00
fff26351c9 chore(deps): bump socket.io-parser from 4.0.4 to 4.0.5 (#2564)
Bumps [socket.io-parser](https://github.com/socketio/socket.io-parser) from 4.0.4 to 4.0.5.
- [Release notes](https://github.com/socketio/socket.io-parser/releases)
- [Changelog](https://github.com/socketio/socket.io-parser/blob/main/CHANGELOG.md)
- [Commits](https://github.com/socketio/socket.io-parser/compare/4.0.4...4.0.5)

---
updated-dependencies:
- dependency-name: socket.io-parser
  dependency-type: indirect
...

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-17 11:52:32 +11:00
e0fb524382 navigator.platform is deprecated (#2530)
I'm submitting a little update for browser detection:

1. `navigator.platform` is deprecated - it's prefered to use `navigator.userAgent` https://developer.mozilla.org/en-US/docs/Web/API/Navigator/platform
2. No need for the brackets in the RegEx - you can test this on https://regex101.com

And that's about it. Maybe I missed the point, do let me know! ❤️
2022-09-15 15:08:03 +10:00
ebda039395 Added configurable property to elements for re-use (#2489) 2022-09-09 22:52:01 +10:00
ed456197f5 chore(deps): bump terser from 5.10.0 to 5.14.2 (#2506)
Bumps [terser](https://github.com/terser/terser) from 5.10.0 to 5.14.2.
- [Release notes](https://github.com/terser/terser/releases)
- [Changelog](https://github.com/terser/terser/blob/master/CHANGELOG.md)
- [Commits](https://github.com/terser/terser/commits)

---
updated-dependencies:
- dependency-name: terser
  dependency-type: indirect
...

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-09 22:49:05 +10:00
66187c348a docs: replace example video ID with one that still works (#2518) 2022-09-09 22:47:42 +10:00
cacaef7def Improve accessibility on control buttons with aria-pressed (#2523) 2022-09-09 22:46:24 +10:00
42b8f7bdab Fix for calc() in newer Dart Sass versions (#2519) 2022-09-09 22:45:16 +10:00
c90f044dac v3.7.2
- Fix: Add `@babel/plugin-proposal-optional-chaining` to transform optional chaining in build output
2022-04-20 20:15:42 +10:00
5f2cb90bc6 fix: add babel plugin to transform optional chaining 2022-04-20 20:12:08 +10:00
30 changed files with 14159 additions and 13668 deletions

1
.node-version Normal file
View File

@ -0,0 +1 @@
19.7.0

1
.nvmrc
View File

@ -1 +0,0 @@
16

View File

@ -1,7 +1,38 @@
### v3.7.5
- Fix: Replace `pnpm` with `npm` in scripts to fix build issues
### v3.7.4
- Fix: Fixed event key with space (thanks @royeden!)
- Fix: Changing Vimeo function call from `setVolume` to `setMuted` to fix iOS issue (issue #2624) (thanks @HandreMelo and Andre Fernandes Cristofolini Melo!)
- Fix: Call preview-thumbnails listeners() function on load (thanks @mogzol!)
- Fix: Fullscreen improvements for iOS & iPadOS
- Feat: Remove need for iOS-specific styling (please update [volume.scss](https://github.com/sampotts/plyr/blob/master/src/sass/components/volume.scss))
### v3.7.3
- Fix: force nowrap in progress tooltips (related: #2549) (thanks @raad-altaie!)
- Feat(i18n): Make captions autodetect text direction (#2540) (thanks @ebraminio!)
- Fix: fixed menu border radius bug (#2548) (thanks @raad-altaie!)
- Chore: navigator.platform is deprecated (#2530) (thanks @stamat!)
- Feat: Added configurable property to elements for re-use (#2489) (thanks @NoirHusky!)
- Docs: Replace example video ID with one that still works (#2518) (thanks @luvejo!)
- Fix: Improve accessibility on control buttons with aria-pressed (#2523) (thanks @emilkarl!)
- Fix: Fix for calc() in newer Dart Sass versions (#2519) (thanks @ckhicks!)
- Fix: simplify logic for isFunction assertion method
- Chore: update types to include string for controls
- Chore: upgrade packages
- Chore: use `.node-version` instead of `.nvmrc`
### v3.7.2
- Fix: Add `@babel/plugin-proposal-optional-chaining` to transform optional chaining in build output
### v3.7.1 ### v3.7.1
- Feat: Minor styling improvements to the preview thumbnails (🚨 Requires a SCSS/CSS update 🚨) - Feat: Minor styling improvements to the preview thumbnails (🚨 Requires a SCSS/CSS update 🚨)
- Fix: fix invalid CSS @charset rule in Sass files (thanks @Hashen110!) - Fix: Fix invalid CSS @charset rule in Sass files (thanks @Hashen110!)
- Chore: Replace deprecated KeyboardEvent `keyCode` references to use `key` instead (thanks @Hashen110!) - Chore: Replace deprecated KeyboardEvent `keyCode` references to use `key` instead (thanks @Hashen110!)
- Various other code clean up and typo fixes (thanks @Hashen110!) - Various other code clean up and typo fixes (thanks @Hashen110!)
@ -611,10 +642,10 @@ Because we're using the fancy new ES6 syntax, you will need to polyfill for vint
- Vimeo controls fix (fixes #697) - Vimeo controls fix (fixes #697)
- SVG4everybody compatibility fix - SVG4everybody compatibility fix
- Allow Plyr.setup event listeners to be set up as separate event listeners (https://github.com/sampotts/plyr/pull/703) - Allow Plyr.setup event listeners to be set up as separate event listeners (<https://github.com/sampotts/plyr/pull/703>)
- Added title to the layer html template (for custom controls) (https://github.com/sampotts/plyr/pull/649) - Added title to the layer html template (for custom controls) (<https://github.com/sampotts/plyr/pull/649>)
- Target is null bug fix (https://github.com/sampotts/plyr/pull/617) - Target is null bug fix (<https://github.com/sampotts/plyr/pull/617>)
- fix #684 memory leaks issues after destroy (https://github.com/sampotts/plyr/pull/700) - fix #684 memory leaks issues after destroy (<https://github.com/sampotts/plyr/pull/700>)
### v2.0.16 ### v2.0.16
@ -634,8 +665,8 @@ Because we're using the fancy new ES6 syntax, you will need to polyfill for vint
### v2.0.12 ### v2.0.12
- Ability to set custom `blankUrl` for source changes (https://github.com/sampotts/plyr/pull/504) - Ability to set custom `blankUrl` for source changes (<https://github.com/sampotts/plyr/pull/504>)
- Ability to set caption button listener (https://github.com/sampotts/plyr/pull/468) - Ability to set caption button listener (<https://github.com/sampotts/plyr/pull/468>)
### v2.0.11 ### v2.0.11

197
README.md
View File

@ -7,7 +7,7 @@ Plyr is a simple, lightweight, accessible and customizable HTML5, YouTube and Vi
[![npm version](https://badge.fury.io/js/plyr.svg)](https://badge.fury.io/js/plyr) [![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/sampotts/plyr) [![Financial Contributors on Open Collective](https://opencollective.com/plyr/all/badge.svg?label=financial+contributors)](https://opencollective.com/plyr) [![npm version](https://badge.fury.io/js/plyr.svg)](https://badge.fury.io/js/plyr) [![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/sampotts/plyr) [![Financial Contributors on Open Collective](https://opencollective.com/plyr/all/badge.svg?label=financial+contributors)](https://opencollective.com/plyr)
[![Image of Plyr](https://cdn.plyr.io/static/demo/screenshot.png?v=3)](https://plyr.io) [![Screenshot of Plyr](https://cdn.plyr.io/static/screenshot.webp)](https://plyr.io)
# Features # Features
@ -32,7 +32,7 @@ Plyr is a simple, lightweight, accessible and customizable HTML5, YouTube and Vi
- 🤟 **No frameworks** - written in "vanilla" ES6 JavaScript, no jQuery required - 🤟 **No frameworks** - written in "vanilla" ES6 JavaScript, no jQuery required
- 💁‍♀️ **Sass** - to include in your build processes - 💁‍♀️ **Sass** - to include in your build processes
### Demos ## Demos
You can try Plyr in Codepen using our minimal templates: [HTML5 video](https://codepen.io/pen?template=bKeqpr), [HTML5 audio](https://codepen.io/pen?template=rKLywR), [YouTube](https://codepen.io/pen?template=GGqbbJ), [Vimeo](https://codepen.io/pen?template=bKeXNq). For Streaming we also have example integrations with: [Dash.js](https://codepen.io/pen?template=GRoogML), [Hls.js](https://codepen.io/pen?template=oyLKQb) and [Shaka Player](https://codepen.io/pen?template=ZRpzZO) You can try Plyr in Codepen using our minimal templates: [HTML5 video](https://codepen.io/pen?template=bKeqpr), [HTML5 audio](https://codepen.io/pen?template=rKLywR), [YouTube](https://codepen.io/pen?template=GGqbbJ), [Vimeo](https://codepen.io/pen?template=bKeXNq). For Streaming we also have example integrations with: [Dash.js](https://codepen.io/pen?template=GRoogML), [Hls.js](https://codepen.io/pen?template=oyLKQb) and [Shaka Player](https://codepen.io/pen?template=ZRpzZO)
@ -117,7 +117,7 @@ Or the `<div>` non progressively enhanced method:
You can use Plyr as an ES6 module as follows: You can use Plyr as an ES6 module as follows:
```javascript ```js
import Plyr from 'plyr'; import Plyr from 'plyr';
const player = new Plyr('#player'); const player = new Plyr('#player');
@ -132,18 +132,18 @@ Alternatively you can include the `plyr.js` script before the closing `</body>`
</script> </script>
``` ```
See [initialising](#initialising) for more information on advanced setups. See [initialising](#initializing) for more information on advanced setups.
You can use our CDN (provided by [Fastly](https://www.fastly.com/)) for the JavaScript. There's 2 versions; one with and one without [polyfills](#polyfills). My recommendation would be to manage polyfills separately as part of your application but to make life easier you can use the polyfilled build. You can use our CDN (provided by [Cloudflare](https://www.cloudflare.com/)) for the JavaScript. There's 2 versions; one with and one without [polyfills](#polyfills). My recommendation would be to manage polyfills separately as part of your application but to make life easier you can use the polyfilled build.
```html ```html
<script src="https://cdn.plyr.io/3.7.1/plyr.js"></script> <script src="https://cdn.plyr.io/3.7.5/plyr.js"></script>
``` ```
...or... ...or...
```html ```html
<script src="https://cdn.plyr.io/3.7.1/plyr.polyfilled.js"></script> <script src="https://cdn.plyr.io/3.7.5/plyr.polyfilled.js"></script>
``` ```
## CSS ## CSS
@ -154,16 +154,24 @@ Include the `plyr.css` stylesheet into your `<head>`.
<link rel="stylesheet" href="path/to/plyr.css" /> <link rel="stylesheet" href="path/to/plyr.css" />
``` ```
If you want to use our CDN (provided by [Fastly](https://www.fastly.com/)) for the default CSS, you can use the following: If you want to use our CDN (provided by [Cloudflare](https://www.cloudflare.com/)) for the default CSS, you can use the following:
```html ```html
<link rel="stylesheet" href="https://cdn.plyr.io/3.7.1/plyr.css" /> <link rel="stylesheet" href="https://cdn.plyr.io/3.7.5/plyr.css" />
``` ```
## SVG Sprite ## SVG Sprite
The SVG sprite is loaded automatically from our CDN (provided by [Fastly](https://www.fastly.com/)). To change this, see the [options](#options) below. For The SVG sprite is loaded automatically from our CDN (provided by [Cloudflare](https://www.cloudflare.com/)). To change this, see the [options](#options) below. For
reference, the CDN hosted SVG sprite can be found at `https://cdn.plyr.io/3.7.1/plyr.svg`. reference, the CDN hosted SVG sprite can be found at `https://cdn.plyr.io/3.7.5/plyr.svg`.
### Self hosting
If you don't want to create a build system to include Plyr as an npm module, you can use the pre-built files. You have a few options:
- Download the files from the CDN links above, they're already minified.
- Download the files from [unpkg](https://unpkg.com/browse/plyr/dist/) or similar services.
- Build the project yourself using `pnpm i`, which installs the dependencies and spits out a build to `dist`.
# Ads # Ads
@ -310,7 +318,7 @@ WebVTT captions are supported. To add a caption track, check the HTML example ab
## JavaScript ## JavaScript
### Initialising ### Initializing
You can specify a range of arguments for the constructor to use: You can specify a range of arguments for the constructor to use:
@ -324,17 +332,17 @@ _Note_: If a `NodeList`, `Array`, or jQuery object are passed, the first element
Passing a CSS string selector that's compatible with [`querySelector`](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector): Passing a CSS string selector that's compatible with [`querySelector`](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector):
```javascript ```js
const player = new Plyr('#player'); const player = new Plyr('#player');
``` ```
Passing a [HTMLElement](https://developer.mozilla.org/en/docs/Web/API/HTMLElement): Passing a [HTMLElement](https://developer.mozilla.org/en/docs/Web/API/HTMLElement):
```javascript ```js
const player = new Plyr(document.getElementById('player')); const player = new Plyr(document.getElementById('player'));
``` ```
```javascript ```js
const player = new Plyr(document.querySelector('.js-player')); const player = new Plyr(document.querySelector('.js-player'));
``` ```
@ -344,13 +352,13 @@ The HTMLElement or string selector can be the target `<video>`, `<audio>`, or `<
You have two choices here. You can either use a simple array loop to map the constructor: You have two choices here. You can either use a simple array loop to map the constructor:
```javascript ```js
const players = Array.from(document.querySelectorAll('.js-player')).map((p) => new Plyr(p)); const players = Array.from(document.querySelectorAll('.js-player')).map((p) => new Plyr(p));
``` ```
...or use a static method where you can pass a [CSS string selector](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors), a [NodeList](https://developer.mozilla.org/en-US/docs/Web/API/NodeList), an [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) of [HTMLElement](https://developer.mozilla.org/en/docs/Web/API/HTMLElement), or a [JQuery](https://jquery.com) object: ...or use a static method where you can pass a [CSS string selector](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors), a [NodeList](https://developer.mozilla.org/en-US/docs/Web/API/NodeList), an [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) of [HTMLElement](https://developer.mozilla.org/en/docs/Web/API/HTMLElement), or a [JQuery](https://jquery.com) object:
```javascript ```js
const players = Plyr.setup('.js-player'); const players = Plyr.setup('.js-player');
``` ```
@ -360,7 +368,7 @@ Both options will also return an array of instances in the order of they were in
The second argument for the constructor is the [options](#options) object: The second argument for the constructor is the [options](#options) object:
```javascript ```js
const player = new Plyr('#player', { const player = new Plyr('#player', {
title: 'Example Title', title: 'Example Title',
}); });
@ -374,54 +382,60 @@ Options can be passed as an object to the constructor as above or as JSON in `da
Note the single quotes encapsulating the JSON and double quotes on the object keys. Only string values need double quotes. Note the single quotes encapsulating the JSON and double quotes on the object keys. Only string values need double quotes.
| Option | Type | Default | Description | | Option | Type | Default | Description |
| -------------------- | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | -------------------- | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `enabled` | Boolean | `true` | Completely disable Plyr. This would allow you to do a User Agent check or similar to programmatically enable or disable Plyr for a certain UA. Example below. | | `enabled` | Boolean | `true` | Completely disable Plyr. This would allow you to do a User Agent check or similar to programmatically enable or disable Plyr for a certain UA. Example below. |
| `debug` | Boolean | `false` | Display debugging information in the console | | `debug` | Boolean | `false` | Display debugging information in the console |
| `controls` | Array, Function or Element | `['play-large', 'play', 'progress', 'current-time', 'mute', 'volume', 'captions', 'settings', 'pip', 'airplay', 'fullscreen']` | If a function is passed, it is assumed your method will return either an element or HTML string for the controls. Three arguments will be passed to your function; `id` (the unique id for the player), `seektime` (the seektime step in seconds), and `title` (the media title). See [CONTROLS.md](CONTROLS.md) for more info on how the html needs to be structured. | | `controls` | Array, Function or Element | `['play-large', 'play', 'progress', 'current-time', 'mute', 'volume', 'captions', 'settings', 'pip', 'airplay', 'fullscreen']` | If a function is passed, it is assumed your method will return either an element or HTML string for the controls. Three arguments will be passed to your function; `id` (the unique id for the player), `seektime` (the seektime step in seconds), and `title` (the media title). See [CONTROLS.md](CONTROLS.md) for more info on how the html needs to be structured. |
| `settings` | Array | `['captions', 'quality', 'speed', 'loop']` | If the default controls are used, you can specify which settings to show in the menu | | `settings` | Array | `['captions', 'quality', 'speed', 'loop']` | If the default controls are used, you can specify which settings to show in the menu |
| `i18n` | Object | See [defaults.js](/src/js/config/defaults.js) | Used for internationalization (i18n) of the text within the UI. | | `i18n` | Object | See [defaults.js](/src/js/config/defaults.js) | Used for internationalization (i18n) of the text within the UI. |
| `loadSprite` | Boolean | `true` | Load the SVG sprite specified as the `iconUrl` option (if a URL). If `false`, it is assumed you are handling sprite loading yourself. | | `loadSprite` | Boolean | `true` | Load the SVG sprite specified as the `iconUrl` option (if a URL). If `false`, it is assumed you are handling sprite loading yourself. |
| `iconUrl` | String | `null` | Specify a URL or path to the SVG sprite. See the [SVG section](#svg) for more info. | | `iconUrl` | String | `null` | Specify a URL or path to the SVG sprite. See the [SVG section](#svg) for more info. |
| `iconPrefix` | String | `plyr` | Specify the id prefix for the icons used in the default controls (e.g. "plyr-play" would be "plyr"). This is to prevent clashes if you're using your own SVG sprite but with the default controls. Most people can ignore this option. | | `iconPrefix` | String | `plyr` | Specify the id prefix for the icons used in the default controls (e.g. "plyr-play" would be "plyr"). This is to prevent clashes if you're using your own SVG sprite but with the default controls. Most people can ignore this option. |
| `blankVideo` | String | `https://cdn.plyr.io/static/blank.mp4` | Specify a URL or path to a blank video file used to properly cancel network requests. | | `blankVideo` | String | `https://cdn.plyr.io/static/blank.mp4` | Specify a URL or path to a blank video file used to properly cancel network requests. |
| `autoplay`&sup2; | Boolean | `false` | Autoplay the media on load. If the `autoplay` attribute is present on a `<video>` or `<audio>` element, this will be automatically set to true. | | `autoplay`&sup2; | Boolean | `false` | Autoplay the media on load. If the `autoplay` attribute is present on a `<video>` or `<audio>` element, this will be automatically set to true. |
| `autopause`&sup1; | Boolean | `true` | Only allow one player playing at once. | | `autopause`&sup1; | Boolean | `true` | Only allow one player playing at once. |
| `seekTime` | Number | `10` | The time, in seconds, to seek when a user hits fast forward or rewind. | | `playsinline`&sup3; | Boolean | `true` | Allow inline playback on iOS. Note this has no effect on iPadOS. |
| `volume` | Number | `1` | A number, between 0 and 1, representing the initial volume of the player. | | `seekTime` | Number | `10` | The time, in seconds, to seek when a user hits fast forward or rewind. |
| `muted` | Boolean | `false` | Whether to start playback muted. If the `muted` attribute is present on a `<video>` or `<audio>` element, this will be automatically set to true. | | `volume` | Number | `1` | A number, between 0 and 1, representing the initial volume of the player. |
| `clickToPlay` | Boolean | `true` | Click (or tap) of the video container will toggle play/pause. | | `muted` | Boolean | `false` | Whether to start playback muted. If the `muted` attribute is present on a `<video>` or `<audio>` element, this will be automatically set to true. |
| `disableContextMenu` | Boolean | `true` | Disable right click menu on video to <em>help</em> as very primitive obfuscation to prevent downloads of content. | | `clickToPlay` | Boolean | `true` | Click (or tap) of the video container will toggle play/pause. |
| `hideControls` | Boolean | `true` | Hide video controls automatically after 2s of no mouse or focus movement, on control element blur (tab out), on playback start or entering fullscreen. As soon as the mouse is moved, a control element is focused or playback is paused, the controls reappear instantly. | | `disableContextMenu` | Boolean | `true` | Disable right click menu on video to <em>help</em> as very primitive obfuscation to prevent downloads of content. |
| `resetOnEnd` | Boolean | false | Reset the playback to the start once playback is complete. | | `hideControls` | Boolean | `true` | Hide video controls automatically after 2s of no mouse or focus movement, on control element blur (tab out), on playback start or entering fullscreen. As soon as the mouse is moved, a control element is focused or playback is paused, the controls reappear instantly. |
| `keyboard` | Object | `{ focused: true, global: false }` | Enable [keyboard shortcuts](#shortcuts) for focused players only or globally | | `resetOnEnd` | Boolean | false | Reset the playback to the start once playback is complete. |
| `tooltips` | Object | `{ controls: false, seek: true }` | `controls`: Display control labels as tooltips on `:hover` & `:focus` (by default, the labels are screen reader only). `seek`: Display a seek tooltip to indicate on click where the media would seek to. | | `keyboard` | Object | `{ focused: true, global: false }` | Enable [keyboard shortcuts](#shortcuts) for focused players only or globally |
| `duration` | Number | `null` | Specify a custom duration for media. | | `tooltips` | Object | `{ controls: false, seek: true }` | `controls`: Display control labels as tooltips on `:hover` & `:focus` (by default, the labels are screen reader only). `seek`: Display a seek tooltip to indicate on click where the media would seek to. |
| `displayDuration` | Boolean | `true` | Displays the duration of the media on the "metadataloaded" event (on startup) in the current time display. This will only work if the `preload` attribute is not set to `none` (or is not set at all) and you choose not to display the duration (see `controls` option). | | `duration` | Number | `null` | Specify a custom duration for media. |
| `invertTime` | Boolean | `true` | Display the current time as a countdown rather than an incremental counter. | | `displayDuration` | Boolean | `true` | Displays the duration of the media on the "metadataloaded" event (on startup) in the current time display. This will only work if the `preload` attribute is not set to `none` (or is not set at all) and you choose not to display the duration (see `controls` option). |
| `toggleInvert` | Boolean | `true` | Allow users to click to toggle the above. | | `invertTime` | Boolean | `true` | Display the current time as a countdown rather than an incremental counter. |
| `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. | | `toggleInvert` | Boolean | `true` | Allow users to click to toggle the above. |
| `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). | | `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. |
| `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. | | `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). |
| `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. | | `fullscreen` | Object | `{ enabled: true, fallback: true, iosNative: false, container: null }` | `enabled`: Toggles whether fullscreen should be enabled. `fallback`: Allow fallback to a full-window solution (`true`/`false`/`'force'`). `iosNative`: whether to use native iOS fullscreen when entering fullscreen (no custom controls) - note this has no effect on iPadOS. `container`: A selector for an ancestor of the player element, allows contextual content to remain visual in fullscreen mode. Non-ancestors are ignored. |
| `storage` | Object | `{ enabled: true, key: 'plyr' }` | `enabled`: Allow use of local storage to store user settings. `key`: The key name to use. | | `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. |
| `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. | | `storage` | Object | `{ enabled: true, key: 'plyr' }` | `enabled`: Allow use of local storage to store user settings. `key`: The key name to use. |
| `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. | | `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. |
| `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. | | `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. |
| `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. | | `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. |
| `urls` | Object | See source. | If you wish to override any API URLs then you can do so here. You can also set a custom download URL for the download button. | | `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. |
| `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` | | `urls` | Object | See source. | If you wish to override any API URLs then you can do so here. You can also set a custom download URL for the download button. |
| `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` | | `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` |
| `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. | | `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` |
| `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. | | `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. |
| `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. | | `mediaMetadata` | Object | `{ title: '', artist: '', album: '', artwork: [] }` | The [MediaMetadata](https://developer.mozilla.org/en-US/docs/Web/API/MediaMetadata) interface of the Media Session API allows a web page to provide rich media metadata for display in a platform UI. |
| `markers` | Object | `{ enabled: false, points: [] }` | `enabled`: Whether to enable markers. `points` is an array of `{ time: number; label: string; }` objects where `time` represents the marker position in seconds and `label` is the HTML string to be displayed. |
1. Vimeo only 1. Vimeo only
2. Autoplay is generally not recommended as it is seen as a negative user experience. It is also disabled in many browsers. Before raising issues, do your homework. More info can be found here: 2. Autoplay is generally not recommended as it is seen as a negative user experience. It is also disabled in many browsers. Before raising issues, do your homework. More info can be found here:
- https://webkit.org/blog/6784/new-video-policies-for-ios/ - <https://webkit.org/blog/6784/new-video-policies-for-ios/>
- https://developers.google.com/web/updates/2017/09/autoplay-policy-changes - <https://developers.google.com/web/updates/2017/09/autoplay-policy-changes>
- https://hacks.mozilla.org/2019/02/firefox-66-to-block-automatically-playing-audible-video-and-audio/ - <https://hacks.mozilla.org/2019/02/firefox-66-to-block-automatically-playing-audible-video-and-audio/>
3. YouTube does not support programatically toggling the native fullscreen player via it's API. This means on iOS you have two options, neither being perfect:
- Use the fallback/faux fullscreen option which covers the whole viewport (this is the default)
- Set `playsinline` to `false` and/or `fullscreen.iosNative` to `true` - either option hides the fullscreen toggle in the UI (because of the above API issue) and means iOS will play the video in it's native player.
# API # API
@ -431,7 +445,7 @@ There are methods, setters and getters on a Plyr object.
The easiest way to access the Plyr object is to set the return value from your call to the constructor to a variable. For example: The easiest way to access the Plyr object is to set the return value from your call to the constructor to a variable. For example:
```javascript ```js
const player = new Plyr('#player', { const player = new Plyr('#player', {
/* options */ /* options */
}); });
@ -439,7 +453,7 @@ const player = new Plyr('#player', {
You can also access the object through any events: You can also access the object through any events:
```javascript ```js
element.addEventListener('ready', (event) => { element.addEventListener('ready', (event) => {
const player = event.detail.plyr; const player = event.detail.plyr;
}); });
@ -449,7 +463,7 @@ element.addEventListener('ready', (event) => {
Example method use: Example method use:
```javascript ```js
player.play(); // Start playback player.play(); // Start playback
player.fullscreen.enter(); // Enter fullscreen player.fullscreen.enter(); // Enter fullscreen
``` ```
@ -478,20 +492,20 @@ player.fullscreen.enter(); // Enter fullscreen
| `supports(type)` | String | Check support for a mime type. | | `supports(type)` | String | Check support for a mime type. |
| `destroy()` | - | Destroy the instance and garbage collect any elements. | | `destroy()` | - | Destroy the instance and garbage collect any elements. |
1. For HTML5 players, `play()` will return a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) for most browsers - e.g. Chrome, Firefox, Opera, Safari and Edge [according to MDN](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/play) at time of writing. 1. For HTML5 players, `play()` will return a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) for most browsers - e.g. Chrome, Firefox, Opera, Safari and Edge [according to MDN](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/play) at time of writing.
## Getters and Setters ## Getters and Setters
Example setters: Example setters:
```javascript ```js
player.volume = 0.5; // Sets volume at 50% player.volume = 0.5; // Sets volume at 50%
player.currentTime = 10; // Seeks to 10 seconds player.currentTime = 10; // Seeks to 10 seconds
``` ```
Example getters: Example getters:
```javascript ```js
player.volume; // 0.5; player.volume; // 0.5;
player.currentTime; // 10 player.currentTime; // 10
player.fullscreen.active; // false; player.fullscreen.active; // false;
@ -527,7 +541,7 @@ player.fullscreen.active; // false;
| `ratio` | ✓ | ✓ | Gets or sets the video aspect ratio. The setter accepts a string in the same format as the `ratio` option. | | `ratio` | ✓ | ✓ | Gets or sets the video aspect ratio. The setter accepts a string in the same format as the `ratio` option. |
| `download` | ✓ | ✓ | Gets or sets the URL for the download button. The setter accepts a string containing a valid absolute URL. | | `download` | ✓ | ✓ | Gets or sets the URL for the download button. The setter accepts a string containing a valid absolute URL. |
1. HTML5 only 1. HTML5 only
### The `.source` setter ### The `.source` setter
@ -535,7 +549,7 @@ This allows changing the player source and type on the fly.
Video example: Video example:
```javascript ```js
player.source = { player.source = {
type: 'video', type: 'video',
title: 'Example title', title: 'Example title',
@ -575,7 +589,7 @@ player.source = {
Audio example: Audio example:
```javascript ```js
player.source = { player.source = {
type: 'audio', type: 'audio',
title: 'Example title', title: 'Example title',
@ -594,7 +608,7 @@ player.source = {
YouTube example: YouTube example:
```javascript ```js
player.source = { player.source = {
type: 'video', type: 'video',
sources: [ sources: [
@ -608,12 +622,12 @@ player.source = {
Vimeo example Vimeo example
```javascript ```js
player.source = { player.source = {
type: 'video', type: 'video',
sources: [ sources: [
{ {
src: '143418951', src: '76979871',
provider: 'vimeo', provider: 'vimeo',
}, },
], ],
@ -631,7 +645,7 @@ _Note:_ `src` property for YouTube and Vimeo can either be the video ID or the w
| `tracks`&sup1; | String | An array of track objects. Each element in the array is mapped directly to a track element and any keys mapped directly to HTML attributes so as in the example above, it will render as `<track kind="captions" label="English" srclang="en" src="https://cdn.selz.com/plyr/1.0/example_captions_en.vtt" default>` and similar for the French version. Booleans are converted to HTML5 value-less attributes. | | `tracks`&sup1; | String | An array of track objects. Each element in the array is mapped directly to a track element and any keys mapped directly to HTML attributes so as in the example above, it will render as `<track kind="captions" label="English" srclang="en" src="https://cdn.selz.com/plyr/1.0/example_captions_en.vtt" default>` and similar for the French version. Booleans are converted to HTML5 value-less attributes. |
| `previewThumbnails`&sup1; | Object | The same object like in the `previewThumbnails` constructor option. This means you can either change the thumbnails vtt via the `src` key or disable the thumbnails plugin for the next video by passing `{ enabled: false }`. | | `previewThumbnails`&sup1; | Object | The same object like in the `previewThumbnails` constructor option. This means you can either change the thumbnails vtt via the `src` key or disable the thumbnails plugin for the next video by passing `{ enabled: false }`. |
1. HTML5 only 1. HTML5 only
# Events # Events
@ -639,7 +653,7 @@ You can listen for events on the target element you setup Plyr on (see example u
reference to the instance, you can use the `on()` API method or `addEventListener()`. Access to the API can be obtained this way through the `event.detail.plyr` reference to the instance, you can use the `on()` API method or `addEventListener()`. Access to the API can be obtained this way through the `event.detail.plyr`
property. Here's an example: property. Here's an example:
```javascript ```js
player.on('ready', (event) => { player.on('ready', (event) => {
const instance = event.detail.plyr; const instance = event.detail.plyr;
}); });
@ -749,9 +763,9 @@ Plyr supports the last 2 versions of most _modern_ browsers.
| IE11 | ✓&sup3; | | IE11 | ✓&sup3; |
| IE10 | ✓<sup>2,3</sup> | | IE10 | ✓<sup>2,3</sup> |
1. Mobile Safari on the iPhone forces the native player for `<video>` unless the `playsinline` attribute is present. Volume controls are also disabled as they are handled device wide. 1. Mobile Safari on the iPhone forces the native player for `<video>` unless the `playsinline` attribute is present. Volume controls are also disabled as they are handled device wide.
2. Native player used (no support for `<progress>` or `<input type="range">`) but the API is supported. No native fullscreen support, fallback can be used (see [options](#options)). 2. Native player used (no support for `<progress>` or `<input type="range">`) but the API is supported. No native fullscreen support, fallback can be used (see [options](#options)).
3. Polyfills required. See below. 3. Polyfills required. See below.
## Polyfills ## Polyfills
@ -761,21 +775,20 @@ Plyr uses ES6 which isn't supported in all browsers quite yet. This means some f
You can use the static method to check for support. For example You can use the static method to check for support. For example
```javascript ```js
const supported = Plyr.supported('video', 'html5', true); const supported = Plyr.supported('video', 'html5');
``` ```
The arguments are: The arguments are:
- Media type (`audio` or `video`) - Media type (`'audio' | 'video'`)
- Provider (`html5`, `youtube` or `vimeo`) - Provider (`'html5' | 'youtube' | 'vimeo'`)
- Whether the player has the `playsinline` attribute (only applicable to iOS 10+)
## Disable support programmatically ## Disable support programmatically
The `enabled` option can be used to disable certain User Agents. For example, if you don't want to use Plyr for smartphones, you could use: The `enabled` option can be used to disable certain User Agents. For example, if you don't want to use Plyr for smartphones, you could use:
```javascript ```js
{ {
enabled: !/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent); enabled: !/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent);
} }
@ -846,6 +859,7 @@ Plyr costs money to run, not only my time. I donate my time for free as I enjoy
- [STROLLÿN: Work with a View](https://strollyn.com) - [STROLLÿN: Work with a View](https://strollyn.com)
- [CFDA Runway360](https://runway360.cfda.com/) - [CFDA Runway360](https://runway360.cfda.com/)
- [NKLAV | Filmmaker](https://nklav.com) - [NKLAV | Filmmaker](https://nklav.com)
- [GDI.JS.ORG - Google Drive Index](https://gitlab.com/GoogleDriveIndex/Google-Drive-Index)
If you want to be added to the list, open a pull request. It'd be awesome to see how you're using Plyr 😎 If you want to be added to the list, open a pull request. It'd be awesome to see how you're using Plyr 😎
@ -856,13 +870,8 @@ If you want to be added to the list, open a pull request. It'd be awesome to see
# Thanks # Thanks
[![Fastly](https://cdn.plyr.io/static/fastly-logo.png)](https://www.fastly.com/) - [Cloudflare](https://www.cloudflare.com/) and [Fastly](https://www.fastly.com/) for providing the CDN services.
- [Sentry](https://sentry.io/) for error logging service on the demo website.
Massive thanks to [Fastly](https://www.fastly.com/) for providing the CDN services.
[![Sentry](https://cdn.plyr.io/static/sentry-logo-black.svg)](https://sentry.io/)
Massive thanks to [Sentry](https://sentry.io/) for providing the logging services for the demo site.
## Contributors ## Contributors

View File

@ -1,12 +1,8 @@
{ {
"version": "0.2", "version": "0.2",
"ignorePaths": [ "ignorePaths": ["package.json", "dist/*", "demo/node_modules/*"],
"package.json",
"dist/*",
"demo/node_modules/*"
],
"dictionaryDefinitions": [], "dictionaryDefinitions": [],
"dictionaries": [], "dictionaries": ["en-gb", "softwareTerms", "html", "css", "typescript"],
"words": [ "words": [
"autopause", "autopause",
"autoplay", "autoplay",

View File

@ -1,6 +1,6 @@
{ {
"name": "plyr", "name": "plyr",
"version": "3.7.1", "version": "3.7.5",
"description": "A simple, accessible and customizable HTML5, YouTube and Vimeo media player", "description": "A simple, accessible and customizable HTML5, YouTube and Vimeo media player",
"homepage": "https://plyr.io", "homepage": "https://plyr.io",
"author": "Sam Potts <sam@potts.es>", "author": "Sam Potts <sam@potts.es>",
@ -30,28 +30,30 @@
}, },
"browserslist": "> 1%", "browserslist": "> 1%",
"scripts": { "scripts": {
"postinstall": "npm run build",
"build": "gulp build", "build": "gulp build",
"lint": "eslint src/js && npm run remark && stylelint **/*.scss", "lint": "eslint src/js && npm run remark && stylelint **/*.scss",
"lint:fix": "eslint --fix src/js && stylelint **/*.scss --fix", "lint:fix": "eslint --fix src/js && stylelint **/*.scss --fix",
"remark": "remark -f --use 'validate-links=repository:\"sampotts/plyr\"' '{,!(node_modules),.?**/}*.md'", "remark": "remark -f --use 'validate-links=repository:\"sampotts/plyr\"' '{,!(node_modules),.?**/}*.md'",
"deploy": "yarn lint && gulp version && gulp build && gulp deploy", "deploy": "npm run lint && gulp version && gulp build && gulp deploy",
"format": "prettier --write \"./{src,demo/src}/**/*.{js,scss}\"", "format": "prettier --write \"./{src,demo/src}/**/*.{js,scss}\"",
"spellcheck": "cspell \"**/*.{js,md,scss,json}\" --no-must-find-files", "spellcheck": "cspell \"**/*.{js,md,scss,json}\" --no-must-find-files",
"start": "gulp" "start": "gulp"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.17.9", "@babel/core": "^7.20.2",
"@babel/plugin-proposal-class-properties": "^7.16.7", "@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/preset-env": "^7.16.11", "@babel/plugin-proposal-optional-chaining": "^7.18.9",
"@babel/preset-env": "^7.20.2",
"@sampotts/eslint-config": "1.1.7", "@sampotts/eslint-config": "1.1.7",
"autoprefixer": "^10.4.4", "autoprefixer": "^10.4.13",
"aws-sdk": "^2.1116.0", "aws-sdk": "^2.1256.0",
"babel-eslint": "^10.1.0", "babel-eslint": "^10.1.0",
"browser-sync": "^2.27.9", "browser-sync": "^2.27.10",
"colorette": "2.0.16", "colorette": "2.0.19",
"cspell": "^5.19.7", "cspell": "^6.14.2",
"cssnano": "^5.1.7", "cssnano": "^5.1.14",
"del": "^6.0.0", "del": "^6.1.1",
"eslint": "^7.23.0", "eslint": "^7.23.0",
"fancy-log": "^2.0.0", "fancy-log": "^2.0.0",
"git-branch": "^2.0.1", "git-branch": "^2.0.1",
@ -73,25 +75,25 @@
"gulp-sourcemaps": "^3.0.0", "gulp-sourcemaps": "^3.0.0",
"gulp-svgstore": "^9.0.0", "gulp-svgstore": "^9.0.0",
"gulp-terser": "^2.1.0", "gulp-terser": "^2.1.0",
"postcss": "^8.4.12", "postcss": "^8.4.19",
"postcss-custom-properties": "^12.1.7", "postcss-custom-properties": "^12.1.9",
"postcss-scss": "^4.0.3", "postcss-scss": "^4.0.5",
"prettier-eslint": "^12.0.0", "prettier-eslint": "^12.0.0",
"prettier-stylelint": "^0.4.2", "prettier-stylelint": "^0.4.2",
"remark-cli": "^10.0.1", "remark-cli": "^11.0.0",
"remark-validate-links": "^11.0.2", "remark-validate-links": "^12.1.0",
"rollup": "^2.70.2", "rollup": "^3.3.0",
"rollup-plugin-babel": "^4.4.0", "rollup-plugin-babel": "^4.4.0",
"rollup-plugin-commonjs": "^10.1.0", "rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-node-resolve": "^5.2.0", "rollup-plugin-node-resolve": "^5.2.0",
"sass": "^1.50.0", "sass": "^1.56.1",
"stylelint": "^14.7.1", "stylelint": "^14.15.0",
"stylelint-config-prettier": "^9.0.3", "stylelint-config-prettier": "^9.0.4",
"stylelint-config-sass-guidelines": "^9.0.1", "stylelint-config-sass-guidelines": "^9.0.1",
"stylelint-selector-bem-pattern": "^2.1.1" "stylelint-selector-bem-pattern": "^2.1.1"
}, },
"dependencies": { "dependencies": {
"core-js": "^3.22.0", "core-js": "^3.26.1",
"custom-event-polyfill": "^1.0.7", "custom-event-polyfill": "^1.0.7",
"loadjs": "^4.2.0", "loadjs": "^4.2.0",
"rangetouch": "^2.0.1", "rangetouch": "^2.0.1",

13882
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -47,6 +47,7 @@ const captions = {
// Inject the container // Inject the container
if (!is.element(this.elements.captions)) { if (!is.element(this.elements.captions)) {
this.elements.captions = createElement('div', getAttributesFromSelector(this.config.selectors.captions)); this.elements.captions = createElement('div', getAttributesFromSelector(this.config.selectors.captions));
this.elements.captions.setAttribute('dir', 'auto');
insertAfter(this.elements.captions, this.elements.wrapper); insertAfter(this.elements.captions, this.elements.wrapper);
} }

View File

@ -18,8 +18,7 @@ const defaults = {
// Only allow one media playing at once (vimeo only) // Only allow one media playing at once (vimeo only)
autopause: true, autopause: true,
// Allow inline playback on iOS (this effects YouTube/Vimeo - HTML5 requires the attribute present) // Allow inline playback on iOS
// TODO: Remove iosNative fullscreen option in favour of this (logic needs work)
playsinline: true, playsinline: true,
// Default time to skip when rewind/fast forward // Default time to skip when rewind/fast forward
@ -61,7 +60,7 @@ const defaults = {
// Sprite (for icons) // Sprite (for icons)
loadSprite: true, loadSprite: true,
iconPrefix: 'plyr', iconPrefix: 'plyr',
iconUrl: 'https://cdn.plyr.io/3.7.1/plyr.svg', iconUrl: 'https://cdn.plyr.io/3.7.5/plyr.svg',
// Blank video (used to prevent errors on source change) // Blank video (used to prevent errors on source change)
blankVideo: 'https://cdn.plyr.io/static/blank.mp4', blankVideo: 'https://cdn.plyr.io/static/blank.mp4',
@ -353,7 +352,6 @@ const defaults = {
marker: 'plyr__progress__marker', marker: 'plyr__progress__marker',
hidden: 'plyr__sr-only', hidden: 'plyr__sr-only',
hideControls: 'plyr--hide-controls', hideControls: 'plyr--hide-controls',
isIos: 'plyr--is-ios',
isTouch: 'plyr--is-touch', isTouch: 'plyr--is-touch',
uiSupported: 'plyr--full-ui', uiSupported: 'plyr--full-ui',
noTransition: 'plyr--no-transition', noTransition: 'plyr--no-transition',

16
src/js/controls.js vendored
View File

@ -404,7 +404,7 @@ const controls = {
'keydown keyup', 'keydown keyup',
(event) => { (event) => {
// We only care about space and ⬆️ ⬇️️ ➡️ // We only care about space and ⬆️ ⬇️️ ➡️
if (!['Space', 'ArrowUp', 'ArrowDown', 'ArrowRight'].includes(event.key)) { if (![' ', 'ArrowUp', 'ArrowDown', 'ArrowRight'].includes(event.key)) {
return; return;
} }
@ -420,12 +420,12 @@ const controls = {
const isRadioButton = matches(menuItem, '[role="menuitemradio"]'); const isRadioButton = matches(menuItem, '[role="menuitemradio"]');
// Show the respective menu // Show the respective menu
if (!isRadioButton && ['Space', 'ArrowRight'].includes(event.key)) { if (!isRadioButton && [' ', 'ArrowRight'].includes(event.key)) {
controls.showMenuPanel.call(this, type, true); controls.showMenuPanel.call(this, type, true);
} else { } else {
let target; let target;
if (event.key !== 'Space') { if (event.key !== ' ') {
if (event.key === 'ArrowDown' || (isRadioButton && event.key === 'ArrowRight')) { if (event.key === 'ArrowDown' || (isRadioButton && event.key === 'ArrowRight')) {
target = menuItem.nextElementSibling; target = menuItem.nextElementSibling;
@ -504,7 +504,7 @@ const controls = {
menuItem, menuItem,
'click keyup', 'click keyup',
(event) => { (event) => {
if (is.keyboardEvent(event) && event.key !== 'Space') { if (is.keyboardEvent(event) && event.key !== ' ') {
return; return;
} }
@ -676,7 +676,7 @@ const controls = {
} }
// WebKit only // WebKit only
if (!browser.isWebkit) { if (!browser.isWebKit && !browser.isIPadOS) {
return; return;
} }
@ -1385,7 +1385,7 @@ const controls = {
// Volume range control // Volume range control
// Ignored on iOS as it's handled globally // Ignored on iOS as it's handled globally
// https://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/Using_HTML5_Audio_Video/Device-SpecificConsiderations/Device-SpecificConsiderations.html // https://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/Using_HTML5_Audio_Video/Device-SpecificConsiderations/Device-SpecificConsiderations.html
if (control === 'volume' && !browser.isIos) { if (control === 'volume' && !browser.isIos && !browser.isIPadOS) {
// Set the attributes // Set the attributes
const attributes = { const attributes = {
max: 1, max: 1,
@ -1715,13 +1715,17 @@ const controls = {
if (!is.empty(this.elements.buttons)) { if (!is.empty(this.elements.buttons)) {
const addProperty = (button) => { const addProperty = (button) => {
const className = this.config.classNames.controlPressed; const className = this.config.classNames.controlPressed;
button.setAttribute('aria-pressed', 'false');
Object.defineProperty(button, 'pressed', { Object.defineProperty(button, 'pressed', {
configurable: true,
enumerable: true, enumerable: true,
get() { get() {
return hasClass(button, className); return hasClass(button, className);
}, },
set(pressed = false) { set(pressed = false) {
toggleClass(button, className, pressed); toggleClass(button, className, pressed);
button.setAttribute('aria-pressed', pressed ? 'true' : 'false');
}, },
}); });
}; };

View File

@ -57,12 +57,10 @@ class Fullscreen {
// Update the UI // Update the UI
this.update(); this.update();
// this.toggle = this.toggle.bind(this);
} }
// Determine if native supported // Determine if native supported
static get native() { static get nativeSupported() {
return !!( return !!(
document.fullscreenEnabled || document.fullscreenEnabled ||
document.webkitFullscreenEnabled || document.webkitFullscreenEnabled ||
@ -72,16 +70,14 @@ class Fullscreen {
} }
// If we're actually using native // If we're actually using native
get usingNative() { get useNative() {
return Fullscreen.native && !this.forceFallback; return Fullscreen.nativeSupported && !this.forceFallback;
} }
// Get the prefix for handlers // Get the prefix for handlers
static get prefix() { static get prefix() {
// No prefix // No prefix
if (is.function(document.exitFullscreen)) { if (is.function(document.exitFullscreen)) return '';
return '';
}
// Check for fullscreen support by vendor prefix // Check for fullscreen support by vendor prefix
let value = ''; let value = '';
@ -103,24 +99,30 @@ class Fullscreen {
return this.prefix === 'moz' ? 'FullScreen' : 'Fullscreen'; return this.prefix === 'moz' ? 'FullScreen' : 'Fullscreen';
} }
// Determine if fullscreen is enabled // Determine if fullscreen is supported
get enabled() { get supported() {
return ( return [
(Fullscreen.native || this.player.config.fullscreen.fallback) && // Fullscreen is enabled in config
this.player.config.fullscreen.enabled && this.player.config.fullscreen.enabled,
this.player.supported.ui && // Must be a video
this.player.isVideo this.player.isVideo,
); // Either native is supported or fallback enabled
Fullscreen.nativeSupported || this.player.config.fullscreen.fallback,
// YouTube has no way to trigger fullscreen, so on devices with no native support, playsinline
// must be enabled and iosNative fullscreen must be disabled to offer the fullscreen fallback
!this.player.isYouTube ||
Fullscreen.nativeSupported ||
!browser.isIos ||
(this.player.config.playsinline && !this.player.config.fullscreen.iosNative),
].every(Boolean);
} }
// Get active state // Get active state
get active() { get active() {
if (!this.enabled) { if (!this.supported) return false;
return false;
}
// Fallback using classname // Fallback using classname
if (!Fullscreen.native || this.forceFallback) { if (!Fullscreen.nativeSupported || this.forceFallback) {
return hasClass(this.target, this.player.config.classNames.fullscreen.fallback); return hasClass(this.target, this.player.config.classNames.fullscreen.fallback);
} }
@ -135,13 +137,11 @@ class Fullscreen {
get target() { get target() {
return browser.isIos && this.player.config.fullscreen.iosNative return browser.isIos && this.player.config.fullscreen.iosNative
? this.player.media ? this.player.media
: this.player.elements.fullscreen || this.player.elements.container; : this.player.elements.fullscreen ?? this.player.elements.container;
} }
onChange = () => { onChange = () => {
if (!this.enabled) { if (!this.supported) return;
return;
}
// Update toggle button // Update toggle button
const button = this.player.elements.buttons.fullscreen; const button = this.player.elements.buttons.fullscreen;
@ -159,8 +159,8 @@ class Fullscreen {
// Store or restore scroll position // Store or restore scroll position
if (toggle) { if (toggle) {
this.scrollPosition = { this.scrollPosition = {
x: window.scrollX || 0, x: window.scrollX ?? 0,
y: window.scrollY || 0, y: window.scrollY ?? 0,
}; };
} else { } else {
window.scrollTo(this.scrollPosition.x, this.scrollPosition.y); window.scrollTo(this.scrollPosition.x, this.scrollPosition.y);
@ -188,10 +188,7 @@ class Fullscreen {
if (toggle) { if (toggle) {
this.cleanupViewport = !hasProperty; this.cleanupViewport = !hasProperty;
if (!hasProperty) viewport.content += `,${property}`;
if (!hasProperty) {
viewport.content += `,${property}`;
}
} else if (this.cleanupViewport) { } else if (this.cleanupViewport) {
viewport.content = viewport.content viewport.content = viewport.content
.split(',') .split(',')
@ -206,10 +203,8 @@ class Fullscreen {
// Trap focus inside container // Trap focus inside container
trapFocus = (event) => { trapFocus = (event) => {
// Bail if iOS, not active, not the tab key // Bail if iOS/iPadOS, not active, not the tab key
if (browser.isIos || !this.active || event.key !== 'Tab') { if (browser.isIos || browser.isIPadOS || !this.active || event.key !== 'Tab') return;
return;
}
// Get the current focused element // Get the current focused element
const focused = document.activeElement; const focused = document.activeElement;
@ -230,16 +225,12 @@ class Fullscreen {
// Update UI // Update UI
update = () => { update = () => {
if (this.enabled) { if (this.supported) {
let mode; let mode;
if (this.forceFallback) { if (this.forceFallback) mode = 'Fallback (forced)';
mode = 'Fallback (forced)'; else if (Fullscreen.nativeSupported) mode = 'Native';
} else if (Fullscreen.native) { else mode = 'Fallback';
mode = 'Native';
} else {
mode = 'Fallback';
}
this.player.debug.log(`${mode} fullscreen enabled`); this.player.debug.log(`${mode} fullscreen enabled`);
} else { } else {
@ -247,14 +238,12 @@ class Fullscreen {
} }
// Add styling hook to show button // Add styling hook to show button
toggleClass(this.player.elements.container, this.player.config.classNames.fullscreen.enabled, this.enabled); toggleClass(this.player.elements.container, this.player.config.classNames.fullscreen.enabled, this.supported);
}; };
// Make an element fullscreen // Make an element fullscreen
enter = () => { enter = () => {
if (!this.enabled) { if (!this.supported) return;
return;
}
// iOS native fullscreen doesn't need the request step // iOS native fullscreen doesn't need the request step
if (browser.isIos && this.player.config.fullscreen.iosNative) { if (browser.isIos && this.player.config.fullscreen.iosNative) {
@ -263,7 +252,7 @@ class Fullscreen {
} else { } else {
this.target.webkitEnterFullscreen(); this.target.webkitEnterFullscreen();
} }
} else if (!Fullscreen.native || this.forceFallback) { } else if (!Fullscreen.nativeSupported || this.forceFallback) {
this.toggleFallback(true); this.toggleFallback(true);
} else if (!this.prefix) { } else if (!this.prefix) {
this.target.requestFullscreen({ navigationUI: 'hide' }); this.target.requestFullscreen({ navigationUI: 'hide' });
@ -274,15 +263,17 @@ class Fullscreen {
// Bail from fullscreen // Bail from fullscreen
exit = () => { exit = () => {
if (!this.enabled) { if (!this.supported) return;
return;
}
// iOS native fullscreen // iOS native fullscreen
if (browser.isIos && this.player.config.fullscreen.iosNative) { if (browser.isIos && this.player.config.fullscreen.iosNative) {
this.target.webkitExitFullscreen(); if (this.player.isVimeo) {
this.player.embed.exitFullscreen();
} else {
this.target.webkitEnterFullscreen();
}
silencePromise(this.player.play()); silencePromise(this.player.play());
} else if (!Fullscreen.native || this.forceFallback) { } else if (!Fullscreen.nativeSupported || this.forceFallback) {
this.toggleFallback(false); this.toggleFallback(false);
} else if (!this.prefix) { } else if (!this.prefix) {
(document.cancelFullScreen || document.exitFullscreen).call(document); (document.cancelFullScreen || document.exitFullscreen).call(document);
@ -294,11 +285,8 @@ class Fullscreen {
// Toggle state // Toggle state
toggle = () => { toggle = () => {
if (!this.active) { if (!this.active) this.enter();
this.enter(); else this.exit();
} else {
this.exit();
}
}; };
} }

View File

@ -65,14 +65,14 @@ class Listeners {
return; return;
} }
if (event.key === 'Space' && matches(focused, 'button, [role^="menuitem"]')) { if (event.key === ' ' && matches(focused, 'button, [role^="menuitem"]')) {
return; return;
} }
} }
// Which keys should we prevent default // Which keys should we prevent default
const preventDefault = [ const preventDefault = [
'Space', ' ',
'ArrowLeft', 'ArrowLeft',
'ArrowUp', 'ArrowUp',
'ArrowRight', 'ArrowRight',
@ -118,7 +118,7 @@ class Listeners {
} }
break; break;
case 'Space': case ' ':
case 'k': case 'k':
if (!repeat) { if (!repeat) {
silencePromise(player.togglePlay()); silencePromise(player.togglePlay());
@ -663,7 +663,7 @@ class Listeners {
elements.buttons.settings, elements.buttons.settings,
'keyup', 'keyup',
(event) => { (event) => {
if (!['Space', 'Enter'].includes(event.key)) { if (![' ', 'Enter'].includes(event.key)) {
return; return;
} }
@ -797,7 +797,7 @@ class Listeners {
}); });
// Polyfill for lower fill in <input type="range"> for webkit // Polyfill for lower fill in <input type="range"> for webkit
if (browser.isWebkit) { if (browser.isWebKit) {
Array.from(getElements.call(player, 'input[type="range"]')).forEach((element) => { Array.from(getElements.call(player, 'input[type="range"]')).forEach((element) => {
this.bind(element, 'input', (event) => controls.updateRangeFill.call(player, event.target)); this.bind(element, 'input', (event) => controls.updateRangeFill.call(player, event.target));
}); });

View File

@ -123,6 +123,9 @@ class PreviewThumbnails {
// Check to see if thumb container size was specified manually in CSS // Check to see if thumb container size was specified manually in CSS
this.determineContainerAutoSizing(); this.determineContainerAutoSizing();
// Set up listeners
this.listeners();
this.loaded = true; this.loaded = true;
}); });
}; };

View File

@ -113,7 +113,7 @@ const vimeo = {
autoplay: player.autoplay, autoplay: player.autoplay,
muted: player.muted, muted: player.muted,
gesture: 'media', gesture: 'media',
playsinline: !this.config.fullscreen.iosNative, playsinline: player.config.playsinline,
// hash has to be added to iframe-URL // hash has to be added to iframe-URL
...hashParam, ...hashParam,
...frameParams, ...frameParams,
@ -265,7 +265,7 @@ const vimeo = {
set(input) { set(input) {
const toggle = is.boolean(input) ? input : false; const toggle = is.boolean(input) ? input : false;
player.embed.setVolume(toggle ? 0 : player.config.volume).then(() => { player.embed.setMuted(toggle ? true : player.config.muted).then(() => {
muted = toggle; muted = toggle;
triggerEvent.call(player, player.media, 'volumechange'); triggerEvent.call(player, player.media, 'volumechange');
}); });

View File

@ -131,7 +131,7 @@ const youtube = {
const posterSrc = (s) => `https://i.ytimg.com/vi/${videoId}/${s}default.jpg`; const posterSrc = (s) => `https://i.ytimg.com/vi/${videoId}/${s}default.jpg`;
// Check thumbnail images in order of quality, but reject fallback thumbnails (120px wide) // Check thumbnail images in order of quality, but reject fallback thumbnails (120px wide)
loadImage(posterSrc('maxres'), 121) // Higest quality and unpadded loadImage(posterSrc('maxres'), 121) // Highest quality and un-padded
.catch(() => loadImage(posterSrc('sd'), 121)) // 480p padded 4:3 .catch(() => loadImage(posterSrc('sd'), 121)) // 480p padded 4:3
.catch(() => loadImage(posterSrc('hq'))) // 360p padded 4:3. Always exists .catch(() => loadImage(posterSrc('hq'))) // 360p padded 4:3. Always exists
.then((image) => ui.setPoster.call(player, image.src)) .then((image) => ui.setPoster.call(player, image.src))
@ -161,7 +161,7 @@ const youtube = {
// Disable keyboard as we handle it // Disable keyboard as we handle it
disablekb: 1, disablekb: 1,
// Allow iOS inline playback // Allow iOS inline playback
playsinline: !player.config.fullscreen.iosNative ? 1 : 0, playsinline: player.config.playsinline && !player.config.fullscreen.iosNative ? 1 : 0,
// Captions are flaky on YouTube // Captions are flaky on YouTube
cc_load_policy: player.captions.active ? 1 : 0, cc_load_policy: player.captions.active ? 1 : 0,
cc_lang_pref: player.config.captions.language, cc_lang_pref: player.config.captions.language,
@ -183,7 +183,7 @@ const youtube = {
100: 'The video requested was not found. This error occurs when a video has been removed (for any reason) or has been marked as private.', 100: 'The video requested was not found. This error occurs when a video has been removed (for any reason) or has been marked as private.',
101: 'The owner of the requested video does not allow it to be played in embedded players.', 101: 'The owner of the requested video does not allow it to be played in embedded players.',
150: 'The owner of the requested video does not allow it to be played in embedded players.', 150: 'The owner of the requested video does not allow it to be played in embedded players.',
}[code] || 'An unknown error occured'; }[code] || 'An unknown error occurred';
player.media.error = { code, message }; player.media.error = { code, message };

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

@ -341,7 +341,7 @@ declare namespace Plyr {
* id (the unique id for the player), seektime (the seektime step in seconds), and title (the media title). See CONTROLS.md for more info on how the html needs to be structured. * id (the unique id for the player), seektime (the seektime step in seconds), and title (the media title). See CONTROLS.md for more info on how the html needs to be structured.
* Defaults to ['play-large', 'play', 'progress', 'current-time', 'mute', 'volume', 'captions', 'settings', 'pip', 'airplay', 'fullscreen'] * Defaults to ['play-large', 'play', 'progress', 'current-time', 'mute', 'volume', 'captions', 'settings', 'pip', 'airplay', 'fullscreen']
*/ */
controls?: string[] | ((id: string, seektime: number, title: string) => unknown) | Element; controls?: string | string[] | ((id: string, seektime: number, title: string) => unknown) | Element;
/** /**
* If you're using the default controls are used then you can specify which settings to show in the menu * If you're using the default controls are used then you can specify which settings to show in the menu
@ -459,7 +459,7 @@ declare namespace Plyr {
* Allows binding of event listeners to the controls before the default handlers. See the defaults.js for available listeners. * Allows binding of event listeners to the controls before the default handlers. See the defaults.js for available listeners.
* If your handler prevents default on the event (event.preventDefault()), the default handler will not fire. * If your handler prevents default on the event (event.preventDefault()), the default handler will not fire.
*/ */
listeners?: {[key: string]: (error: PlyrEvent) => void}; listeners?: { [key: string]: (error: PlyrEvent) => void };
/** /**
* active: Toggles if captions should be active by default. language: Sets the default language to load (if available). 'auto' uses the browser language. * active: Toggles if captions should be active by default. language: Sets the default language to load (if available). 'auto' uses the browser language.
@ -606,7 +606,7 @@ declare namespace Plyr {
interface MarkersOptions { interface MarkersOptions {
enabled: boolean; enabled: boolean;
points: MarkersPoints[] points: MarkersPoints[];
} }
export interface Elements { export interface Elements {
@ -700,7 +700,7 @@ declare namespace Plyr {
} }
interface PlyrEvent extends CustomEvent { interface PlyrEvent extends CustomEvent {
readonly detail: {readonly plyr: Plyr}; readonly detail: { readonly plyr: Plyr };
} }
enum YoutubeState { enum YoutubeState {

View File

@ -1,6 +1,6 @@
// ========================================================================== // ==========================================================================
// Plyr // Plyr
// plyr.js v3.7.1 // plyr.js v3.7.5
// https://github.com/sampotts/plyr // https://github.com/sampotts/plyr
// License: The MIT License (MIT) // License: The MIT License (MIT)
// ========================================================================== // ==========================================================================
@ -246,7 +246,7 @@ class Plyr {
} }
// Check for support again but with type // Check for support again but with type
this.supported = support.check(this.type, this.provider, this.config.playsinline); this.supported = support.check(this.type, this.provider);
// If no support for even API, bail // If no support for even API, bail
if (!this.supported.api) { if (!this.supported.api) {
@ -1032,7 +1032,7 @@ class Plyr {
} }
/** /**
* Sets the preview thubmnails for the current source * Sets the preview thumbnails for the current source
*/ */
setPreviewThumbnails(thumbnailSource) { setPreviewThumbnails(thumbnailSource) {
if (this.previewThumbnails && this.previewThumbnails.loaded) { if (this.previewThumbnails && this.previewThumbnails.loaded) {
@ -1239,10 +1239,9 @@ class Plyr {
* Check for support * Check for support
* @param {String} type - Player type (audio/video) * @param {String} type - Player type (audio/video)
* @param {String} provider - Provider (html5/youtube/vimeo) * @param {String} provider - Provider (html5/youtube/vimeo)
* @param {Boolean} inline - Where player has `playsinline` sttribute
*/ */
static supported(type, provider, inline) { static supported(type, provider) {
return support.check(type, provider, inline); return support.check(type, provider);
} }
/** /**

View File

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

View File

@ -24,10 +24,9 @@ const support = {
// Check for support // Check for support
// Basic functionality vs full UI // Basic functionality vs full UI
check(type, provider, playsinline) { check(type, provider) {
const canPlayInline = browser.isIPhone && playsinline && support.playsinline;
const api = support[type] || provider !== 'html5'; const api = support[type] || provider !== 'html5';
const ui = api && support.rangeInput && (type !== 'video' || !browser.isIPhone || canPlayInline); const ui = api && support.rangeInput;
return { return {
api, api,
@ -38,6 +37,9 @@ const support = {
// Picture-in-picture support // Picture-in-picture support
// Safari & Chrome only currently // Safari & Chrome only currently
pip: (() => { pip: (() => {
// While iPhone's support picture-in-picture for some apps, seemingly Safari isn't one of them
// It will throw the following error when trying to enter picture-in-picture
// `NotSupportedError: The Picture-in-Picture mode is not supported.`
if (browser.isIPhone) { if (browser.isIPhone) {
return false; return false;
} }

View File

@ -5,7 +5,6 @@
import captions from './captions'; import captions from './captions';
import controls from './controls'; import controls from './controls';
import support from './support'; import support from './support';
import browser from './utils/browser';
import { getElement, toggleClass } from './utils/elements'; import { getElement, toggleClass } from './utils/elements';
import { ready, triggerEvent } from './utils/events'; import { ready, triggerEvent } from './utils/events';
import i18n from './utils/i18n'; import i18n from './utils/i18n';
@ -98,9 +97,6 @@ const ui = {
// Check for airplay support // Check for airplay support
toggleClass(this.elements.container, this.config.classNames.airplay.supported, support.airplay && this.isHTML5); toggleClass(this.elements.container, this.config.classNames.airplay.supported, support.airplay && this.isHTML5);
// Add iOS class
toggleClass(this.elements.container, this.config.classNames.isIos, browser.isIos);
// Add touch class // Add touch class
toggleClass(this.elements.container, this.config.classNames.isTouch, this.touch); toggleClass(this.elements.container, this.config.classNames.isTouch, this.touch);

View File

@ -3,14 +3,19 @@
// Unfortunately, due to mixed support, UA sniffing is required // Unfortunately, due to mixed support, UA sniffing is required
// ========================================================================== // ==========================================================================
const browser = { const isIE = Boolean(window.document.documentMode);
isIE: Boolean(window.document.documentMode), const isEdge = /Edge/g.test(navigator.userAgent);
isEdge: window.navigator.userAgent.includes('Edge'), const isWebKit = 'WebkitAppearance' in document.documentElement.style && !/Edge/g.test(navigator.userAgent);
isWebkit: 'WebkitAppearance' in document.documentElement.style && !/Edge/.test(navigator.userAgent), const isIPhone = /iPhone|iPod/gi.test(navigator.userAgent) && navigator.maxTouchPoints > 1;
isIPhone: /(iPhone|iPod)/gi.test(navigator.platform), // navigator.platform may be deprecated but this check is still required
isIos: const isIPadOS = navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1;
(navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1) || const isIos = /iPad|iPhone|iPod/gi.test(navigator.userAgent) && navigator.maxTouchPoints > 1;
/(iPad|iPhone|iPod)/gi.test(navigator.platform),
};
export default browser; export default {
isIE,
isEdge,
isWebKit,
isIPhone,
isIPadOS,
isIos,
};

View File

@ -67,7 +67,7 @@ export function createElement(type, attributes, text) {
return element; return element;
} }
// Inaert an element after another // Insert an element after another
export function insertAfter(element, target) { export function insertAfter(element, target) {
if (!is.element(element) || !is.element(target)) { if (!is.element(element) || !is.element(target)) {
return; return;

View File

@ -9,7 +9,7 @@ const isObject = (input) => getConstructor(input) === Object;
const isNumber = (input) => getConstructor(input) === Number && !Number.isNaN(input); const isNumber = (input) => getConstructor(input) === Number && !Number.isNaN(input);
const isString = (input) => getConstructor(input) === String; const isString = (input) => getConstructor(input) === String;
const isBoolean = (input) => getConstructor(input) === Boolean; const isBoolean = (input) => getConstructor(input) === Boolean;
const isFunction = (input) => getConstructor(input) === Function; const isFunction = (input) => typeof input === 'function';
const isArray = (input) => Array.isArray(input); const isArray = (input) => Array.isArray(input);
const isWeakMap = (input) => instanceOf(input, WeakMap); const isWeakMap = (input) => instanceOf(input, WeakMap);
const isNodeList = (input) => instanceOf(input, NodeList); const isNodeList = (input) => instanceOf(input, NodeList);

View File

@ -13,7 +13,7 @@ export function generateId(prefix) {
export function format(input, ...args) { export function format(input, ...args) {
if (is.empty(input)) return input; if (is.empty(input)) return input;
return input.toString().replace(/{(\d+)}/g, (match, i) => args[i].toString()); return input.toString().replace(/{(\d+)}/g, (_, i) => args[i].toString());
} }
// Get percentage // Get percentage

View File

@ -26,7 +26,7 @@
&__container { &__container {
animation: plyr-popup 0.2s ease; animation: plyr-popup 0.2s ease;
background: $plyr-menu-background; background: $plyr-menu-background;
border-radius: 4px; border-radius: $plyr-menu-radius;
bottom: 100%; bottom: 100%;
box-shadow: $plyr-menu-shadow; box-shadow: $plyr-menu-shadow;
color: $plyr-menu-color; color: $plyr-menu-color;
@ -192,7 +192,7 @@
align-items: center; align-items: center;
display: flex; display: flex;
margin-left: auto; margin-left: auto;
margin-right: calc((#{$plyr-control-padding} - 2) * -1); margin-right: calc((#{$plyr-control-padding} - 2px) * -1);
overflow: hidden; overflow: hidden;
padding-left: calc(#{$plyr-control-padding} * 3.5); padding-left: calc(#{$plyr-control-padding} * 3.5);
pointer-events: none; pointer-events: none;

View File

@ -27,7 +27,6 @@ $plyr-progress-offset: $plyr-range-thumb-height;
left: 0; left: 0;
max-width: 120px; max-width: 120px;
overflow-wrap: break-word; overflow-wrap: break-word;
white-space: normal;
} }
} }

View File

@ -5,21 +5,14 @@
.plyr__volume { .plyr__volume {
align-items: center; align-items: center;
display: flex; display: flex;
max-width: 110px;
min-width: 80px;
position: relative; position: relative;
width: 20%;
input[type='range'] { input[type='range'] {
margin-left: calc(#{$plyr-control-spacing} / 2); margin-left: calc(#{$plyr-control-spacing} / 2);
margin-right: calc(#{$plyr-control-spacing} / 2); margin-right: calc(#{$plyr-control-spacing} / 2);
max-width: 90px;
min-width: 60px;
position: relative; position: relative;
z-index: 2; z-index: 2;
} }
} }
// Auto size on iOS as there's no slider
.plyr--is-ios .plyr__volume {
min-width: 0;
width: auto;
}

View File

@ -11,7 +11,6 @@
@include plyr-fullscreen-active; @include plyr-fullscreen-active;
bottom: 0; bottom: 0;
display: block;
left: 0; left: 0;
position: fixed; position: fixed;
right: 0; right: 0;

View File

@ -118,7 +118,7 @@ Object.entries(build.js).forEach(([filename, entry]) => {
}, },
], ],
], ],
plugins: ['@babel/plugin-proposal-class-properties'], plugins: ['@babel/plugin-proposal-class-properties', '@babel/plugin-proposal-optional-chaining'],
babelrc: false, babelrc: false,
exclude: [/\/core-js\//], exclude: [/\/core-js\//],
}), }),

13416
yarn.lock

File diff suppressed because it is too large Load Diff