v1.8.3
- Disabled iPad support for YouTube and Vimeo due to iOS limitations with iFrame playback - Fixed IE11 icon loading (fixes #269) - Updated screenshot (fixes #281) - Added WordPress plugin (fixes #239) - Added Neos plugin - Added HLS, Shaka and dash.js examples (see #235 for more) - Improvements for controls hiding and showing on touch devices
This commit is contained in:
parent
be19b72719
commit
9b75436380
@ -1,5 +1,14 @@
|
||||
# Changelog
|
||||
|
||||
# v1.8.3
|
||||
- Disabled iPad support for YouTube and Vimeo due to iOS limitations with iFrame playback
|
||||
- Fixed IE11 icon loading (fixes #269)
|
||||
- Updated screenshot (fixes #281)
|
||||
- Added WordPress plugin (fixes #239)
|
||||
- Added Neos plugin
|
||||
- Added HLS, Shaka and dash.js examples (see #235 for more)
|
||||
- Improvements for controls hiding and showing on touch devices
|
||||
|
||||
# v1.8.2
|
||||
- Fixed event bubbling
|
||||
|
||||
|
@ -79,7 +79,7 @@
|
||||
<script src="dist/demo.js"></script>
|
||||
|
||||
<!-- Rangetouch to fix <input type="range"> on touch devices (see https://rangetouch.com) -->
|
||||
<script src="https://cdn.rangetouch.com/0.0.9/rangetouch.js"></script>
|
||||
<script src="https://cdn.rangetouch.com/0.0.9/rangetouch.js" async></script>
|
||||
|
||||
<!-- Sharing libary (https://shr.one) -->
|
||||
<script src="https://cdn.shr.one/0.1.9/shr.js"></script>
|
||||
|
@ -15,7 +15,7 @@
|
||||
debug: true,
|
||||
title: 'Video demo',
|
||||
iconUrl: '../dist/plyr.svg',
|
||||
tooltips: {
|
||||
tooltips: {
|
||||
controls: true
|
||||
},
|
||||
captions: {
|
||||
|
2
dist/plyr.css
vendored
2
dist/plyr.css
vendored
File diff suppressed because one or more lines are too long
4
dist/plyr.js
vendored
4
dist/plyr.js
vendored
File diff suppressed because one or more lines are too long
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "plyr",
|
||||
"version": "1.8.2",
|
||||
"version": "1.8.3",
|
||||
"description": "A simple, accessible and customizable HTML5, YouTube and Vimeo media player",
|
||||
"homepage": "http://plyr.io",
|
||||
"main": "src/js/plyr.js",
|
||||
@ -27,7 +27,11 @@
|
||||
"keywords": [
|
||||
"HTML5 Video",
|
||||
"HTML5 Audio",
|
||||
"Media Player"
|
||||
"Media Player",
|
||||
"DASH",
|
||||
"Shaka",
|
||||
"WordPress",
|
||||
"HLS"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
364
readme.md
364
readme.md
@ -3,7 +3,7 @@ A simple, accessible and customizable HTML5, YouTube and Vimeo media player.
|
||||
|
||||
[Checkout the demo](https://plyr.io)
|
||||
|
||||
[](https://plyr.io)
|
||||
[](https://plyr.io)
|
||||
|
||||
## Why?
|
||||
We wanted a lightweight, accessible and customizable media player that supports [*modern*](#browser-support) browsers. Sure, there are many other players out there but we wanted to keep things simple, using the right elements for the job.
|
||||
@ -22,6 +22,7 @@ We wanted a lightweight, accessible and customizable media player that supports
|
||||
- **i18n support** - support for internationalization of controls
|
||||
- **No dependencies** - written in "vanilla" JavaScript, no jQuery required
|
||||
- **SASS and LESS provided** - If you like _these_ over plain CSS
|
||||
- **[Streaming](#streaming)** - Support for hls.js, Shaka and dash.js streaming playback
|
||||
|
||||
Oh and yes, it works with Bootstrap.
|
||||
|
||||
@ -38,7 +39,18 @@ Check out the [changelog](changelog.md) to see what's new with Plyr.
|
||||
|
||||
If you have any cool ideas or features, please let me know by [creating an issue](https://github.com/Selz/plyr/issues/new) or, of course, forking and sending a pull request.
|
||||
|
||||
## CMS plugins
|
||||
|
||||
### [WordPress](https://wordpress.org)
|
||||
Created and maintained by Ryan Anthony Drake ([@iamryandrake](https://github.com/iamryandrake))
|
||||
[Plyr on WordPress](https://wordpress.org/plugins/plyr/)
|
||||
|
||||
### [Neos](https://www.neos.io/)
|
||||
Created and maintained by Jon Uhlmann ([@jonnitto](https://github.com/jonnitto))
|
||||
[Plyr.io for Neos.io](https://packagist.org/packages/jonnitto/plyr)
|
||||
|
||||
## Using package managers
|
||||
You can grab the source using one of the following package managers.
|
||||
|
||||
### npm
|
||||
```
|
||||
@ -61,7 +73,6 @@ ember addon:install ember-cli-plyr
|
||||
```
|
||||
More info is on [npm](https://www.npmjs.com/package/ember-cli-plyr) and [GitHub](https://github.com/louisrudner/ember-cli-plyr)
|
||||
|
||||
|
||||
## Quick setup
|
||||
Here's a quick run through on getting up and running.
|
||||
|
||||
@ -69,7 +80,6 @@ Here's a quick run through on getting up and running.
|
||||
Plyr extends upon the standard HTML5 markup so that's all you need for those types.
|
||||
|
||||
#### HTML5 Video
|
||||
|
||||
```html
|
||||
<video poster="/path/to/poster.jpg" controls>
|
||||
<source src="/path/to/video.mp4" type="video/mp4">
|
||||
@ -80,7 +90,6 @@ Plyr extends upon the standard HTML5 markup so that's all you need for those typ
|
||||
```
|
||||
|
||||
#### HTML5 Audio
|
||||
|
||||
```html
|
||||
<audio controls>
|
||||
<source src="/path/to/audio.mp3" type="audio/mp3">
|
||||
@ -91,13 +100,11 @@ Plyr extends upon the standard HTML5 markup so that's all you need for those typ
|
||||
For YouTube and Vimeo, Plyr uses the standard YouTube API markup (an empty `<div>`):
|
||||
|
||||
#### YouTube embed
|
||||
|
||||
```html
|
||||
<div data-type="youtube" data-video-id="bTqVqk7FSmY"></div>
|
||||
```
|
||||
|
||||
#### Vimeo embed
|
||||
|
||||
```html
|
||||
<div data-type="vimeo" data-video-id="143418951"></div>
|
||||
```
|
||||
@ -113,7 +120,7 @@ Include the `plyr.js` script before the closing `</body>` tag and then call `ply
|
||||
If you want to use our CDN for the JavaScript, you can use the following:
|
||||
|
||||
```html
|
||||
<script src="https://cdn.plyr.io/1.8.2/plyr.js"></script>
|
||||
<script src="https://cdn.plyr.io/1.8.3/plyr.js"></script>
|
||||
```
|
||||
|
||||
### CSS
|
||||
@ -126,11 +133,11 @@ Include the `plyr.css` stylsheet into your `<head>`
|
||||
If you want to use our CDN for the default CSS, you can use the following:
|
||||
|
||||
```html
|
||||
<link rel="stylesheet" href="https://cdn.plyr.io/1.8.2/plyr.css">
|
||||
<link rel="stylesheet" href="https://cdn.plyr.io/1.8.3/plyr.css">
|
||||
```
|
||||
|
||||
### SVG Sprite
|
||||
The SVG sprite is loaded automatically from our CDN. To change this, see the [#options](Options) below. For reference, the CDN hosted SVG sprite can be found at `https://cdn.plyr.io/1.8.2/plyr.svg`.
|
||||
The SVG sprite is loaded automatically from our CDN. To change this, see the [#options](Options) below. For reference, the CDN hosted SVG sprite can be found at `https://cdn.plyr.io/1.8.3/plyr.svg`.
|
||||
|
||||
## Advanced
|
||||
|
||||
@ -192,7 +199,6 @@ plyr.setup(options);
|
||||
Some touch browsers (particularly Mobile Safari on iOS) seem to have issues with `<input type="range">` elements whereby touching the track to set the value doesn't work and sliding the thumb can be tricky. To combat this, I've created [RangeTouch](https://rangetouch.com) which I'd recommend including in your solution. It's a tiny script with a nice benefit for users on touch devices.
|
||||
|
||||
#### Options
|
||||
|
||||
Options must be passed as an object to the `setup()` method as above or as JSON in `data-plyr` attribute on each of your target elements:
|
||||
|
||||
```html
|
||||
@ -202,176 +208,176 @@ Options must be passed as an object to the `setup()` method as above or as JSON
|
||||
Note the single quotes encapsulating the JSON and double quotes on the object keys.
|
||||
|
||||
<table class="table" width="100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="20%">Option</th>
|
||||
<th width="15%">Type</th>
|
||||
<th width="15%">Default</th>
|
||||
<th width="50%">Description</th>
|
||||
</tr>
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="20%">Option</th>
|
||||
<th width="15%">Type</th>
|
||||
<th width="15%">Default</th>
|
||||
<th width="50%">Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>enabled</code></td>
|
||||
<td>Boolean</td>
|
||||
<td><code>true</code></td>
|
||||
<td>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.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>html</code></td>
|
||||
<td>String</td>
|
||||
<td><code><a href="controls.md">See controls.md</a></code></td>
|
||||
<td>See <a href="controls.md">controls.md</a> for more info on how the html needs to be structured.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>controls</code></td>
|
||||
<td>Array</td>
|
||||
<td><code>['play-large', 'play', 'progress', 'current-time', 'mute', 'volume', 'captions', 'fullscreen']</code></td>
|
||||
<td>Toggle which control elements you would like to display when using the default controls html. If you specify a <code>html</code> option, this is redundant. The default value is to display everything.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>i18n</code></td>
|
||||
<td>Object</td>
|
||||
<td><code><a href="controls.md">See controls.md</a></code></td>
|
||||
<td>Used for internationalization (i18n) of the tooltips/labels within the buttons.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>loadSprite</code></td>
|
||||
<td>Boolean</td>
|
||||
<td><code>true</code></td>
|
||||
<td>Load the SVG sprite specified as the <code>iconUrl</code> option (if a URL). If <code>false</code>, it is assumed you are handling sprite loading yourself.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>iconUrl</code></td>
|
||||
<td>String</td>
|
||||
<td><code>null</code></td>
|
||||
<td>Specify a URL or path to the SVG sprite. See the <a href="#svg">SVG section</a> for more info.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>iconPrefix</code></td>
|
||||
<td>String</td>
|
||||
<td><code>plyr</code></td>
|
||||
<td>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.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>debug</code></td>
|
||||
<td>Boolean</td>
|
||||
<td><code>false</code></td>
|
||||
<td>Display debugging information on what Plyr is doing.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>autoplay</code></td>
|
||||
<td>Boolean</td>
|
||||
<td><code>false</code></td>
|
||||
<td>Autoplay the media on load. This is generally advised against on UX grounds. It is also disabled on iOS (an Apple limitation).</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>seekTime</code></td>
|
||||
<td>Number</td>
|
||||
<td><code>10</code></td>
|
||||
<td>The time, in seconds, to seek when a user hits fast forward or rewind.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>volume</code></td>
|
||||
<td>Number</td>
|
||||
<td><code>5</code></td>
|
||||
<td>A number, between 1 and 10, representing the initial volume of the player.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>clickToPlay</code></td>
|
||||
<td>Boolean</td>
|
||||
<td><code>true</code></td>
|
||||
<td>Click (or tap) of the video container will toggle pause/play.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>disableContextMenu</code></td>
|
||||
<td>Boolean</td>
|
||||
<td><code>true</code></td>
|
||||
<td>Disable right click menu on video to <em>help</em> as very primitive obfuscation to prevent downloads of content.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>hideControls</code></td>
|
||||
<td>Boolean</td>
|
||||
<td><code>true</code></td>
|
||||
<td>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.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>showPosterOnEnd</code></td>
|
||||
<td>Boolean</td>
|
||||
<td><code>false</code></td>
|
||||
<td>This will restore and *reload* HTML5 video once playback is complete. Note: depending on the browser caching, this may result in the video downloading again (or parts of it). Use with caution.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>tooltips</code></td>
|
||||
<td>Object</td>
|
||||
<td><code>{ controls: false, seek: true }</code></td>
|
||||
<td>
|
||||
<strong>controls</strong>: Display control labels as tooltips on :hover & :focus (by default, the labels are screen reader only).
|
||||
<br><br>
|
||||
<strong>seek</strong>: Display a seek tooltip to indicate on click where the media would seek to.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>duration</code></td>
|
||||
<td>Number</td>
|
||||
<td><code>null</code></td>
|
||||
<td>Specify a custom duration.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>displayDuration</code></td>
|
||||
<td>Boolean</td>
|
||||
<td><code>true</code></td>
|
||||
<td>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 <code>controls</code> option).</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>selectors</code></td>
|
||||
<td>Object</td>
|
||||
<td>—</td>
|
||||
<td>See <code>plyr.js</code> in <code>/src</code> for more info. You probably don't need to change any of these.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>listeners</code></td>
|
||||
<td>Object</td>
|
||||
<td>—</td>
|
||||
<td>Allows early binding of event listeners to the controls. See <code>controls</code> above for list of controls and see <code>plyr.js</code> in <code>/src</code> for more info.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>classes</code></td>
|
||||
<td>Object</td>
|
||||
<td>—</td>
|
||||
<td>Similar to above, these are the classes added to the player when state changes occur.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>captions</code></td>
|
||||
<td>Object</td>
|
||||
<td>—</td>
|
||||
<td>One property <code>defaultActive</code> which toggles if captions should be on by default. The default value is <code>false</code>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>fullscreen</code></td>
|
||||
<td>Object</td>
|
||||
<td>—</td>
|
||||
<td>See <a href="#fullscreen-options">below</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>storage</code></td>
|
||||
<td>Object</td>
|
||||
<td>—</td>
|
||||
<td>Two properties; <code>enabled</code> which toggles if local storage should be enabled (if the browser supports it). The default value is `true`. This enables storing user settings, currently it only stores volume but more will be added later. The second property <code>key</code> is the key used for the local storage. The default is <code>plyr_volume</code> until more settings are stored.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tr>
|
||||
<td><code>enabled</code></td>
|
||||
<td>Boolean</td>
|
||||
<td><code>true</code></td>
|
||||
<td>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.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>html</code></td>
|
||||
<td>String</td>
|
||||
<td><code><a href="controls.md">See controls.md</a></code></td>
|
||||
<td>See <a href="controls.md">controls.md</a> for more info on how the html needs to be structured.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>controls</code></td>
|
||||
<td>Array</td>
|
||||
<td><code>['play-large', 'play', 'progress', 'current-time', 'mute', 'volume', 'captions', 'fullscreen']</code></td>
|
||||
<td>Toggle which control elements you would like to display when using the default controls html. If you specify a <code>html</code> option, this is redundant. The default value is to display everything.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>i18n</code></td>
|
||||
<td>Object</td>
|
||||
<td><code><a href="controls.md">See controls.md</a></code></td>
|
||||
<td>Used for internationalization (i18n) of the tooltips/labels within the buttons.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>loadSprite</code></td>
|
||||
<td>Boolean</td>
|
||||
<td><code>true</code></td>
|
||||
<td>Load the SVG sprite specified as the <code>iconUrl</code> option (if a URL). If <code>false</code>, it is assumed you are handling sprite loading yourself.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>iconUrl</code></td>
|
||||
<td>String</td>
|
||||
<td><code>null</code></td>
|
||||
<td>Specify a URL or path to the SVG sprite. See the <a href="#svg">SVG section</a> for more info.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>iconPrefix</code></td>
|
||||
<td>String</td>
|
||||
<td><code>plyr</code></td>
|
||||
<td>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.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>debug</code></td>
|
||||
<td>Boolean</td>
|
||||
<td><code>false</code></td>
|
||||
<td>Display debugging information on what Plyr is doing.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>autoplay</code></td>
|
||||
<td>Boolean</td>
|
||||
<td><code>false</code></td>
|
||||
<td>Autoplay the media on load. This is generally advised against on UX grounds. It is also disabled on iOS (an Apple limitation).</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>seekTime</code></td>
|
||||
<td>Number</td>
|
||||
<td><code>10</code></td>
|
||||
<td>The time, in seconds, to seek when a user hits fast forward or rewind.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>volume</code></td>
|
||||
<td>Number</td>
|
||||
<td><code>5</code></td>
|
||||
<td>A number, between 1 and 10, representing the initial volume of the player.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>clickToPlay</code></td>
|
||||
<td>Boolean</td>
|
||||
<td><code>true</code></td>
|
||||
<td>Click (or tap) of the video container will toggle pause/play.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>disableContextMenu</code></td>
|
||||
<td>Boolean</td>
|
||||
<td><code>true</code></td>
|
||||
<td>Disable right click menu on video to <em>help</em> as very primitive obfuscation to prevent downloads of content.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>hideControls</code></td>
|
||||
<td>Boolean</td>
|
||||
<td><code>true</code></td>
|
||||
<td>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.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>showPosterOnEnd</code></td>
|
||||
<td>Boolean</td>
|
||||
<td><code>false</code></td>
|
||||
<td>This will restore and *reload* HTML5 video once playback is complete. Note: depending on the browser caching, this may result in the video downloading again (or parts of it). Use with caution.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>tooltips</code></td>
|
||||
<td>Object</td>
|
||||
<td><code>{ controls: false, seek: true }</code></td>
|
||||
<td>
|
||||
<strong>controls</strong>: Display control labels as tooltips on :hover & :focus (by default, the labels are screen reader only).
|
||||
<br><br>
|
||||
<strong>seek</strong>: Display a seek tooltip to indicate on click where the media would seek to.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>duration</code></td>
|
||||
<td>Number</td>
|
||||
<td><code>null</code></td>
|
||||
<td>Specify a custom duration.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>displayDuration</code></td>
|
||||
<td>Boolean</td>
|
||||
<td><code>true</code></td>
|
||||
<td>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 <code>controls</code> option).</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>selectors</code></td>
|
||||
<td>Object</td>
|
||||
<td>—</td>
|
||||
<td>See <code>plyr.js</code> in <code>/src</code> for more info. You probably don't need to change any of these.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>listeners</code></td>
|
||||
<td>Object</td>
|
||||
<td>—</td>
|
||||
<td>Allows early binding of event listeners to the controls. See <code>controls</code> above for list of controls and see <code>plyr.js</code> in <code>/src</code> for more info.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>classes</code></td>
|
||||
<td>Object</td>
|
||||
<td>—</td>
|
||||
<td>Similar to above, these are the classes added to the player when state changes occur.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>captions</code></td>
|
||||
<td>Object</td>
|
||||
<td>—</td>
|
||||
<td>One property <code>defaultActive</code> which toggles if captions should be on by default. The default value is <code>false</code>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>fullscreen</code></td>
|
||||
<td>Object</td>
|
||||
<td>—</td>
|
||||
<td>See <a href="#fullscreen-options">below</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>storage</code></td>
|
||||
<td>Object</td>
|
||||
<td>—</td>
|
||||
<td>Two properties; <code>enabled</code> which toggles if local storage should be enabled (if the browser supports it). The default value is `true`. This enables storing user settings, currently it only stores volume but more will be added later. The second property <code>key</code> is the key used for the local storage. The default is <code>plyr_volume</code> until more settings are stored.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
#### Fullscreen options
|
||||
|
||||
<table class="table" width="100%" id="fullscreen-options">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="20%">Option</th>
|
||||
<th width="15%">Type</th>
|
||||
<th width="15%">Default</th>
|
||||
<th width="50%">Description</th>
|
||||
</tr>
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="20%">Option</th>
|
||||
<th width="15%">Type</th>
|
||||
<th width="15%">Default</th>
|
||||
<th width="50%">Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
@ -533,7 +539,6 @@ Here's a list of the methods supported:
|
||||
</table>
|
||||
|
||||
#### .source() method
|
||||
|
||||
This allows changing the plyr source and type on the fly.
|
||||
|
||||
Video example:
|
||||
@ -643,9 +648,7 @@ Some more details on the object parameters
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
## Events
|
||||
|
||||
You 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.
|
||||
|
||||
<table class="table" width="100%">
|
||||
@ -788,7 +791,6 @@ document.querySelector('.js-plyr').addEventListener('ready', function(event) {
|
||||
These events also bubble up the DOM.
|
||||
|
||||
## Embeds
|
||||
|
||||
YouTube and Vimeo are currently supported and function much like a HTML5 video. Check the relevant documentation sections for any differences.
|
||||
|
||||
Plyr references a custom version of the Vimeo Froogaloop API as Vimeo have neglected to maintain the library and there were bugs with their version. You don't need to worry about including your own versions of the Vimeo or YouTube JavaScript APIs.
|
||||
@ -813,8 +815,14 @@ More info on the respective API's here:
|
||||
|
||||
*Please note*: not all API methods may work 100%. Your mileage may vary. It's better to use the universal plyr API where possible.
|
||||
|
||||
## Fullscreen
|
||||
## Streaming
|
||||
Because Plyr is an extension of the standard HTML5 video and audio elements, third party streaming plugins can be used with Plyr. Massive thanks to Matias Russitto ([@russitto](https://github.com/russitto)) for working on this. Here's a few examples:
|
||||
|
||||
- Using [hls.js](https://github.com/dailymotion/hls.js) - [Demo](http://codepen.io/sampotts/pen/JKEMqB)
|
||||
- Using [Shaka](https://github.com/google/shaka-player) - [Demo](http://codepen.io/sampotts/pen/zBNpVR)
|
||||
- Using [dash.js](https://github.com/Dash-Industry-Forum/dash.js) - [Demo](http://codepen.io/sampotts/pen/BzpJXN)
|
||||
|
||||
## Fullscreen
|
||||
Fullscreen in Plyr is supported by all browsers that [currently support it](http://caniuse.com/#feat=fullscreen). If you're using the default CSS, you can also use a "full browser" mode which will use the full browser window by adding the `plyr-fullscreen` class to your container.
|
||||
|
||||
## Browser support
|
||||
|
117
src/js/plyr.js
117
src/js/plyr.js
@ -1,6 +1,6 @@
|
||||
// ==========================================================================
|
||||
// Plyr
|
||||
// plyr.js v1.8.2
|
||||
// plyr.js v1.8.3
|
||||
// https://github.com/selz/plyr
|
||||
// License: The MIT License (MIT)
|
||||
// ==========================================================================
|
||||
@ -44,7 +44,7 @@
|
||||
displayDuration: true,
|
||||
loadSprite: true,
|
||||
iconPrefix: 'plyr',
|
||||
iconUrl: 'https://cdn.plyr.io/1.8.2/plyr.svg',
|
||||
iconUrl: 'https://cdn.plyr.io/1.8.3/plyr.svg',
|
||||
clickToPlay: true,
|
||||
hideControls: true,
|
||||
showPosterOnEnd: false,
|
||||
@ -253,8 +253,8 @@
|
||||
isFirefox: isFirefox,
|
||||
isChrome: isChrome,
|
||||
isSafari: isSafari,
|
||||
ios: /(iPad|iPhone|iPod)/g.test(navigator.platform),
|
||||
touch: 'ontouchstart' in document.documentElement
|
||||
isIos: /(iPad|iPhone|iPod)/g.test(navigator.platform),
|
||||
isTouch: 'ontouchstart' in document.documentElement
|
||||
};
|
||||
}
|
||||
|
||||
@ -684,9 +684,14 @@
|
||||
_log(config);
|
||||
|
||||
// Debugging
|
||||
function _log(text, warn) {
|
||||
function _log() {
|
||||
if (config.debug && window.console) {
|
||||
console[(warn ? 'warn' : 'log')](text);
|
||||
console.log.apply(console, arguments);
|
||||
}
|
||||
}
|
||||
function _warn() {
|
||||
if (config.debug && window.console) {
|
||||
console.warn.apply(console, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
@ -694,7 +699,7 @@
|
||||
function _getIconUrl() {
|
||||
return {
|
||||
url: config.iconUrl,
|
||||
external: (config.iconUrl.indexOf("http") === 0)
|
||||
absolute: (config.iconUrl.indexOf("http") === 0) || plyr.browser.isIE
|
||||
};
|
||||
}
|
||||
|
||||
@ -703,7 +708,7 @@
|
||||
// Create html array
|
||||
var html = [],
|
||||
iconUrl = _getIconUrl(),
|
||||
iconPath = (!iconUrl.external ? iconUrl.url : '') + '#' + config.iconPrefix;
|
||||
iconPath = (!iconUrl.absolute ? iconUrl.url : '') + '#' + config.iconPrefix;
|
||||
|
||||
// Larger overlaid play button
|
||||
if (_inArray(config.controls, 'play-large')) {
|
||||
@ -1013,7 +1018,7 @@
|
||||
_log('Successfully loaded the caption file via AJAX');
|
||||
}
|
||||
else {
|
||||
_log('There was a problem loading the caption file via AJAX', true);
|
||||
_warn('There was a problem loading the caption file via AJAX');
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -1206,12 +1211,11 @@
|
||||
function _injectControls() {
|
||||
// Sprite
|
||||
if (config.loadSprite) {
|
||||
var iconUrl = _getIconUrl(),
|
||||
isExternal = iconUrl.external;
|
||||
var iconUrl = _getIconUrl();
|
||||
|
||||
// Only load external sprite using AJAX
|
||||
if (isExternal || plyr.browser.isIE) {
|
||||
_log('AJAX loading external SVG sprite' + (plyr.browser.isIE ? ' (due to IE)' : ''));
|
||||
if (iconUrl.absolute) {
|
||||
_log('AJAX loading absolute SVG sprite' + (plyr.browser.isIE ? ' (due to IE)' : ''));
|
||||
loadSprite(iconUrl.url, "sprite-plyr");
|
||||
}
|
||||
else {
|
||||
@ -1316,7 +1320,7 @@
|
||||
return true;
|
||||
}
|
||||
catch(e) {
|
||||
_log('It looks like there is a problem with your controls html', true);
|
||||
_warn('It looks like there is a problem with your controls HTML');
|
||||
|
||||
// Restore native video controls
|
||||
_toggleNativeControls(true);
|
||||
@ -1332,7 +1336,7 @@
|
||||
|
||||
// Toggle native controls
|
||||
function _toggleNativeControls(toggle) {
|
||||
if (toggle) {
|
||||
if (toggle && _inArray(config.types.html5, plyr.type)) {
|
||||
plyr.media.setAttribute('controls', '');
|
||||
}
|
||||
else {
|
||||
@ -1351,7 +1355,7 @@
|
||||
}
|
||||
|
||||
// If there's a play button, set label
|
||||
if (plyr.supported.full && plyr.buttons && plyr.buttons.play) {
|
||||
if (plyr.supported.full && plyr.buttons.play) {
|
||||
for (var i = plyr.buttons.play.length - 1; i >= 0; i--) {
|
||||
plyr.buttons.play[i].setAttribute('aria-label', label);
|
||||
}
|
||||
@ -1368,8 +1372,8 @@
|
||||
function _setupMedia() {
|
||||
// If there's no media, bail
|
||||
if (!plyr.media) {
|
||||
_log('No audio or video element found', true);
|
||||
return false;
|
||||
_warn('No media element found!');
|
||||
return;
|
||||
}
|
||||
|
||||
if (plyr.supported.full) {
|
||||
@ -1386,10 +1390,10 @@
|
||||
_toggleClass(plyr.container, config.classes.stopped, config.autoplay);
|
||||
|
||||
// Add iOS class
|
||||
_toggleClass(plyr.container, config.classes.isIos, plyr.browser.ios);
|
||||
_toggleClass(plyr.container, config.classes.isIos, plyr.browser.isIos);
|
||||
|
||||
// Add touch class
|
||||
_toggleClass(plyr.container, config.classes.isTouch, plyr.browser.touch);
|
||||
_toggleClass(plyr.container, config.classes.isTouch, plyr.browser.isTouch);
|
||||
|
||||
// Inject the player wrapper
|
||||
if (plyr.type === 'video') {
|
||||
@ -1533,8 +1537,10 @@
|
||||
// Store reference to API
|
||||
plyr.container.plyr.embed = plyr.embed;
|
||||
|
||||
// Setup the UI
|
||||
_setupInterface();
|
||||
// Setup the UI if full support
|
||||
if (plyr.supported.full) {
|
||||
_setupInterface();
|
||||
}
|
||||
|
||||
// Set title
|
||||
_setTitle(_getElement('iframe'));
|
||||
@ -1899,7 +1905,7 @@
|
||||
targetTime = input;
|
||||
}
|
||||
// Event
|
||||
else if (typeof input === 'object' && (input.type === 'input' || input.type === 'change')) {
|
||||
else if (input.type && _inArray(['input', 'change'], input.type)) {
|
||||
// It's the seek slider
|
||||
// Seek to the selected time
|
||||
targetTime = ((input.target.value / input.target.max) * duration);
|
||||
@ -2276,6 +2282,10 @@
|
||||
// Video playing
|
||||
case 'timeupdate':
|
||||
case 'seeking':
|
||||
if (plyr.controls.pressed) {
|
||||
return;
|
||||
}
|
||||
|
||||
value = _getPercentage(plyr.media.currentTime, duration);
|
||||
|
||||
// Set seek range value only if it's a 'natural' time event
|
||||
@ -2485,21 +2495,22 @@
|
||||
if (!config.hideControls || plyr.type === 'audio') {
|
||||
return;
|
||||
}
|
||||
|
||||
var delay = 0,
|
||||
isEnterFullscreen = false,
|
||||
show = toggle;
|
||||
|
||||
// Default to false if no boolean
|
||||
if (typeof toggle !== "boolean") {
|
||||
if (typeof toggle !== 'boolean') {
|
||||
if (toggle && toggle.type) {
|
||||
// Is the enter fullscreen event
|
||||
isEnterFullscreen = (toggle.type === 'enterfullscreen');
|
||||
|
||||
// Whether to show controls
|
||||
show = _inArray(['mousemove', 'mouseenter', 'focus'], toggle.type);
|
||||
show = _inArray(['mousemove', 'touchstart', 'mouseenter', 'focus'], toggle.type);
|
||||
|
||||
// Delay hiding on mousemove events
|
||||
if (toggle.type === 'mousemove') {
|
||||
// Delay hiding on move events
|
||||
if (_inArray(['mousemove', 'touchmove'], toggle.type)) {
|
||||
delay = 2000;
|
||||
}
|
||||
|
||||
@ -2509,7 +2520,7 @@
|
||||
}
|
||||
}
|
||||
else {
|
||||
show = !_hasClass(plyr.container, config.classes.hideControls);
|
||||
show = _hasClass(plyr.container, config.classes.hideControls);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2526,7 +2537,7 @@
|
||||
}
|
||||
|
||||
// Delay for hiding on touch
|
||||
if (plyr.browser.touch) {
|
||||
if (plyr.browser.isTouch) {
|
||||
delay = 3000;
|
||||
}
|
||||
}
|
||||
@ -2536,7 +2547,7 @@
|
||||
if (!show || !plyr.media.paused) {
|
||||
plyr.timers.hover = window.setTimeout(function() {
|
||||
// If the mouse is over the controls (and not entering fullscreen), bail
|
||||
if (plyr.controls.active && !isEnterFullscreen) {
|
||||
if ((plyr.controls.pressed || plyr.controls.hover) && !isEnterFullscreen) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2584,7 +2595,7 @@
|
||||
// Sources are not checked for support so be careful
|
||||
function _updateSource(source) {
|
||||
if (typeof source === 'undefined' || !('sources' in source) || !source.sources.length) {
|
||||
_log('Invalid source format', true);
|
||||
_warn('Invalid source format');
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2712,6 +2723,10 @@
|
||||
// Display duration if available
|
||||
_displayDuration();
|
||||
}
|
||||
// If embed but not fully supported, setupInterface now
|
||||
else if (_inArray(config.types.embed, plyr.type) && !plyr.supported.full) {
|
||||
_setupInterface();
|
||||
}
|
||||
|
||||
// Set aria title and iframe title
|
||||
config.title = source.title;
|
||||
@ -2857,11 +2872,16 @@
|
||||
// Toggle controls visibility based on mouse movement
|
||||
if (config.hideControls) {
|
||||
// Toggle controls on mouse events and entering fullscreen
|
||||
_on(plyr.container, 'mouseenter mouseleave mousemove enterfullscreen', _toggleControls);
|
||||
_on(plyr.container, 'mouseenter mouseleave mousemove touchstart touchend touchcancel touchmove enterfullscreen', _toggleControls);
|
||||
|
||||
// Watch for cursor over controls so they don't hide when trying to interact
|
||||
_on(plyr.controls, 'mouseenter mouseleave', function(event) {
|
||||
plyr.controls.active = (event.type === 'mouseenter');
|
||||
plyr.controls.hover = event.type === 'mouseenter';
|
||||
});
|
||||
|
||||
// Watch for cursor over controls so they don't hide when trying to interact
|
||||
_on(plyr.controls, 'mousedown mouseup touchstart touchend touchcancel', function(event) {
|
||||
plyr.controls.pressed = _inArray(['mousedown', 'touchstart'], event.type);
|
||||
});
|
||||
|
||||
// Focus in/out on controls
|
||||
@ -2959,8 +2979,8 @@
|
||||
|
||||
// On click play, pause ore restart
|
||||
_on(wrapper, 'click', function() {
|
||||
if (plyr.browser.touch && !plyr.media.paused) {
|
||||
_toggleControls(true);
|
||||
// Touch devices will just show controls
|
||||
if (plyr.browser.isTouch && !plyr.media.paused) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -3144,6 +3164,10 @@
|
||||
_play();
|
||||
}
|
||||
}
|
||||
// If embed but not fully supported, setupInterface now (to avoid flash of controls)
|
||||
else if (_inArray(config.types.embed, plyr.type) && !plyr.supported.full) {
|
||||
_setupInterface();
|
||||
}
|
||||
|
||||
// Successful setup
|
||||
plyr.init = true;
|
||||
@ -3152,7 +3176,7 @@
|
||||
function _setupInterface() {
|
||||
// Don't setup interface if no support
|
||||
if (!plyr.supported.full) {
|
||||
_log('No full support for this media type (' + plyr.type + ')', true);
|
||||
_warn('No full support for this media type (' + plyr.type + ')');
|
||||
|
||||
// Remove controls
|
||||
_remove(_getElement(config.selectors.controls.wrapper));
|
||||
@ -3277,34 +3301,35 @@
|
||||
|
||||
// Check for support
|
||||
function supported(type) {
|
||||
var browser = _browserSniff(),
|
||||
oldIE = (browser.isIE && browser.version <= 9),
|
||||
iPhone = /iPhone|iPod/i.test(navigator.userAgent),
|
||||
audio = !!document.createElement('audio').canPlayType,
|
||||
video = !!document.createElement('video').canPlayType,
|
||||
var browser = _browserSniff(),
|
||||
isOldIE = (browser.isIE && browser.version <= 9),
|
||||
isIos = browser.isIos,
|
||||
isIphone = /iPhone|iPod/i.test(navigator.userAgent),
|
||||
audio = !!document.createElement('audio').canPlayType,
|
||||
video = !!document.createElement('video').canPlayType,
|
||||
basic, full;
|
||||
|
||||
switch (type) {
|
||||
case 'video':
|
||||
basic = video;
|
||||
full = (basic && (!oldIE && !iPhone));
|
||||
full = (basic && (!isOldIE && !isIphone));
|
||||
break;
|
||||
|
||||
case 'audio':
|
||||
basic = audio;
|
||||
full = (basic && !oldIE);
|
||||
full = (basic && !isOldIE);
|
||||
break;
|
||||
|
||||
case 'vimeo':
|
||||
case 'youtube':
|
||||
case 'soundcloud':
|
||||
basic = true;
|
||||
full = (!oldIE && !iPhone);
|
||||
full = (!isOldIE && !isIos);
|
||||
break;
|
||||
|
||||
default:
|
||||
basic = (audio && video);
|
||||
full = (basic && !oldIE);
|
||||
full = (basic && !isOldIE);
|
||||
}
|
||||
|
||||
return {
|
||||
@ -3429,7 +3454,7 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
function CustomEvent (event, params) {
|
||||
function CustomEvent(event, params) {
|
||||
params = params || { bubbles: false, cancelable: false, detail: undefined };
|
||||
var evt = document.createEvent('CustomEvent');
|
||||
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
|
||||
|
@ -19,6 +19,7 @@
|
||||
position: relative;
|
||||
max-width: 100%;
|
||||
min-width: 200px;
|
||||
overflow: hidden;
|
||||
font-family: Avenir, "Avenir Next", "Helvetica Neue", "Segoe UI", Helvetica, Arial, sans-serif;
|
||||
direction: ltr;
|
||||
|
||||
@ -203,8 +204,8 @@
|
||||
|
||||
// Captions
|
||||
// --------------------------------------------------------------
|
||||
// Hide default captions (can't find -moz -ms prefixes)
|
||||
.plyr ::-webkit-media-text-track-container {
|
||||
// Hide default captions
|
||||
.plyr video::-webkit-media-text-track-container {
|
||||
display: none;
|
||||
}
|
||||
.plyr__captions {
|
||||
@ -246,9 +247,8 @@
|
||||
|
||||
// Controls
|
||||
// --------------------------------------------------------------
|
||||
// Hide default controls (can't find -moz -ms prefixes)
|
||||
.plyr ::-webkit-media-controls,
|
||||
.plyr ::-webkit-media-controls-enclosure {
|
||||
// Hide native controls
|
||||
.plyr ::-webkit-media-controls {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@ -256,12 +256,9 @@
|
||||
.plyr__controls {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
line-height: 1;
|
||||
text-align: center;
|
||||
|
||||
transition: opacity .3s ease;
|
||||
|
||||
// Spacing
|
||||
> button,
|
||||
.plyr__progress,
|
||||
@ -325,6 +322,7 @@
|
||||
// Hide controls
|
||||
.plyr--hide-controls .plyr__controls {
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
// Video controls
|
||||
@ -338,6 +336,7 @@
|
||||
border-bottom-left-radius: inherit;
|
||||
border-bottom-right-radius: inherit;
|
||||
color: @plyr-video-control-color;
|
||||
transition: opacity .3s ease;
|
||||
|
||||
button {
|
||||
// Hover and tab focus
|
||||
|
@ -19,6 +19,7 @@
|
||||
position: relative;
|
||||
max-width: 100%;
|
||||
min-width: 200px;
|
||||
overflow: hidden;
|
||||
font-family: Avenir, "Avenir Next", "Helvetica Neue", "Segoe UI", Helvetica, Arial, sans-serif;
|
||||
direction: ltr;
|
||||
|
||||
@ -203,8 +204,8 @@
|
||||
|
||||
// Captions
|
||||
// --------------------------------------------------------------
|
||||
// Hide default captions (can't find -moz -ms prefixes)
|
||||
.plyr ::-webkit-media-text-track-container {
|
||||
// Hide default captions
|
||||
.plyr video::-webkit-media-text-track-container {
|
||||
display: none;
|
||||
}
|
||||
.plyr__captions {
|
||||
@ -246,9 +247,8 @@
|
||||
|
||||
// Controls
|
||||
// --------------------------------------------------------------
|
||||
// Hide default controls (can't find -moz -ms prefixes)
|
||||
.plyr ::-webkit-media-controls,
|
||||
.plyr ::-webkit-media-controls-enclosure {
|
||||
// Hide native controls
|
||||
.plyr ::-webkit-media-controls {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@ -256,12 +256,9 @@
|
||||
.plyr__controls {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
line-height: 1;
|
||||
text-align: center;
|
||||
|
||||
transition: opacity .3s ease;
|
||||
|
||||
// Spacing
|
||||
> button,
|
||||
.plyr__progress,
|
||||
@ -325,6 +322,7 @@
|
||||
// Hide controls
|
||||
.plyr--hide-controls .plyr__controls {
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
// Video controls
|
||||
@ -338,6 +336,7 @@
|
||||
border-bottom-left-radius: inherit;
|
||||
border-bottom-right-radius: inherit;
|
||||
color: $plyr-video-control-color;
|
||||
transition: opacity .3s ease;
|
||||
|
||||
button {
|
||||
// Hover and tab focus
|
||||
|
Loading…
x
Reference in New Issue
Block a user