UNPKG

98.9 kBMarkdownView Raw
1| 🎉 | [Plyr is merging into Vidstack](https://github.com/sampotts/plyr/issues/2408) | 🎉 |
2| :-: | :---------------------------------------------------------------------------: | :-- |
3
4Plyr is a simple, lightweight, accessible and customizable HTML5, YouTube and Vimeo media player that supports [_modern_](#browser-support) browsers.
5
6[Checkout the demo](https://plyr.io) - [Donate](#donate) - [Slack](https://bit.ly/plyr--chat)
7
8[![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)
9
10[![Screenshot of Plyr](https://cdn.plyr.io/static/screenshot.webp)](https://plyr.io)
11
12# Features
13
14- 📼 **HTML Video & Audio, YouTube & Vimeo** - support for the major formats
15- 💪 **Accessible** - full support for VTT captions and screen readers
16- 🔧 **[Customizable](#html)** - make the player look how you want with the markup you want
17- 😎 **Clean HTML** - uses the _right_ elements. `<input type="range">` for volume and `<progress>` for progress and well, `<button>`s for buttons. There's no
18 `<span>` or `<a href="#">` button hacks
19- 📱 **Responsive** - works with any screen size
20- 💵 **[Monetization](#ads)** - make money from your videos
21- 📹 **[Streaming](#demos)** - support for hls.js, Shaka and dash.js streaming playback
22- 🎛 **[API](#api)** - toggle playback, volume, seeking, and more through a standardized API
23- 🎤 **[Events](#events)** - no messing around with Vimeo and YouTube APIs, all events are standardized across formats
24- 🔎 **[Fullscreen](#fullscreen)** - supports native fullscreen with fallback to "full window" modes
25- ⌨️ **[Shortcuts](#shortcuts)** - supports keyboard shortcuts
26- 🖥 **Picture-in-Picture** - supports picture-in-picture mode
27- 📱 **Playsinline** - supports the `playsinline` attribute
28- 🏎 **Speed controls** - adjust speed on the fly
29- 📖 **Multiple captions** - support for multiple caption tracks
30- 🌎 **i18n support** - support for internationalization of controls
31- 👌 **[Preview thumbnails](#preview-thumbnails)** - support for displaying preview thumbnails
32- 🤟 **No frameworks** - written in "vanilla" ES6 JavaScript, no jQuery required
33- 💁‍♀️ **Sass** - to include in your build processes
34
35## Demos
36
37You 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)
38
39# Quick setup
40
41## HTML
42
43Plyr extends upon the standard [HTML5 media element](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement) markup so that's all you need for those types.
44
45### HTML5 Video
46
47```html
48<video id="player" playsinline controls data-poster="/path/to/poster.jpg">
49 <source src="/path/to/video.mp4" type="video/mp4" />
50 <source src="/path/to/video.webm" type="video/webm" />
51
52 <!-- Captions are optional -->
53 <track kind="captions" label="English captions" src="/path/to/captions.vtt" srclang="en" default />
54</video>
55```
56
57**Note**: The poster image should be specified using `data-poster`. This is to prevent it [being downloaded twice](https://github.com/sampotts/plyr/issues/1531). If you're sure the image will be cached, you can still use the `poster` attribute for true progressive enhancement.
58
59### HTML5 Audio
60
61```html
62<audio id="player" controls>
63 <source src="/path/to/audio.mp3" type="audio/mp3" />
64 <source src="/path/to/audio.ogg" type="audio/ogg" />
65</audio>
66```
67
68For YouTube and Vimeo players, Plyr uses progressive enhancement to enhance the default `<iframe>` embeds. Below are some examples. The `plyr__video-embed` classname will make the embed responsive. You can add the `autoplay`, `loop`, `hl` (YouTube only) and `playsinline` (YouTube only) query parameters to the URL and they will be set as config options automatically. For YouTube, the `origin` should be updated to reflect the domain you're hosting the embed on, or you can opt to omit it.
69
70### YouTube
71
72We recommend [progressive enhancement](https://www.smashingmagazine.com/2009/04/progressive-enhancement-what-it-is-and-how-to-use-it/) with the embedded players. You can elect to use an `<iframe>` as the source element (which Plyr will progressively enhance) or a bog standard `<div>` with two essential data attributes - `data-plyr-provider` and `data-plyr-embed-id`.
73
74```html
75<div class="plyr__video-embed" id="player">
76 <iframe
77 src="https://www.youtube.com/embed/bTqVqk7FSmY?origin=https://plyr.io&amp;iv_load_policy=3&amp;modestbranding=1&amp;playsinline=1&amp;showinfo=0&amp;rel=0&amp;enablejsapi=1"
78 allowfullscreen
79 allowtransparency
80 allow="autoplay"
81 ></iframe>
82</div>
83```
84
85_Note_: The `plyr__video-embed` classname will make the player a responsive 16:9 (most common) iframe embed. When plyr itself kicks in, your custom `ratio` config option will be used.
86
87Or the `<div>` non progressively enhanced method:
88
89```html
90<div id="player" data-plyr-provider="youtube" data-plyr-embed-id="bTqVqk7FSmY"></div>
91```
92
93_Note_: The `data-plyr-embed-id` can either be the video ID or URL for the media.
94
95### Vimeo
96
97Much the same as YouTube above.
98
99```html
100<div class="plyr__video-embed" id="player">
101 <iframe
102 src="https://player.vimeo.com/video/76979871?loop=false&amp;byline=false&amp;portrait=false&amp;title=false&amp;speed=true&amp;transparent=0&amp;gesture=media"
103 allowfullscreen
104 allowtransparency
105 allow="autoplay"
106 ></iframe>
107</div>
108```
109
110Or the `<div>` non progressively enhanced method:
111
112```html
113<div id="player" data-plyr-provider="vimeo" data-plyr-embed-id="76979871"></div>
114```
115
116## JavaScript
117
118You can use Plyr as an ES6 module as follows:
119
120```js
121import Plyr from 'plyr';
122
123const player = new Plyr('#player');
124```
125
126Alternatively you can include the `plyr.js` script before the closing `</body>` tag and then in your JS create a new instance of Plyr as below.
127
128```html
129<script src="path/to/plyr.js"></script>
130<script>
131 const player = new Plyr('#player');
132</script>
133```
134
135See [initialising](#initializing) for more information on advanced setups.
136
137You 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.
138
139```html
140<script src="https://cdn.plyr.io/3.7.8/plyr.js"></script>
141```
142
143...or...
144
145```html
146<script src="https://cdn.plyr.io/3.7.8/plyr.polyfilled.js"></script>
147```
148
149## CSS
150
151Include the `plyr.css` stylesheet into your `<head>`.
152
153```html
154<link rel="stylesheet" href="path/to/plyr.css" />
155```
156
157If you want to use our CDN (provided by [Cloudflare](https://www.cloudflare.com/)) for the default CSS, you can use the following:
158
159```html
160<link rel="stylesheet" href="https://cdn.plyr.io/3.7.8/plyr.css" />
161```
162
163## SVG Sprite
164
165The SVG sprite is loaded automatically from our CDN (provided by [Cloudflare](https://www.cloudflare.com/)). To change this, see the [options](#options) below. For
166reference, the CDN hosted SVG sprite can be found at `https://cdn.plyr.io/3.7.8/plyr.svg`.
167
168### Self hosting
169
170If 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:
171
172- Download the files from the CDN links above, they're already minified.
173- Download the files from [unpkg](https://unpkg.com/browse/plyr/dist/) or similar services.
174- Build the project yourself using `npm i && npm run build`, which installs the dependencies and spits out a build to `dist`.
175
176# Ads
177
178Plyr has partnered up with [vi.ai](https://vi.ai/publisher-video-monetization/?aid=plyrio) to offer monetization options for your videos. Getting setup is easy:
179
180- [Sign up for a vi.ai account](https://vi.ai/publisher-video-monetization/?aid=plyrio)
181- Grab your publisher ID from the code snippet
182- Enable ads in the [config options](#options) and enter your publisher ID
183
184Any questions regarding the ads can be sent straight to vi.ai and any issues with rendering raised through GitHub issues.
185
186If you do not wish to use Vi, you can set your own `ads.tagUrl` [option](#options).
187
188# Advanced
189
190## Customizing the CSS
191
192If you want to change any design tokens used for the rendering of the player, you can do so using [CSS Custom Properties](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties).
193
194Here's a list of the properties and what they are used for:
195
196| Name | Description | Default / Fallback |
197| ---------------------------------------------- | ------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
198| `--plyr-color-main` | The primary UI color. | ![#f03c15](https://place-hold.it/15/00b3ff/000000?text=+) `#00b3ff` |
199| `--plyr-video-background` | The background color of video and poster wrappers for using alpha channel videos and poster images. | `rgba(0, 0, 0, 1)` |
200| `--plyr-focus-visible-color` | The color used for the focus styles when an element is `:focus-visible` (keyboard focused). | `--plyr-color-main` |
201| `--plyr-badge-background` | The background color for badges in the menu. | ![#4a5464](https://place-hold.it/15/4a5464/000000?text=+) `#4a5464` |
202| `--plyr-badge-text-color` | The text color for badges. | ![#ffffff](https://place-hold.it/15/ffffff/000000?text=+) `#ffffff` |
203| `--plyr-badge-border-radius` | The border radius used for badges. | `2px` |
204| `--plyr-captions-background` | The color for the background of captions. | `rgba(0, 0, 0, 0.8)` |
205| `--plyr-captions-text-color` | The color used for the captions text. | ![#ffffff](https://place-hold.it/15/ffffff/000000?text=+) `#ffffff` |
206| `--plyr-control-icon-size` | The size of the icons used in the controls. | `18px` |
207| `--plyr-control-spacing` | The space between controls (sometimes used in a multiple - e.g. `10px / 2 = 5px`). | `10px` |
208| `--plyr-control-padding` | The padding inside controls. | `--plyr-control-spacing * 0.7` (`7px`) |
209| `--plyr-control-radius` | The border radius used on controls. | `3px` |
210| `--plyr-control-toggle-checked-background` | The background color used for checked menu items. | `--plyr-color-main` |
211| `--plyr-video-controls-background` | The background for the video controls. | `linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.75))` |
212| `--plyr-video-control-color` | The text/icon color for video controls. | ![#ffffff](https://place-hold.it/15/ffffff/000000?text=+) `#ffffff` |
213| `--plyr-video-control-color-hover` | The text/icon color used when video controls are `:hover`, `:focus` and `:focus-visible` (equivalent). | ![#ffffff](https://place-hold.it/15/ffffff/000000?text=+) `#ffffff` |
214| `--plyr-video-control-background-hover` | The background color used when video controls are `:hover`, `:focus` and `:focus-visible` (equivalent). | `--plyr-color-main` |
215| `--plyr-audio-controls-background` | The background for the audio controls. | ![#ffffff](https://place-hold.it/15/ffffff/000000?text=+) `#ffffff` |
216| `--plyr-audio-control-color` | The text/icon color for audio controls. | ![#4a5464](https://place-hold.it/15/4a5464/000000?text=+) `#4a5464` |
217| `--plyr-audio-control-color-hover` | The text/icon color used when audio controls are `:hover`, `:focus` and `:focus-visible` (equivalent). | ![#ffffff](https://place-hold.it/15/ffffff/000000?text=+) `#ffffff` |
218| `--plyr-audio-control-background-hover` | The background color used when video controls are `:hover`, `:focus` and `:focus-visible` (equivalent). | `--plyr-color-main` |
219| `--plyr-menu-background` | The background color for menus. | `rgba(255, 255, 255, 0.9)` |
220| `--plyr-menu-color` | The text/icon color for menu items. | ![#4a5464](https://place-hold.it/15/4a5464/000000?text=+) `#4a5464` |
221| `--plyr-menu-shadow` | The shadow used on menus. | `0 1px 2px rgba(0, 0, 0, 0.15)` |
222| `--plyr-menu-radius` | The border radius on the menu. | `4px` |
223| `--plyr-menu-arrow-size` | The size of the arrow on the bottom of the menu. | `6px` |
224| `--plyr-menu-item-arrow-color` | The color of the arrows in the menu. | ![#728197](https://place-hold.it/15/728197/000000?text=+) `#728197` |
225| `--plyr-menu-item-arrow-size` | The size of the arrows in the menu. | `4px` |
226| `--plyr-menu-border-color` | The border color for the bottom of the back button in the top of the sub menu pages. | ![#dcdfe5](https://place-hold.it/15/dcdfe5/000000?text=+) `#dcdfe5` |
227| `--plyr-menu-border-shadow-color` | The shadow below the border of the back button in the top of the sub menu pages. | ![#ffffff](https://place-hold.it/15/ffffff/000000?text=+) `#ffffff` |
228| `--plyr-progress-loading-size` | The size of the stripes in the loading state in the scrubber. | `25px` |
229| `--plyr-progress-loading-background` | The background color on the loading state in the scrubber. | `rgba(35, 40, 47, 0.6)` |
230| `--plyr-video-progress-buffered-background` | The fill color for the buffer indication in the scrubber for video. | `rgba(255, 255, 255, 0.25)` |
231| `--plyr-audio-progress-buffered-background` | The fill color for the buffer indication in the scrubber for audio. | `rgba(193, 200, 209, 0.6)` |
232| `--plyr-range-thumb-height` | The height of the scrubber handle/thumb. | `13px` |
233| `--plyr-range-thumb-background` | The background of the scrubber handle/thumb. | ![#ffffff](https://place-hold.it/15/ffffff/000000?text=+) `#ffffff` |
234| `--plyr-range-thumb-shadow` | The shadow of the scrubber handle/thumb. | `0 1px 1px rgba(215, 26, 18, 0.15), 0 0 0 1px rgba(215, 26, 18, 0.2)` |
235| `--plyr-range-thumb-active-shadow-width` | The width of the shadow when the scrubber handle/thumb is `:active` (pressed). | `3px` |
236| `--plyr-range-track-height` | The height of the scrubber/progress track. | `5px` |
237| `--plyr-range-fill-background` | The fill color of the scrubber/progress. | `--plyr-color-main` |
238| `--plyr-video-range-track-background` | The background of the scrubber/progress. | `--plyr-video-progress-buffered-background` |
239| `--plyr-video-range-thumb-active-shadow-color` | The color of the shadow when the video scrubber handle/thumb is `:active` (pressed). | `rgba(255, 255, 255, 0.5)` |
240| `--plyr-audio-range-track-background` | The background of the scrubber/progress. | `--plyr-video-progress-buffered-background` |
241| `--plyr-audio-range-thumb-active-shadow-color` | The color of the shadow when the audio scrubber handle/thumb is `:active` (pressed). | `rgba(215, 26, 18, 0.1)` |
242| `--plyr-tooltip-background` | The background color for tooltips. | `rgba(255, 255, 255, 0.9)` |
243| `--plyr-tooltip-color` | The text color for tooltips. | ![#4a5464](https://place-hold.it/15/4a5464/000000?text=+) `#4a5464` |
244| `--plyr-tooltip-padding` | The padding for tooltips. | `calc(var(--plyr-control-spacing) / 2))` |
245| `--plyr-tooltip-arrow-size` | The size of the arrow under tooltips. | `4px` |
246| `--plyr-tooltip-radius` | The border radius on tooltips. | `3px` |
247| `--plyr-tooltip-shadow` | The shadow on tooltips. | `0 1px 2px rgba(0, 0, 0, 0.15)` |
248| `--plyr-font-family` | The font family used in the player. | |
249| `--plyr-font-size-base` | The base font size. Mainly used for captions. | `15px` |
250| `--plyr-font-size-small` | The smaller font size. Mainly used for captions. | `13px` |
251| `--plyr-font-size-large` | The larger font size. Mainly used for captions. | `18px` |
252| `--plyr-font-size-xlarge` | The even larger font size. Mainly used for captions. | `21px` |
253| `--plyr-font-size-time` | The font size for the time. | `--plyr-font-size-small` |
254| `--plyr-font-size-menu` | The font size used in the menu. | `--plyr-font-size-small` |
255| `--plyr-font-size-badge` | The font size used for badges. | `9px` |
256| `--plyr-font-weight-regular` | The regular font weight. | `400` |
257| `--plyr-font-weight-bold` | The bold font weight. | `600` |
258| `--plyr-line-height` | The line height used within the player. | `1.7` |
259| `--plyr-font-smoothing` | Whether to enable font antialiasing within the player. | `false` |
260
261You can set them in your CSS for all players:
262
263```css
264:root {
265 --plyr-color-main: #1ac266;
266}
267```
268
269...or for a specific class name:
270
271```css
272.player {
273 --plyr-color-main: #1ac266;
274}
275```
276
277...or in your HTML:
278
279```html
280<video class="player" style="--plyr-color-main: #1ac266;">...</video>
281```
282
283### Sass
284
285You 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
286use [autoprefixer](https://www.npmjs.com/package/gulp-autoprefixer) (you should be already!) as all declarations use the W3C definitions.
287
288The 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
289you write. Check out the JavaScript source for more on this.
290
291## SVG
292
293The icons used in the Plyr controls are loaded in an SVG sprite. The sprite is automatically loaded from our CDN by default. If you already have an icon build
294system in place, you can include the source plyr icons (see `/src/sprite` for source icons).
295
296### Using the `iconUrl` option
297
298You can however specify your own `iconUrl` option and Plyr will determine if the url is absolute and requires loading by AJAX/CORS due to current browser
299limitations or if it's a relative path, just use the path directly.
300
301If you're using the `<base>` tag on your site, you may need to use something like this: [svgfixer.js](https://gist.github.com/leonderijke/c5cf7c5b2e424c0061d2)
302
303More info on SVG sprites here: [http://css-tricks.com/svg-sprites-use-better-icon-fonts/](http://css-tricks.com/svg-sprites-use-better-icon-fonts/) and the AJAX
304technique here: [http://css-tricks.com/ajaxing-svg-sprite/](http://css-tricks.com/ajaxing-svg-sprite/)
305
306## Cross Origin (CORS)
307
308You'll notice the `crossorigin` attribute on the example `<video>` elements. This is because the TextTrack captions are loaded from another domain. If your
309TextTrack captions are also hosted on another domain, you will need to add this attribute and make sure your host has the correct headers setup. For more info
310on CORS checkout the MDN docs:
311[https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS)
312
313## Captions
314
315WebVTT captions are supported. To add a caption track, check the HTML example above and look for the `<track>` element. Be sure to
316[validate your caption files](https://quuz.org/webvtt/).
317
318## JavaScript
319
320### Initializing
321
322You can specify a range of arguments for the constructor to use:
323
324- A [CSS string selector](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors)
325- A [`HTMLElement`](https://developer.mozilla.org/en/docs/Web/API/HTMLElement)
326- A [jQuery](https://jquery.com) object
327
328_Note_: If a `NodeList`, `Array`, or jQuery object are passed, the first element will be used for setup. To setup multiple players, see [multiple players](#multiple-players) below.
329
330#### Single player
331
332Passing a CSS string selector that's compatible with [`querySelector`](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector):
333
334```js
335const player = new Plyr('#player');
336```
337
338Passing a [HTMLElement](https://developer.mozilla.org/en/docs/Web/API/HTMLElement):
339
340```js
341const player = new Plyr(document.getElementById('player'));
342```
343
344```js
345const player = new Plyr(document.querySelector('.js-player'));
346```
347
348The HTMLElement or string selector can be the target `<video>`, `<audio>`, or `<div>` wrapper for embeds.
349
350#### Multiple players
351
352You have two choices here. You can either use a simple array loop to map the constructor:
353
354```js
355const players = Array.from(document.querySelectorAll('.js-player')).map((p) => new Plyr(p));
356```
357
358...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:
359
360```js
361const players = Plyr.setup('.js-player');
362```
363
364Both options will also return an array of instances in the order of they were in the DOM for the string selector or the source NodeList or Array.
365
366#### Options
367
368The second argument for the constructor is the [options](#options) object:
369
370```js
371const player = new Plyr('#player', {
372 title: 'Example Title',
373});
374```
375
376Options can be passed as an object to the constructor as above or as JSON in `data-plyr-config` attribute on each of your target elements:
377
378```html
379<video src="/path/to/video.mp4" id="player" controls data-plyr-config='{ "title": "Example Title" }'></video>
380```
381
382Note the single quotes encapsulating the JSON and double quotes on the object keys. Only string values need double quotes.
383
384| Option | Type | Default | Description |
385| -------------------- | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
386| `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. |
387| `debug` | Boolean | `false` | Display debugging information in the console |
388| `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. |
389| `settings` | Array | `['captions', 'quality', 'speed', 'loop']` | If the default controls are used, you can specify which settings to show in the menu |
390| `i18n` | Object | See [defaults.js](/src/js/config/defaults.js) | Used for internationalization (i18n) of the text within the UI. |
391| `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. |
392| `iconUrl` | String | `null` | Specify a URL or path to the SVG sprite. See the [SVG section](#svg) for more info. |
393| `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. |
394| `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. |
395| `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. |
396| `autopause`&sup1; | Boolean | `true` | Only allow one player playing at once. |
397| `playsinline`&sup3; | Boolean | `true` | Allow inline playback on iOS. Note this has no effect on iPadOS. |
398| `seekTime` | Number | `10` | The time, in seconds, to seek when a user hits fast forward or rewind. |
399| `volume` | Number | `1` | A number, between 0 and 1, representing the initial volume of the player. |
400| `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. |
401| `clickToPlay` | Boolean | `true` | Click (or tap) of the video container will toggle play/pause. |
402| `disableContextMenu` | Boolean | `true` | Disable right click menu on video to <em>help</em> as very primitive obfuscation to prevent downloads of content. |
403| `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. |
404| `resetOnEnd` | Boolean | false | Reset the playback to the start once playback is complete. |
405| `keyboard` | Object | `{ focused: true, global: false }` | Enable [keyboard shortcuts](#shortcuts) for focused players only or globally |
406| `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. |
407| `duration` | Number | `null` | Specify a custom duration for media. |
408| `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). |
409| `invertTime` | Boolean | `true` | Display the current time as a countdown rather than an incremental counter. |
410| `toggleInvert` | Boolean | `true` | Allow users to click to toggle the above. |
411| `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. |
412| `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). |
413| `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. |
414| `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. |
415| `storage` | Object | `{ enabled: true, key: 'plyr' }` | `enabled`: Allow use of local storage to store user settings. `key`: The key name to use. |
416| `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. |
417| `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. |
418| `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. |
419| `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. |
420| `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. |
421| `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` |
422| `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` |
423| `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. |
424| `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. |
425| `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. |
426
4271. Vimeo only
4282. 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:
429
430- <https://webkit.org/blog/6784/new-video-policies-for-ios/>
431- <https://developers.google.com/web/updates/2017/09/autoplay-policy-changes>
432- <https://hacks.mozilla.org/2019/02/firefox-66-to-block-automatically-playing-audible-video-and-audio/>
433
4343. 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:
435
436- Use the fallback/faux fullscreen option which covers the whole viewport (this is the default)
437- 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.
438
439# API
440
441There are methods, setters and getters on a Plyr object.
442
443## Object
444
445The easiest way to access the Plyr object is to set the return value from your call to the constructor to a variable. For example:
446
447```js
448const player = new Plyr('#player', {
449 /* options */
450});
451```
452
453You can also access the object through any events:
454
455```js
456element.addEventListener('ready', (event) => {
457 const player = event.detail.plyr;
458});
459```
460
461## Methods
462
463Example method use:
464
465```js
466player.play(); // Start playback
467player.fullscreen.enter(); // Enter fullscreen
468```
469
470| Method | Parameters | Description |
471| -------------------------------------------------------- | ---------------- | ---------------------------------------------------------------------------------------------------------- |
472| `play()`&sup1; | - | Start playback. |
473| `pause()` | - | Pause playback. |
474| `togglePlay(toggle)`&sup1; | Boolean | Toggle playback, if no parameters are passed, it will toggle based on current status. |
475| `stop()` | - | Stop playback and reset to start. |
476| `restart()` | - | Restart playback. |
477| `rewind(seekTime)` | Number | Rewind playback by the specified seek time. If no parameter is passed, the default seek time will be used. |
478| `forward(seekTime)` | Number | Fast forward by the specified seek time. If no parameter is passed, the default seek time will be used. |
479| `increaseVolume(step)` | Number | Increase volume by the specified step. If no parameter is passed, the default step will be used. |
480| `decreaseVolume(step)` | Number | Increase volume by the specified step. If no parameter is passed, the default step will be used. |
481| `toggleCaptions(toggle)` | Boolean | Toggle captions display. If no parameter is passed, it will toggle based on current status. |
482| `fullscreen.enter()` | - | Enter fullscreen. If fullscreen is not supported, a fallback "full window/viewport" is used instead. |
483| `fullscreen.exit()` | - | Exit fullscreen. |
484| `fullscreen.toggle()` | - | Toggle fullscreen. |
485| `airplay()` | - | Trigger the airplay dialog on supported devices. |
486| `setPreviewThumbnails(source: PreviewThumbnailsOptions)` | - | Sets the preview thumbnails for the current source. |
487| `toggleControls(toggle)` | Boolean | Toggle the controls (video only). Takes optional truthy value to force it on/off. |
488| `on(event, function)` | String, Function | Add an event listener for the specified event. |
489| `once(event, function)` | String, Function | Add an event listener for the specified event once. |
490| `off(event, function)` | String, Function | Remove an event listener for the specified event. |
491| `supports(type)` | String | Check support for a mime type. |
492| `destroy()` | - | Destroy the instance and garbage collect any elements. |
493
4941. 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.
495
496## Getters and Setters
497
498Example setters:
499
500```js
501player.volume = 0.5; // Sets volume at 50%
502player.currentTime = 10; // Seeks to 10 seconds
503```
504
505Example getters:
506
507```js
508player.volume; // 0.5;
509player.currentTime; // 10
510player.fullscreen.active; // false;
511```
512
513| Property | Getter | Setter | Description |
514| -------------------- | ------ | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
515| `isHTML5` | ✓ | - | Returns a boolean indicating if the current player is HTML5. |
516| `isEmbed` | ✓ | - | Returns a boolean indicating if the current player is an embedded player. |
517| `playing` | ✓ | - | Returns a boolean indicating if the current player is playing. |
518| `paused` | ✓ | - | Returns a boolean indicating if the current player is paused. |
519| `stopped` | ✓ | - | Returns a boolean indicating if the current player is stopped. |
520| `ended` | ✓ | - | Returns a boolean indicating if the current player has finished playback. |
521| `buffered` | ✓ | - | Returns a float between 0 and 1 indicating how much of the media is buffered |
522| `currentTime` | ✓ | ✓ | Gets or sets the currentTime for the player. The setter accepts a float in seconds. |
523| `seeking` | ✓ | - | Returns a boolean indicating if the current player is seeking. |
524| `duration` | ✓ | - | Returns the duration for the current media. |
525| `volume` | ✓ | ✓ | Gets or sets the volume for the player. The setter accepts a float between 0 and 1. |
526| `muted` | ✓ | ✓ | Gets or sets the muted state of the player. The setter accepts a boolean. |
527| `hasAudio` | ✓ | - | Returns a boolean indicating if the current media has an audio track. |
528| `speed` | ✓ | ✓ | Gets or sets the speed for the player. The setter accepts a value in the options specified in your config. Generally the minimum should be 0.5. |
529| `quality`&sup1; | ✓ | ✓ | Gets or sets the quality for the player. The setter accepts a value from the options specified in your config. |
530| `loop` | ✓ | ✓ | Gets or sets the current loop state of the player. The setter accepts a boolean. |
531| `source` | ✓ | ✓ | Gets or sets the current source for the player. The setter accepts an object. See [source setter](#the-source-setter) below for examples. |
532| `poster` | ✓ | ✓ | Gets or sets the current poster image for the player. The setter accepts a string; the URL for the updated poster image. |
533| `previewThumbnails` | ✓ | ✓ | Gets or sets the current preview thumbnail source for the player. The setter accepts a string |
534| `autoplay` | ✓ | ✓ | Gets or sets the autoplay state of the player. The setter accepts a boolean. |
535| `currentTrack` | ✓ | ✓ | Gets or sets the caption track by index. `-1` means the track is missing or captions is not active |
536| `language` | ✓ | ✓ | Gets or sets the preferred captions language for the player. The setter accepts an ISO two-letter language code. Support for the languages is dependent on the captions you include. If your captions don't have any language data, or if you have multiple tracks with the same language, you may want to use `currentTrack` instead. |
537| `fullscreen.active` | ✓ | - | Returns a boolean indicating if the current player is in fullscreen mode. |
538| `fullscreen.enabled` | ✓ | - | Returns a boolean indicating if the current player has fullscreen enabled. |
539| `pip`&sup1; | ✓ | ✓ | Gets or sets the picture-in-picture state of the player. The setter accepts a boolean. This currently only supported on Safari 10+ (on MacOS Sierra+ and iOS 10+) and Chrome 70+. |
540| `ratio` | ✓ | ✓ | Gets or sets the video aspect ratio. The setter accepts a string in the same format as the `ratio` option. |
541| `download` | ✓ | ✓ | Gets or sets the URL for the download button. The setter accepts a string containing a valid absolute URL. |
542
5431. HTML5 only
544
545### The `.source` setter
546
547This allows changing the player source and type on the fly.
548
549Video example:
550
551```js
552player.source = {
553 type: 'video',
554 title: 'Example title',
555 sources: [
556 {
557 src: '/path/to/movie.mp4',
558 type: 'video/mp4',
559 size: 720,
560 },
561 {
562 src: '/path/to/movie.webm',
563 type: 'video/webm',
564 size: 1080,
565 },
566 ],
567 poster: '/path/to/poster.jpg',
568 previewThumbnails: {
569 src: '/path/to/thumbnails.vtt',
570 },
571 tracks: [
572 {
573 kind: 'captions',
574 label: 'English',
575 srclang: 'en',
576 src: '/path/to/captions.en.vtt',
577 default: true,
578 },
579 {
580 kind: 'captions',
581 label: 'French',
582 srclang: 'fr',
583 src: '/path/to/captions.fr.vtt',
584 },
585 ],
586};
587```
588
589Audio example:
590
591```js
592player.source = {
593 type: 'audio',
594 title: 'Example title',
595 sources: [
596 {
597 src: '/path/to/audio.mp3',
598 type: 'audio/mp3',
599 },
600 {
601 src: '/path/to/audio.ogg',
602 type: 'audio/ogg',
603 },
604 ],
605};
606```
607
608YouTube example:
609
610```js
611player.source = {
612 type: 'video',
613 sources: [
614 {
615 src: 'bTqVqk7FSmY',
616 provider: 'youtube',
617 },
618 ],
619};
620```
621
622Vimeo example
623
624```js
625player.source = {
626 type: 'video',
627 sources: [
628 {
629 src: '76979871',
630 provider: 'vimeo',
631 },
632 ],
633};
634```
635
636_Note:_ `src` property for YouTube and Vimeo can either be the video ID or the whole URL.
637
638| Property | Type | Description |
639| ------------------------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
640| `type` | String | Either `video` or `audio`. _Note:_ YouTube and Vimeo are currently not supported as audio sources. |
641| `title` | String | _Optional._ Title of the new media. Used for the `aria-label` attribute on the play button, and outer container. YouTube and Vimeo are populated automatically. |
642| `sources` | Array | This is an array of sources. For HTML5 media, the properties of this object are mapped directly to HTML attributes so more can be added to the object if required. |
643| `poster`&sup1; | String | The URL for the poster image (HTML5 video only). |
644| `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. |
645| `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 }`. |
646
6471. HTML5 only
648
649# Events
650
651You can listen for events on the target element you setup Plyr on (see example under the table). Some events only apply to HTML5 audio and video. Using your
652reference 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`
653property. Here's an example:
654
655```js
656player.on('ready', (event) => {
657 const instance = event.detail.plyr;
658});
659```
660
661## Standard Media Events
662
663| Event Type | Description |
664| ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
665| `progress` | Sent periodically to inform interested parties of progress downloading the media. Information about the current amount of the media that has been downloaded is available in the media element's `buffered` attribute. |
666| `playing` | Sent when the media begins to play (either for the first time, after having been paused, or after ending and then restarting). |
667| `play` | Sent when playback of the media starts after having been paused; that is, when playback is resumed after a prior `pause` event. |
668| `pause` | Sent when playback is paused. |
669| `timeupdate` | The time indicated by the element's `currentTime` attribute has changed. |
670| `volumechange` | Sent when the audio volume changes (both when the volume is set and when the `muted` state is changed). |
671| `seeking` | Sent when a seek operation begins. |
672| `seeked` | Sent when a seek operation completes. |
673| `ratechange` | Sent when the playback speed changes. |
674| `ended` | Sent when playback completes. _Note:_ This does not fire if `autoplay` is true. |
675| `enterfullscreen` | Sent when the player enters fullscreen mode (either the proper fullscreen or full-window fallback for older browsers). |
676| `exitfullscreen` | Sent when the player exits fullscreen mode. |
677| `captionsenabled` | Sent when captions are enabled. |
678| `captionsdisabled` | Sent when captions are disabled. |
679| `languagechange` | Sent when the caption language is changed. |
680| `controlshidden` | Sent when the controls are hidden. |
681| `controlsshown` | Sent when the controls are shown. |
682| `ready` | Triggered when the instance is ready for API calls. |
683
684### HTML5 only
685
686| Event Type | Description |
687| ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
688| `loadstart` | Sent when loading of the media begins. |
689| `loadeddata` | The first frame of the media has finished loading. |
690| `loadedmetadata` | The media's metadata has finished loading; all attributes now contain as much useful information as they're going to. |
691| `qualitychange` | The quality of playback has changed. |
692| `canplay` | Sent when enough data is available that the media can be played, at least for a couple of frames. This corresponds to the `HAVE_ENOUGH_DATA` `readyState`. |
693| `canplaythrough` | Sent when the ready state changes to `CAN_PLAY_THROUGH`, indicating that the entire media can be played without interruption, assuming the download rate remains at least at the current level. _Note:_ Manually setting the `currentTime` will eventually fire a `canplaythrough` event in firefox. Other browsers might not fire this event. |
694| `stalled` | Sent when the user agent is trying to fetch media data, but data is unexpectedly not forthcoming. |
695| `waiting` | Sent when the requested operation (such as playback) is delayed pending the completion of another operation (such as a seek). |
696| `emptied` | he media has become empty; for example, this event is sent if the media has already been loaded (or partially loaded), and the `load()` method is called to reload it. |
697| `cuechange` | Sent when a `TextTrack` has changed the currently displaying cues. |
698| `error` | Sent when an error occurs. The element's `error` attribute contains more information. |
699
700### YouTube only
701
702| Event Type | Description |
703| ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
704| `statechange` | The state of the player has changed. The code can be accessed via `event.detail.code`. Possible values are `-1`: Unstarted, `0`: Ended, `1`: Playing, `2`: Paused, `3`: Buffering, `5`: Video cued. See the [YouTube Docs](https://developers.google.com/youtube/iframe_api_reference#onStateChange) for more information. |
705
706_Note:_ These events also bubble up the DOM. The event target will be the container element.
707
708Some event details borrowed from [MDN](https://developer.mozilla.org/en-US/docs/Web/Guide/Events/Media_events).
709
710# Embeds
711
712YouTube and Vimeo are currently supported and function much like a HTML5 video. Similar events and API methods are available for all types. However if you wish
713to access the API's directly. You can do so via the `embed` property of your player object - e.g. `player.embed`. You can then use the relevant methods from the
714third party APIs. More info on the respective API's here:
715
716- [YouTube iframe API Reference](https://developers.google.com/youtube/iframe_api_reference)
717- [Vimeo player.js Reference](https://github.com/vimeo/player.js)
718
719_Note_: Not all API methods may work 100%. Your mileage may vary. It's better to use the Plyr API where possible.
720
721# Shortcuts
722
723By default, a player will bind the following keyboard shortcuts when it has focus. If you have the `global` option to `true` and there's only one player in the
724document then the shortcuts will work when any element has focus, apart from an element that requires input.
725
726| Key | Action |
727| ---------- | -------------------------------------- |
728| `0` to `9` | Seek from 0 to 90% respectively |
729| `space` | Toggle playback |
730| `K` | Toggle playback |
731| &larr; | Seek backward by the `seekTime` option |
732| &rarr; | Seek forward by the `seekTime` option |
733| &uarr; | Increase volume |
734| &darr; | Decrease volume |
735| `M` | Toggle mute |
736| `F` | Toggle fullscreen |
737| `C` | Toggle captions |
738| `L` | Toggle loop |
739
740# Preview thumbnails
741
742It's possible to display preview thumbnails as per the demo when you hover over the scrubber or while you are scrubbing in the main video area. This can be used for all video types but is easiest with HTML5 of course. You will need to generate the sprite or images yourself. This is possible using something like AWS transcoder to generate the frames and then combine them into a sprite image. Sprites are recommended for performance reasons - they will be much faster to download and easier to compress into a small file size making them load faster.
743
744You can see the example VTT files [here](https://cdn.plyr.io/static/demo/thumbs/100p.vtt) and [here](https://cdn.plyr.io/static/demo/thumbs/240p.vtt) for how the sprites are done. The coordinates are set as the `xywh` hash on the URL in the order X Offset, Y Offset, Width, Height (e.g. `240p-00001.jpg#xywh=1708,480,427,240` is offset `1708px` from the left, `480px` from the top and is `427x240px`. If you want to include images per frame, this is also possible but will be slower, resulting in a degraded experience.
745
746# Fullscreen
747
748Fullscreen in Plyr is supported by all browsers that [currently support it](http://caniuse.com/#feat=fullscreen).
749
750# Browser support
751
752Plyr supports the last 2 versions of most _modern_ browsers.
753
754| Browser | Supported |
755| ------------- | --------------- |
756| Safari | ✓ |
757| Mobile Safari | ✓&sup1; |
758| Firefox | ✓ |
759| Chrome | ✓ |
760| Opera | ✓ |
761| Edge | ✓ |
762| IE11 | ✓&sup3; |
763| IE10 | ✓<sup>2,3</sup> |
764
7651. 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.
7662. 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)).
7673. Polyfills required. See below.
768
769## Polyfills
770
771Plyr uses ES6 which isn't supported in all browsers quite yet. This means some features will need to be polyfilled to be available otherwise you'll run into issues. We've elected to not burden the ~90% of users that do support these features with extra JS and instead leave polyfilling to you to work out based on your needs. The easiest method I've found is to use [polyfill.io](https://polyfill.io) which provides polyfills based on user agent. This is the method the demo uses.
772
773## Checking for support
774
775You can use the static method to check for support. For example
776
777```js
778const supported = Plyr.supported('video', 'html5');
779```
780
781The arguments are:
782
783- Media type (`'audio' | 'video'`)
784- Provider (`'html5' | 'youtube' | 'vimeo'`)
785
786## Disable support programmatically
787
788The `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:
789
790```js
791{
792 enabled: !/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent);
793}
794```
795
796If a User Agent is disabled but supports `<video>` and `<audio>` natively, it will use the native player.
797
798# Plugins & Components
799
800Some awesome folks have made plugins for CMSs and Components for JavaScript frameworks:
801
802| Type | Maintainer | Link |
803| ----------- | --------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- |
804| WordPress | Brandon Lavigne ([@drrobotnik](https://github.com/drrobotnik)) | [https://wordpress.org/plugins/plyr/](https://wordpress.org/plugins/plyr/) |
805| Angular | Simon Bobrov ([@smnbbrv](https://github.com/smnbbrv)) | [https://github.com/smnbbrv/ngx-plyr](https://github.com/smnbbrv/ngx-plyr) |
806| React | Chintan Prajapati ([@chintan9](https://github.com/chintan9)) | [https://github.com/chintan9/plyr-react](https://github.com/chintan9/plyr-react) |
807| Vue | Gabe Dunn ([@redxtech](https://github.com/redxtech)) | [https://github.com/redxtech/vue-plyr](https://github.com/redxtech/vue-plyr) |
808| Neos | Jon Uhlmann ([@jonnitto](https://github.com/jonnitto)) | [https://packagist.org/packages/jonnitto/plyr](https://packagist.org/packages/jonnitto/plyr) |
809| Kirby | Dominik Pschenitschni ([@dpschen](https://github.com/dpschen)) | [https://github.com/dpschen/kirby-plyrtag](https://github.com/dpschen/kirby-plyrtag) |
810| REDAXO | FriendsOfRedaxo / skerbis ([@skerbis](https://friendsofredaxo.github.io)) | [https://github.com/FriendsOfREDAXO/plyr](https://github.com/FriendsOfREDAXO/plyr) |
811| svelte-plyr | Ben Woodward / benwoodward ([@benwoodward](https://github.com/benwoodward)) | [https://github.com/benwoodward/svelte-plyr](https://github.com/benwoodward/svelte-plyr) |
812
813# Issues
814
815If you find anything weird with Plyr, please let us know using the GitHub issues tracker.
816
817# Author
818
819Plyr is developed by [@sam_potts](https://twitter.com/sam_potts) / [sampotts.me](http://sampotts.me) with help from the awesome
820[contributors](https://github.com/sampotts/plyr/graphs/contributors)
821
822# Donate
823
824Plyr costs money to run, not only my time. I donate my time for free as I enjoy building Plyr but unfortunately have to pay for domains, hosting, and more. Any help with costs is appreciated...
825
826- [Donate via Patreon](https://www.patreon.com/plyr)
827- [Donate via PayPal](https://www.paypal.me/pottsy/20usd)
828
829# Mentions
830
831- [ProductHunt](https://www.producthunt.com/tech/plyr)
832- [The Changelog](http://thechangelog.com/plyr-simple-html5-media-player-custom-controls-webvtt-captions/)
833- [HTML5 Weekly #177](http://html5weekly.com/issues/177)
834- [Responsive Design #149](http://us4.campaign-archive2.com/?u=559bc631fe5294fc66f5f7f89&id=451a61490f)
835- [Web Design Weekly #174](https://web-design-weekly.com/2015/02/24/web-design-weekly-174/)
836- [Front End Focus #177](https://frontendfoc.us/issues/177)
837- [Hacker News](https://news.ycombinator.com/item?id=9136774)
838- [Web Platform Daily](http://webplatformdaily.org/releases/2015-03-04)
839- [LayerVault Designer News](https://news.layervault.com/stories/45394-plyr--a-simple-html5-media-player)
840- [The Treehouse Show #131](https://teamtreehouse.com/library/episode-131-origami-react-responsive-hero-images)
841- [noupe.com](http://www.noupe.com/design/html5-plyr-is-a-responsive-and-accessible-video-player-94389.html)
842
843# Used by
844
845- [Selz.com](https://selz.com)
846- [Peugeot.fr](http://www.peugeot.fr/marque-et-technologie/technologies/peugeot-i-cockpit.html)
847- [Peugeot.de](http://www.peugeot.de/modelle/modellberater/208-3-turer/fotos-videos.html)
848- [TomTom.com](http://prioritydriving.tomtom.com/)
849- [DIGBMX](http://digbmx.com/)
850- [Grime Archive](https://grimearchive.com/)
851- [koel - A personal music streaming server that works.](http://koel.phanan.net/)
852- [Oscar Radio](http://oscar-radio.xyz/)
853- [Sparkk TV](https://www.sparkktv.com/)
854- [@halfhalftravel](https://www.halfhalftravel.com/)
855- [BitChute](https://www.bitchute.com)
856- [Rutheneum-Bote](https://gymnasium-rutheneum.de/content/newspaper/kreativwettbewerb.php)
857- [pressakey.com | Blog-Magazin für Videospiele](https://pressakey.com)
858- [STROLLÿN: Work with a View](https://strollyn.com)
859- [CFDA Runway360](https://runway360.cfda.com/)
860- [NKLAV | Filmmaker](https://nklav.com)
861- [GDI.JS.ORG - Google Drive Index](https://gitlab.com/GoogleDriveIndex/Google-Drive-Index)
862
863If you want to be added to the list, open a pull request. It'd be awesome to see how you're using Plyr 😎
864
865# Useful links and credits
866
867- [PayPal's Accessible HTML5 Video Player (which Plyr was originally ported from)](https://github.com/paypal/accessible-html5-video-player)
868- [An awesome guide for Plyr in Japanese!](http://syncer.jp/how-to-use-plyr-io) by [@arayutw](https://twitter.com/arayutw)
869
870# Thanks
871
872- [Cloudflare](https://www.cloudflare.com/) and [Fastly](https://www.fastly.com/) for providing the CDN services.
873- [Sentry](https://sentry.io/) for error logging service on the demo website.
874
875## Contributors
876
877### Code Contributors
878
879This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)].
880
881<a href="https://github.com/sampotts/plyr/graphs/contributors"><img src="https://opencollective.com/plyr/contributors.svg?width=890&button=false" /></a>
882
883### Financial Contributors
884
885Become a financial contributor and help us sustain our community. [[Contribute](https://opencollective.com/plyr/contribute)]
886
887#### Individuals
888
889<a href="https://opencollective.com/plyr"><img src="https://opencollective.com/plyr/individuals.svg?width=890"></a>
890
891#### Organizations
892
893Support this project with your organization. Your logo will show up here with a link to your website. [[Contribute](https://opencollective.com/plyr/contribute)]
894
895<a href="https://opencollective.com/plyr/organization/0/website"><img src="https://opencollective.com/plyr/organization/0/avatar.svg"></a>
896<a href="https://opencollective.com/plyr/organization/1/website"><img src="https://opencollective.com/plyr/organization/1/avatar.svg"></a><a href="https://opencollective.com/plyr/organization/2/website"><img src="https://opencollective.com/plyr/organization/2/avatar.svg"></a>
897
898# Copyright and License
899
900[The MIT license](LICENSE.md)