Compare commits
33 Commits
Author | SHA1 | Date | |
---|---|---|---|
0505e49038 | |||
6ff1e47341 | |||
e72a91de6e | |||
52ec4c012d | |||
ae89c92ab6 | |||
57ad124ce8 | |||
a85d45d2e5 | |||
a6f57fc034 | |||
04c9653b86 | |||
b8cdc71001 | |||
277ebf0fd1 | |||
7682d998e7 | |||
05b9b9a831 | |||
eee699cec6 | |||
3c9e9862d8 | |||
39dc651a9d | |||
4effda125a | |||
bf9de231d8 | |||
ef12332505 | |||
1b735f1727 | |||
7f7ecf852e | |||
931672895f | |||
0952bc8239 | |||
7e7508ca82 | |||
095d100ba4 | |||
c61fad51c1 | |||
7b11c6803d | |||
9b75436380 | |||
be19b72719 | |||
2fdcc18356 | |||
cb591dac0c | |||
4c1cdea56e | |||
80cfabbaf9 |
45
changelog.md
45
changelog.md
@ -1,9 +1,50 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
# v1.8.2
|
## v1.8.11
|
||||||
|
- Fix for keyboard navigation on Vimeo (Fixes #317)
|
||||||
|
- Fix for bug introduced in v1.8.9 related to additional controls
|
||||||
|
- Vimeo API upgrade
|
||||||
|
- Fix for YouTube bug introduced in v1.8.9
|
||||||
|
- Added support for passing array to .setup() (Fixes #319)
|
||||||
|
|
||||||
|
## v1.8.10
|
||||||
|
- Fix for seek issues introduced in v1.8.9
|
||||||
|
|
||||||
|
## v1.8.9
|
||||||
|
- Fix for fullscreen not being defined (Fixes #295)
|
||||||
|
- Fix for multiline captions (Fixes #314)
|
||||||
|
- Clean up of type checks and fix for `restart()` (Fixes #315)
|
||||||
|
- Fix for `MEDIA_ERR_SRC_NOT_SUPPORTED` when calling `.source()` API method
|
||||||
|
|
||||||
|
## v1.8.8
|
||||||
|
- Added getCurrentTime API method (fixes #292)
|
||||||
|
- Fix for !hideControls on touch devices (fixes #303)
|
||||||
|
|
||||||
|
## v1.8.7
|
||||||
|
- Line height fix
|
||||||
|
|
||||||
|
## v1.8.6
|
||||||
|
- Reverted font size change
|
||||||
|
|
||||||
|
## v1.8.5
|
||||||
|
- Fixed overflow issues (fixes #286)
|
||||||
|
|
||||||
|
## v1.8.4
|
||||||
|
- Fix for large play button on small videos
|
||||||
|
|
||||||
|
## 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
|
- Fixed event bubbling
|
||||||
|
|
||||||
# v1.8.1
|
## v1.8.1
|
||||||
- Fixed inaccurate log message
|
- Fixed inaccurate log message
|
||||||
|
|
||||||
# v1.8.0
|
# v1.8.0
|
||||||
|
2
demo/dist/demo.css
vendored
2
demo/dist/demo.css
vendored
File diff suppressed because one or more lines are too long
@ -79,7 +79,7 @@
|
|||||||
<script src="dist/demo.js"></script>
|
<script src="dist/demo.js"></script>
|
||||||
|
|
||||||
<!-- Rangetouch to fix <input type="range"> on touch devices (see https://rangetouch.com) -->
|
<!-- 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) -->
|
<!-- Sharing libary (https://shr.one) -->
|
||||||
<script src="https://cdn.shr.one/0.1.9/shr.js"></script>
|
<script src="https://cdn.shr.one/0.1.9/shr.js"></script>
|
||||||
|
@ -21,7 +21,7 @@ video {
|
|||||||
.plyr--audio {
|
.plyr--audio {
|
||||||
max-width: @example-width-audio;
|
max-width: @example-width-audio;
|
||||||
}
|
}
|
||||||
.plyr--video::after {
|
.plyr__video-wrapper::after {
|
||||||
content: "";
|
content: "";
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
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",
|
"name": "plyr",
|
||||||
"version": "1.8.2",
|
"version": "1.8.11",
|
||||||
"description": "A simple, accessible and customizable HTML5, YouTube and Vimeo media player",
|
"description": "A simple, accessible and customizable HTML5, YouTube and Vimeo media player",
|
||||||
"homepage": "http://plyr.io",
|
"homepage": "http://plyr.io",
|
||||||
"main": "src/js/plyr.js",
|
"main": "src/js/plyr.js",
|
||||||
@ -27,7 +27,11 @@
|
|||||||
"keywords": [
|
"keywords": [
|
||||||
"HTML5 Video",
|
"HTML5 Video",
|
||||||
"HTML5 Audio",
|
"HTML5 Audio",
|
||||||
"Media Player"
|
"Media Player",
|
||||||
|
"DASH",
|
||||||
|
"Shaka",
|
||||||
|
"WordPress",
|
||||||
|
"HLS"
|
||||||
],
|
],
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
54
readme.md
54
readme.md
@ -3,7 +3,7 @@ A simple, accessible and customizable HTML5, YouTube and Vimeo media player.
|
|||||||
|
|
||||||
[Checkout the demo](https://plyr.io)
|
[Checkout the demo](https://plyr.io)
|
||||||
|
|
||||||
[](https://plyr.io)
|
[](https://plyr.io)
|
||||||
|
|
||||||
## Why?
|
## 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.
|
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.
|
||||||
@ -21,7 +21,8 @@ We wanted a lightweight, accessible and customizable media player that supports
|
|||||||
- **[Fullscreen](#fullscreen)** - supports native fullscreen with fallback to "full window" modes
|
- **[Fullscreen](#fullscreen)** - supports native fullscreen with fallback to "full window" modes
|
||||||
- **i18n support** - support for internationalization of controls
|
- **i18n support** - support for internationalization of controls
|
||||||
- **No dependencies** - written in "vanilla" JavaScript, no jQuery required
|
- **No dependencies** - written in "vanilla" JavaScript, no jQuery required
|
||||||
- **SASS and LESS provided** - If you like _these_ over plain CSS
|
- **SASS and LESS source** - to include in your build process
|
||||||
|
- **[Streaming](#streaming)** - support for hls.js, Shaka and dash.js streaming playback
|
||||||
|
|
||||||
Oh and yes, it works with Bootstrap.
|
Oh and yes, it works with Bootstrap.
|
||||||
|
|
||||||
@ -38,7 +39,19 @@ 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.
|
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/plugins/plyr/)
|
||||||
|
Created and maintained by Ryan Anthony Drake ([@iamryandrake](https://github.com/iamryandrake))
|
||||||
|
|
||||||
|
### [Neos](https://packagist.org/packages/jonnitto/plyr)
|
||||||
|
Created and maintained by Jon Uhlmann ([@jonnitto](https://github.com/jonnitto))
|
||||||
|
|
||||||
|
### [Kirby](https://github.com/dpschen/kirby-plyrtag)
|
||||||
|
Created and maintained by Dominik Pschenitschni ([@dpschen](https://github.com/dpschen))
|
||||||
|
|
||||||
## Using package managers
|
## Using package managers
|
||||||
|
You can grab the source using one of the following package managers.
|
||||||
|
|
||||||
### npm
|
### npm
|
||||||
```
|
```
|
||||||
@ -61,7 +74,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)
|
More info is on [npm](https://www.npmjs.com/package/ember-cli-plyr) and [GitHub](https://github.com/louisrudner/ember-cli-plyr)
|
||||||
|
|
||||||
|
|
||||||
## Quick setup
|
## Quick setup
|
||||||
Here's a quick run through on getting up and running.
|
Here's a quick run through on getting up and running.
|
||||||
|
|
||||||
@ -69,7 +81,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.
|
Plyr extends upon the standard HTML5 markup so that's all you need for those types.
|
||||||
|
|
||||||
#### HTML5 Video
|
#### HTML5 Video
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<video poster="/path/to/poster.jpg" controls>
|
<video poster="/path/to/poster.jpg" controls>
|
||||||
<source src="/path/to/video.mp4" type="video/mp4">
|
<source src="/path/to/video.mp4" type="video/mp4">
|
||||||
@ -80,7 +91,6 @@ Plyr extends upon the standard HTML5 markup so that's all you need for those typ
|
|||||||
```
|
```
|
||||||
|
|
||||||
#### HTML5 Audio
|
#### HTML5 Audio
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<audio controls>
|
<audio controls>
|
||||||
<source src="/path/to/audio.mp3" type="audio/mp3">
|
<source src="/path/to/audio.mp3" type="audio/mp3">
|
||||||
@ -91,13 +101,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>`):
|
For YouTube and Vimeo, Plyr uses the standard YouTube API markup (an empty `<div>`):
|
||||||
|
|
||||||
#### YouTube embed
|
#### YouTube embed
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<div data-type="youtube" data-video-id="bTqVqk7FSmY"></div>
|
<div data-type="youtube" data-video-id="bTqVqk7FSmY"></div>
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Vimeo embed
|
#### Vimeo embed
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<div data-type="vimeo" data-video-id="143418951"></div>
|
<div data-type="vimeo" data-video-id="143418951"></div>
|
||||||
```
|
```
|
||||||
@ -113,7 +121,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:
|
If you want to use our CDN for the JavaScript, you can use the following:
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<script src="https://cdn.plyr.io/1.8.2/plyr.js"></script>
|
<script src="https://cdn.plyr.io/1.8.11/plyr.js"></script>
|
||||||
```
|
```
|
||||||
|
|
||||||
### CSS
|
### CSS
|
||||||
@ -126,16 +134,18 @@ Include the `plyr.css` stylsheet into your `<head>`
|
|||||||
If you want to use our CDN for the default CSS, you can use the following:
|
If you want to use our CDN for the default CSS, you can use the following:
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<link rel="stylesheet" href="https://cdn.plyr.io/1.8.2/plyr.css">
|
<link rel="stylesheet" href="https://cdn.plyr.io/1.8.11/plyr.css">
|
||||||
```
|
```
|
||||||
|
|
||||||
### SVG Sprite
|
### 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.11/plyr.svg`.
|
||||||
|
|
||||||
## Advanced
|
## Advanced
|
||||||
|
|
||||||
### LESS & SASS/SCSS
|
### LESS & SASS/SCSS
|
||||||
You can use `plyr.less` or `plyr.scss` file included in `/src` as part of your build and change variables to suit your design. The HTML markup uses the BEM methodology with `plyr` as the block, e.g. `.plyr__controls`. You can change the class hooks in the options to match any custom CSS you write. Check out the JavaScript source for more on this.
|
You can use `plyr.less` or `plyr.scss` file included in `/src` as part of your build and change variables to suit your design. The LESS and SASS require you to use the [autoprefixer](https://www.npmjs.com/package/gulp-autoprefixer) plugin (you should already) as all declerations use the W3C definitions - e.g. `appearance: none;` will be prefixed to `-webkit-appearance: none;` by autoprefixer.
|
||||||
|
|
||||||
|
The HTML markup uses the BEM methodology with `plyr` as the block, e.g. `.plyr__controls`. You can change the class hooks in the options to match any custom CSS you write. Check out the JavaScript source for more on this.
|
||||||
|
|
||||||
### SVG
|
### SVG
|
||||||
The 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 system in place, you can include the source plyr icons (see `/src/sprite` for source icons).
|
The 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 system in place, you can include the source plyr icons (see `/src/sprite` for source icons).
|
||||||
@ -192,7 +202,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.
|
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
|
||||||
|
|
||||||
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:
|
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
|
```html
|
||||||
@ -202,7 +211,7 @@ 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.
|
Note the single quotes encapsulating the JSON and double quotes on the object keys.
|
||||||
|
|
||||||
<table class="table" width="100%">
|
<table class="table" width="100%">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th width="20%">Option</th>
|
<th width="20%">Option</th>
|
||||||
<th width="15%">Type</th>
|
<th width="15%">Type</th>
|
||||||
@ -365,7 +374,7 @@ Note the single quotes encapsulating the JSON and double quotes on the object ke
|
|||||||
#### Fullscreen options
|
#### Fullscreen options
|
||||||
|
|
||||||
<table class="table" width="100%" id="fullscreen-options">
|
<table class="table" width="100%" id="fullscreen-options">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th width="20%">Option</th>
|
<th width="20%">Option</th>
|
||||||
<th width="15%">Type</th>
|
<th width="15%">Type</th>
|
||||||
@ -529,11 +538,15 @@ Here's a list of the methods supported:
|
|||||||
<td>—</td>
|
<td>—</td>
|
||||||
<td>Reverses the effects of the <code>destroy()</code> method, restoring the UI and listeners.</td>
|
<td>Reverses the effects of the <code>destroy()</code> method, restoring the UI and listeners.</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>getCurrentTime()</code></td>
|
||||||
|
<td>—</td>
|
||||||
|
<td>Will return a float with the current time in seconds.</td>
|
||||||
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
#### .source() method
|
#### .source() method
|
||||||
|
|
||||||
This allows changing the plyr source and type on the fly.
|
This allows changing the plyr source and type on the fly.
|
||||||
|
|
||||||
Video example:
|
Video example:
|
||||||
@ -643,9 +656,7 @@ Some more details on the object parameters
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|
||||||
## Events
|
## 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.
|
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%">
|
<table class="table" width="100%">
|
||||||
@ -788,7 +799,6 @@ document.querySelector('.js-plyr').addEventListener('ready', function(event) {
|
|||||||
These events also bubble up the DOM.
|
These events also bubble up the DOM.
|
||||||
|
|
||||||
## Embeds
|
## Embeds
|
||||||
|
|
||||||
YouTube and Vimeo are currently supported and function much like a HTML5 video. Check the relevant documentation sections for any differences.
|
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.
|
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 +823,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.
|
*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.
|
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
|
## Browser support
|
||||||
|
340
src/js/plyr.js
340
src/js/plyr.js
@ -1,6 +1,6 @@
|
|||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
// Plyr
|
// Plyr
|
||||||
// plyr.js v1.8.2
|
// plyr.js v1.8.11
|
||||||
// https://github.com/selz/plyr
|
// https://github.com/selz/plyr
|
||||||
// License: The MIT License (MIT)
|
// License: The MIT License (MIT)
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
@ -23,7 +23,6 @@
|
|||||||
}
|
}
|
||||||
}(typeof window !== 'undefined' ? window : this, function(window, document) {
|
}(typeof window !== 'undefined' ? window : this, function(window, document) {
|
||||||
'use strict';
|
'use strict';
|
||||||
/*global YT,$f*/
|
|
||||||
|
|
||||||
// Globals
|
// Globals
|
||||||
var fullscreen,
|
var fullscreen,
|
||||||
@ -44,7 +43,7 @@
|
|||||||
displayDuration: true,
|
displayDuration: true,
|
||||||
loadSprite: true,
|
loadSprite: true,
|
||||||
iconPrefix: 'plyr',
|
iconPrefix: 'plyr',
|
||||||
iconUrl: 'https://cdn.plyr.io/1.8.2/plyr.svg',
|
iconUrl: 'https://cdn.plyr.io/1.8.11/plyr.svg',
|
||||||
clickToPlay: true,
|
clickToPlay: true,
|
||||||
hideControls: true,
|
hideControls: true,
|
||||||
showPosterOnEnd: false,
|
showPosterOnEnd: false,
|
||||||
@ -146,7 +145,7 @@
|
|||||||
// URLs
|
// URLs
|
||||||
urls: {
|
urls: {
|
||||||
vimeo: {
|
vimeo: {
|
||||||
api: 'https://cdn.plyr.io/froogaloop/1.0.1/plyr.froogaloop.js',
|
api: 'https://player.vimeo.com/api/player.js',
|
||||||
},
|
},
|
||||||
youtube: {
|
youtube: {
|
||||||
api: 'https://www.youtube.com/iframe_api'
|
api: 'https://www.youtube.com/iframe_api'
|
||||||
@ -191,7 +190,7 @@
|
|||||||
if ((navigator.appVersion.indexOf('Windows NT') !== -1) && (navigator.appVersion.indexOf('rv:11') !== -1)) {
|
if ((navigator.appVersion.indexOf('Windows NT') !== -1) && (navigator.appVersion.indexOf('rv:11') !== -1)) {
|
||||||
isIE = true;
|
isIE = true;
|
||||||
name = 'IE';
|
name = 'IE';
|
||||||
fullVersion = '11;';
|
fullVersion = '11';
|
||||||
}
|
}
|
||||||
// MSIE
|
// MSIE
|
||||||
else if ((verOffset = ua.indexOf('MSIE')) !== -1) {
|
else if ((verOffset = ua.indexOf('MSIE')) !== -1) {
|
||||||
@ -253,8 +252,8 @@
|
|||||||
isFirefox: isFirefox,
|
isFirefox: isFirefox,
|
||||||
isChrome: isChrome,
|
isChrome: isChrome,
|
||||||
isSafari: isSafari,
|
isSafari: isSafari,
|
||||||
ios: /(iPad|iPhone|iPod)/g.test(navigator.platform),
|
isIos: /(iPad|iPhone|iPod)/g.test(navigator.platform),
|
||||||
touch: 'ontouchstart' in document.documentElement
|
isTouch: 'ontouchstart' in document.documentElement
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -376,7 +375,7 @@
|
|||||||
// Set attributes
|
// Set attributes
|
||||||
function _setAttributes(element, attributes) {
|
function _setAttributes(element, attributes) {
|
||||||
for (var key in attributes) {
|
for (var key in attributes) {
|
||||||
element.setAttribute(key, (typeof attributes[key] === 'boolean' && attributes[key]) ? '' : attributes[key]);
|
element.setAttribute(key, (_is.boolean(attributes[key]) && attributes[key]) ? '' : attributes[key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -464,7 +463,7 @@
|
|||||||
|
|
||||||
// Whether the listener is a capturing listener or not
|
// Whether the listener is a capturing listener or not
|
||||||
// Default to false
|
// Default to false
|
||||||
if (typeof useCapture !== 'boolean') {
|
if (!_is.boolean(useCapture)) {
|
||||||
useCapture = false;
|
useCapture = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -492,7 +491,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Default bubbles to false
|
// Default bubbles to false
|
||||||
if (typeof bubbles !== 'boolean') {
|
if (!_is.boolean(bubbles)) {
|
||||||
bubbles = false;
|
bubbles = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -515,7 +514,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get state
|
// Get state
|
||||||
state = (typeof state === 'boolean' ? state : !target.getAttribute('aria-pressed'));
|
state = (_is.boolean(state) ? state : !target.getAttribute('aria-pressed'));
|
||||||
|
|
||||||
// Set the attribute on target
|
// Set the attribute on target
|
||||||
target.setAttribute('aria-pressed', state);
|
target.setAttribute('aria-pressed', state);
|
||||||
@ -570,6 +569,34 @@
|
|||||||
return destination;
|
return destination;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check variable types
|
||||||
|
var _is = {
|
||||||
|
object: function(input) {
|
||||||
|
return input !== null && typeof(input) === 'object';
|
||||||
|
},
|
||||||
|
array: function(input) {
|
||||||
|
return input !== null && typeof(input) === 'object' && input.constructor === Array;
|
||||||
|
},
|
||||||
|
number: function(input) {
|
||||||
|
return typeof(input) === 'number' && !isNaN(input - 0) || (typeof input == 'object' && input.constructor === Number);
|
||||||
|
},
|
||||||
|
string: function(input) {
|
||||||
|
return typeof input === 'string' || (typeof input == 'object' && input.constructor === String);
|
||||||
|
},
|
||||||
|
boolean: function(input) {
|
||||||
|
return typeof input === 'boolean';
|
||||||
|
},
|
||||||
|
nodeList: function(input) {
|
||||||
|
return input instanceof NodeList;
|
||||||
|
},
|
||||||
|
htmlElement: function(input) {
|
||||||
|
return input instanceof HTMLElement;
|
||||||
|
},
|
||||||
|
undefined: function(input) {
|
||||||
|
return typeof input === 'undefined';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Fullscreen API
|
// Fullscreen API
|
||||||
function _fullscreen() {
|
function _fullscreen() {
|
||||||
var fullscreen = {
|
var fullscreen = {
|
||||||
@ -584,7 +611,7 @@
|
|||||||
browserPrefixes = 'webkit moz o ms khtml'.split(' ');
|
browserPrefixes = 'webkit moz o ms khtml'.split(' ');
|
||||||
|
|
||||||
// Check for native support
|
// Check for native support
|
||||||
if (typeof document.cancelFullScreen !== 'undefined') {
|
if (!_is.undefined(document.cancelFullScreen)) {
|
||||||
fullscreen.supportsFullScreen = true;
|
fullscreen.supportsFullScreen = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -592,12 +619,12 @@
|
|||||||
for (var i = 0, il = browserPrefixes.length; i < il; i++ ) {
|
for (var i = 0, il = browserPrefixes.length; i < il; i++ ) {
|
||||||
fullscreen.prefix = browserPrefixes[i];
|
fullscreen.prefix = browserPrefixes[i];
|
||||||
|
|
||||||
if (typeof document[fullscreen.prefix + 'CancelFullScreen'] !== 'undefined') {
|
if (!_is.undefined(document[fullscreen.prefix + 'CancelFullScreen'])) {
|
||||||
fullscreen.supportsFullScreen = true;
|
fullscreen.supportsFullScreen = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Special case for MS (when isn't it?)
|
// Special case for MS (when isn't it?)
|
||||||
else if (typeof document.msExitFullscreen !== 'undefined' && document.msFullscreenEnabled) {
|
else if (!_is.undefined(document.msExitFullscreen) && document.msFullscreenEnabled) {
|
||||||
fullscreen.prefix = 'ms';
|
fullscreen.prefix = 'ms';
|
||||||
fullscreen.supportsFullScreen = true;
|
fullscreen.supportsFullScreen = true;
|
||||||
break;
|
break;
|
||||||
@ -612,7 +639,7 @@
|
|||||||
fullscreen.fullScreenEventName = (fullscreen.prefix == 'ms' ? 'MSFullscreenChange' : fullscreen.prefix + 'fullscreenchange');
|
fullscreen.fullScreenEventName = (fullscreen.prefix == 'ms' ? 'MSFullscreenChange' : fullscreen.prefix + 'fullscreenchange');
|
||||||
|
|
||||||
fullscreen.isFullScreen = function(element) {
|
fullscreen.isFullScreen = function(element) {
|
||||||
if (typeof element === 'undefined') {
|
if (_is.undefined(element)) {
|
||||||
element = document.body;
|
element = document.body;
|
||||||
}
|
}
|
||||||
switch (this.prefix) {
|
switch (this.prefix) {
|
||||||
@ -625,7 +652,7 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
fullscreen.requestFullScreen = function(element) {
|
fullscreen.requestFullScreen = function(element) {
|
||||||
if (typeof element === 'undefined') {
|
if (_is.undefined(element)) {
|
||||||
element = document.body;
|
element = document.body;
|
||||||
}
|
}
|
||||||
return (this.prefix === '') ? element.requestFullScreen() : element[this.prefix + (this.prefix == 'ms' ? 'RequestFullscreen' : 'RequestFullScreen')]();
|
return (this.prefix === '') ? element.requestFullScreen() : element[this.prefix + (this.prefix == 'ms' ? 'RequestFullscreen' : 'RequestFullScreen')]();
|
||||||
@ -684,9 +711,14 @@
|
|||||||
_log(config);
|
_log(config);
|
||||||
|
|
||||||
// Debugging
|
// Debugging
|
||||||
function _log(text, warn) {
|
function _log() {
|
||||||
if (config.debug && window.console) {
|
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 +726,7 @@
|
|||||||
function _getIconUrl() {
|
function _getIconUrl() {
|
||||||
return {
|
return {
|
||||||
url: config.iconUrl,
|
url: config.iconUrl,
|
||||||
external: (config.iconUrl.indexOf("http") === 0)
|
absolute: (config.iconUrl.indexOf("http") === 0) || plyr.browser.isIE
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -703,7 +735,7 @@
|
|||||||
// Create html array
|
// Create html array
|
||||||
var html = [],
|
var html = [],
|
||||||
iconUrl = _getIconUrl(),
|
iconUrl = _getIconUrl(),
|
||||||
iconPath = (!iconUrl.external ? iconUrl.url : '') + '#' + config.iconPrefix;
|
iconPath = (!iconUrl.absolute ? iconUrl.url : '') + '#' + config.iconPrefix;
|
||||||
|
|
||||||
// Larger overlaid play button
|
// Larger overlaid play button
|
||||||
if (_inArray(config.controls, 'play-large')) {
|
if (_inArray(config.controls, 'play-large')) {
|
||||||
@ -873,7 +905,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Toggle state
|
// Toggle state
|
||||||
|
if (plyr.buttons && plyr.buttons.fullscreen) {
|
||||||
_toggleState(plyr.buttons.fullscreen, false);
|
_toggleState(plyr.buttons.fullscreen, false);
|
||||||
|
}
|
||||||
|
|
||||||
// Setup focus trap
|
// Setup focus trap
|
||||||
_focusTrap();
|
_focusTrap();
|
||||||
@ -882,6 +916,7 @@
|
|||||||
|
|
||||||
// Setup captions
|
// Setup captions
|
||||||
function _setupCaptions() {
|
function _setupCaptions() {
|
||||||
|
// Bail if not HTML5 video
|
||||||
if (plyr.type !== 'video') {
|
if (plyr.type !== 'video') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1013,7 +1048,7 @@
|
|||||||
_log('Successfully loaded the caption file via AJAX');
|
_log('Successfully loaded the caption file via AJAX');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
_log('There was a problem loading the caption file via AJAX', true);
|
_warn('There was a problem loading the caption file via AJAX');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -1036,12 +1071,12 @@
|
|||||||
container.innerHTML = '';
|
container.innerHTML = '';
|
||||||
|
|
||||||
// Default to empty
|
// Default to empty
|
||||||
if (typeof caption === 'undefined') {
|
if (_is.undefined(caption)) {
|
||||||
caption = '';
|
caption = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the span content
|
// Set the span content
|
||||||
if (typeof caption === 'string') {
|
if (_is.undefined(caption)) {
|
||||||
content.innerHTML = caption.trim();
|
content.innerHTML = caption.trim();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -1101,7 +1136,7 @@
|
|||||||
// Check time is a number, if not use currentTime
|
// Check time is a number, if not use currentTime
|
||||||
// IE has a bug where currentTime doesn't go to 0
|
// IE has a bug where currentTime doesn't go to 0
|
||||||
// https://twitter.com/Sam_Potts/status/573715746506731521
|
// https://twitter.com/Sam_Potts/status/573715746506731521
|
||||||
time = typeof time === 'number' ? time : plyr.media.currentTime;
|
time = _is.number(time) ? time : plyr.media.currentTime;
|
||||||
|
|
||||||
// If there's no subs available, bail
|
// If there's no subs available, bail
|
||||||
if (!plyr.captions[plyr.subcount]) {
|
if (!plyr.captions[plyr.subcount]) {
|
||||||
@ -1192,7 +1227,7 @@
|
|||||||
|
|
||||||
// Add elements to HTML5 media (source, tracks, etc)
|
// Add elements to HTML5 media (source, tracks, etc)
|
||||||
function _insertChildElements(type, attributes) {
|
function _insertChildElements(type, attributes) {
|
||||||
if (typeof attributes === 'string') {
|
if (_is.string(attributes)) {
|
||||||
_insertElement(type, plyr.media, { src: attributes });
|
_insertElement(type, plyr.media, { src: attributes });
|
||||||
}
|
}
|
||||||
else if (attributes.constructor === Array) {
|
else if (attributes.constructor === Array) {
|
||||||
@ -1206,12 +1241,11 @@
|
|||||||
function _injectControls() {
|
function _injectControls() {
|
||||||
// Sprite
|
// Sprite
|
||||||
if (config.loadSprite) {
|
if (config.loadSprite) {
|
||||||
var iconUrl = _getIconUrl(),
|
var iconUrl = _getIconUrl();
|
||||||
isExternal = iconUrl.external;
|
|
||||||
|
|
||||||
// Only load external sprite using AJAX
|
// Only load external sprite using AJAX
|
||||||
if (isExternal || plyr.browser.isIE) {
|
if (iconUrl.absolute) {
|
||||||
_log('AJAX loading external SVG sprite' + (plyr.browser.isIE ? ' (due to IE)' : ''));
|
_log('AJAX loading absolute SVG sprite' + (plyr.browser.isIE ? ' (due to IE)' : ''));
|
||||||
loadSprite(iconUrl.url, "sprite-plyr");
|
loadSprite(iconUrl.url, "sprite-plyr");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -1243,13 +1277,13 @@
|
|||||||
if (config.selectors.controls.container !== null) {
|
if (config.selectors.controls.container !== null) {
|
||||||
container = config.selectors.controls.container;
|
container = config.selectors.controls.container;
|
||||||
|
|
||||||
if (typeof selector === 'string') {
|
if (_is.string(container)) {
|
||||||
container = document.querySelector(container);
|
container = document.querySelector(container);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inject into the container by default
|
// Inject into the container by default
|
||||||
if (!(container instanceof HTMLElement)) {
|
if (!_is.htmlElement(container)) {
|
||||||
container = plyr.container
|
container = plyr.container
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1316,7 +1350,7 @@
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch(e) {
|
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
|
// Restore native video controls
|
||||||
_toggleNativeControls(true);
|
_toggleNativeControls(true);
|
||||||
@ -1332,7 +1366,7 @@
|
|||||||
|
|
||||||
// Toggle native controls
|
// Toggle native controls
|
||||||
function _toggleNativeControls(toggle) {
|
function _toggleNativeControls(toggle) {
|
||||||
if (toggle) {
|
if (toggle && _inArray(config.types.html5, plyr.type)) {
|
||||||
plyr.media.setAttribute('controls', '');
|
plyr.media.setAttribute('controls', '');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -1346,7 +1380,7 @@
|
|||||||
var label = config.i18n.play;
|
var label = config.i18n.play;
|
||||||
|
|
||||||
// If there's a media title set, use that for the label
|
// If there's a media title set, use that for the label
|
||||||
if (typeof(config.title) !== 'undefined' && config.title.length) {
|
if (!_is.undefined(config.title) && config.title.length) {
|
||||||
label += ', ' + config.title;
|
label += ', ' + config.title;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1359,7 +1393,7 @@
|
|||||||
|
|
||||||
// Set iframe title
|
// Set iframe title
|
||||||
// https://github.com/Selz/plyr/issues/124
|
// https://github.com/Selz/plyr/issues/124
|
||||||
if (iframe instanceof HTMLElement) {
|
if (_is.htmlElement(iframe)) {
|
||||||
iframe.setAttribute('title', config.i18n.frameTitle.replace('{title}', config.title));
|
iframe.setAttribute('title', config.i18n.frameTitle.replace('{title}', config.title));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1368,8 +1402,8 @@
|
|||||||
function _setupMedia() {
|
function _setupMedia() {
|
||||||
// If there's no media, bail
|
// If there's no media, bail
|
||||||
if (!plyr.media) {
|
if (!plyr.media) {
|
||||||
_log('No audio or video element found', true);
|
_warn('No media element found!');
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plyr.supported.full) {
|
if (plyr.supported.full) {
|
||||||
@ -1386,10 +1420,10 @@
|
|||||||
_toggleClass(plyr.container, config.classes.stopped, config.autoplay);
|
_toggleClass(plyr.container, config.classes.stopped, config.autoplay);
|
||||||
|
|
||||||
// Add iOS class
|
// Add iOS class
|
||||||
_toggleClass(plyr.container, config.classes.isIos, plyr.browser.ios);
|
_toggleClass(plyr.container, config.classes.isIos, plyr.browser.isIos);
|
||||||
|
|
||||||
// Add touch class
|
// 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
|
// Inject the player wrapper
|
||||||
if (plyr.type === 'video') {
|
if (plyr.type === 'video') {
|
||||||
@ -1439,7 +1473,7 @@
|
|||||||
container.setAttribute('id', id);
|
container.setAttribute('id', id);
|
||||||
|
|
||||||
// Setup API
|
// Setup API
|
||||||
if (typeof YT === 'object') {
|
if (_is.object(window.YT)) {
|
||||||
_youTubeReady(mediaId, container);
|
_youTubeReady(mediaId, container);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -1460,42 +1494,28 @@
|
|||||||
}
|
}
|
||||||
// Vimeo
|
// Vimeo
|
||||||
else if (plyr.type === 'vimeo') {
|
else if (plyr.type === 'vimeo') {
|
||||||
// Inject the iframe
|
// Create the YouTube container
|
||||||
var vimeo = document.createElement('iframe');
|
|
||||||
|
|
||||||
// Watch for iframe load
|
|
||||||
vimeo.loaded = false;
|
|
||||||
_on(vimeo, 'load', function() { vimeo.loaded = true; });
|
|
||||||
|
|
||||||
_setAttributes(vimeo, {
|
|
||||||
'src': 'https://player.vimeo.com/video/' + mediaId + '?player_id=' + id + '&api=1&badge=0&byline=0&portrait=0&title=0',
|
|
||||||
'id': id,
|
|
||||||
'allowfullscreen': '',
|
|
||||||
'frameborder': 0
|
|
||||||
});
|
|
||||||
|
|
||||||
// If full support, we can use custom controls (hiding Vimeos), if not, use Vimeo
|
|
||||||
if (plyr.supported.full) {
|
|
||||||
container.appendChild(vimeo);
|
|
||||||
plyr.media.appendChild(container);
|
plyr.media.appendChild(container);
|
||||||
}
|
|
||||||
else {
|
// Set ID
|
||||||
plyr.media.appendChild(vimeo);
|
container.setAttribute('id', id);
|
||||||
}
|
|
||||||
|
|
||||||
// Load the API if not already
|
// Load the API if not already
|
||||||
if (!('$f' in window)) {
|
if (!_is.object(window.Vimeo)) {
|
||||||
_injectScript(config.urls.vimeo.api);
|
_injectScript(config.urls.vimeo.api);
|
||||||
}
|
|
||||||
|
|
||||||
// Wait for fragaloop load
|
// Wait for fragaloop load
|
||||||
var vimeoTimer = window.setInterval(function() {
|
var vimeoTimer = window.setInterval(function() {
|
||||||
if ('$f' in window && vimeo.loaded) {
|
if (_is.object(window.Vimeo)) {
|
||||||
window.clearInterval(vimeoTimer);
|
window.clearInterval(vimeoTimer);
|
||||||
_vimeoReady.call(vimeo);
|
_vimeoReady(mediaId, container);
|
||||||
}
|
}
|
||||||
}, 50);
|
}, 50);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
_vimeoReady(mediaId, container);
|
||||||
|
}
|
||||||
|
}
|
||||||
// Soundcloud
|
// Soundcloud
|
||||||
else if (plyr.type === 'soundcloud') {
|
else if (plyr.type === 'soundcloud') {
|
||||||
// Inject the iframe
|
// Inject the iframe
|
||||||
@ -1533,8 +1553,10 @@
|
|||||||
// Store reference to API
|
// Store reference to API
|
||||||
plyr.container.plyr.embed = plyr.embed;
|
plyr.container.plyr.embed = plyr.embed;
|
||||||
|
|
||||||
// Setup the UI
|
// Setup the UI if full support
|
||||||
|
if (plyr.supported.full) {
|
||||||
_setupInterface();
|
_setupInterface();
|
||||||
|
}
|
||||||
|
|
||||||
// Set title
|
// Set title
|
||||||
_setTitle(_getElement('iframe'));
|
_setTitle(_getElement('iframe'));
|
||||||
@ -1550,7 +1572,7 @@
|
|||||||
|
|
||||||
// Setup instance
|
// Setup instance
|
||||||
// https://developers.google.com/youtube/iframe_api_reference
|
// https://developers.google.com/youtube/iframe_api_reference
|
||||||
plyr.embed = new YT.Player(container.id, {
|
plyr.embed = new window.YT.Player(container.id, {
|
||||||
videoId: videoId,
|
videoId: videoId,
|
||||||
playerVars: {
|
playerVars: {
|
||||||
autoplay: (config.autoplay ? 1 : 0),
|
autoplay: (config.autoplay ? 1 : 0),
|
||||||
@ -1678,24 +1700,28 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Vimeo ready
|
// Vimeo ready
|
||||||
function _vimeoReady() {
|
function _vimeoReady(mediaId, container) {
|
||||||
/* jshint validthis: true */
|
// Setup player
|
||||||
plyr.embed = $f(this);
|
plyr.embed = new window.Vimeo.Player(container.id, {
|
||||||
|
id: mediaId,
|
||||||
// Setup on ready
|
loop: config.loop,
|
||||||
plyr.embed.addEvent('ready', function() {
|
autoplay: config.autoplay,
|
||||||
|
byline: false,
|
||||||
|
portrait: false,
|
||||||
|
title: false
|
||||||
|
});
|
||||||
|
|
||||||
// Create a faux HTML5 API using the Vimeo API
|
// Create a faux HTML5 API using the Vimeo API
|
||||||
plyr.media.play = function() {
|
plyr.media.play = function() {
|
||||||
plyr.embed.api('play');
|
plyr.embed.play();
|
||||||
plyr.media.paused = false;
|
plyr.media.paused = false;
|
||||||
};
|
};
|
||||||
plyr.media.pause = function() {
|
plyr.media.pause = function() {
|
||||||
plyr.embed.api('pause');
|
plyr.embed.pause();
|
||||||
plyr.media.paused = true;
|
plyr.media.paused = true;
|
||||||
};
|
};
|
||||||
plyr.media.stop = function() {
|
plyr.media.stop = function() {
|
||||||
plyr.embed.api('stop');
|
plyr.embed.stop();
|
||||||
plyr.media.paused = true;
|
plyr.media.paused = true;
|
||||||
};
|
};
|
||||||
plyr.media.paused = true;
|
plyr.media.paused = true;
|
||||||
@ -1704,38 +1730,43 @@
|
|||||||
// Update UI
|
// Update UI
|
||||||
_embedReady();
|
_embedReady();
|
||||||
|
|
||||||
plyr.embed.api('getCurrentTime', function (value) {
|
plyr.embed.getCurrentTime().then(function (value) {
|
||||||
plyr.media.currentTime = value;
|
plyr.media.currentTime = value;
|
||||||
|
|
||||||
// Trigger timeupdate
|
// Trigger timeupdate
|
||||||
_triggerEvent(plyr.media, 'timeupdate');
|
_triggerEvent(plyr.media, 'timeupdate');
|
||||||
});
|
});
|
||||||
|
|
||||||
plyr.embed.api('getDuration', function(value) {
|
plyr.embed.getDuration().then(function(value) {
|
||||||
plyr.media.duration = value;
|
plyr.media.duration = value;
|
||||||
|
|
||||||
// Display duration if available
|
// Display duration if available
|
||||||
_displayDuration();
|
_displayDuration();
|
||||||
});
|
});
|
||||||
|
|
||||||
plyr.embed.addEvent('play', function() {
|
// Captions
|
||||||
|
if (config.captions.defaultActive) {
|
||||||
|
plyr.embed.enableTextTrack('en');
|
||||||
|
}
|
||||||
|
|
||||||
|
plyr.embed.on('play', function() {
|
||||||
plyr.media.paused = false;
|
plyr.media.paused = false;
|
||||||
_triggerEvent(plyr.media, 'play');
|
_triggerEvent(plyr.media, 'play');
|
||||||
_triggerEvent(plyr.media, 'playing');
|
_triggerEvent(plyr.media, 'playing');
|
||||||
});
|
});
|
||||||
|
|
||||||
plyr.embed.addEvent('pause', function() {
|
plyr.embed.on('pause', function() {
|
||||||
plyr.media.paused = true;
|
plyr.media.paused = true;
|
||||||
_triggerEvent(plyr.media, 'pause');
|
_triggerEvent(plyr.media, 'pause');
|
||||||
});
|
});
|
||||||
|
|
||||||
plyr.embed.addEvent('playProgress', function(data) {
|
plyr.embed.on('timeupdate', function(data) {
|
||||||
plyr.media.seeking = false;
|
plyr.media.seeking = false;
|
||||||
plyr.media.currentTime = data.seconds;
|
plyr.media.currentTime = data.seconds;
|
||||||
_triggerEvent(plyr.media, 'timeupdate');
|
_triggerEvent(plyr.media, 'timeupdate');
|
||||||
});
|
});
|
||||||
|
|
||||||
plyr.embed.addEvent('loadProgress', function(data) {
|
plyr.embed.on('progress', function(data) {
|
||||||
plyr.media.buffered = data.percent;
|
plyr.media.buffered = data.percent;
|
||||||
_triggerEvent(plyr.media, 'progress');
|
_triggerEvent(plyr.media, 'progress');
|
||||||
|
|
||||||
@ -1745,19 +1776,10 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
plyr.embed.addEvent('finish', function() {
|
plyr.embed.on('ended', function() {
|
||||||
plyr.media.paused = true;
|
plyr.media.paused = true;
|
||||||
_triggerEvent(plyr.media, 'ended');
|
_triggerEvent(plyr.media, 'ended');
|
||||||
});
|
});
|
||||||
|
|
||||||
// Always seek to 0
|
|
||||||
// plyr.embed.api('seekTo', 0);
|
|
||||||
|
|
||||||
// Autoplay
|
|
||||||
if (config.autoplay) {
|
|
||||||
plyr.embed.api('play');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Soundcloud ready
|
// Soundcloud ready
|
||||||
@ -1872,7 +1894,7 @@
|
|||||||
// Rewind
|
// Rewind
|
||||||
function _rewind(seekTime) {
|
function _rewind(seekTime) {
|
||||||
// Use default if needed
|
// Use default if needed
|
||||||
if (typeof seekTime !== 'number') {
|
if (!_is.number(seekTime)) {
|
||||||
seekTime = config.seekTime;
|
seekTime = config.seekTime;
|
||||||
}
|
}
|
||||||
_seek(plyr.media.currentTime - seekTime);
|
_seek(plyr.media.currentTime - seekTime);
|
||||||
@ -1881,7 +1903,7 @@
|
|||||||
// Fast forward
|
// Fast forward
|
||||||
function _forward(seekTime) {
|
function _forward(seekTime) {
|
||||||
// Use default if needed
|
// Use default if needed
|
||||||
if (typeof seekTime !== 'number') {
|
if (!_is.number(seekTime)) {
|
||||||
seekTime = config.seekTime;
|
seekTime = config.seekTime;
|
||||||
}
|
}
|
||||||
_seek(plyr.media.currentTime + seekTime);
|
_seek(plyr.media.currentTime + seekTime);
|
||||||
@ -1895,11 +1917,11 @@
|
|||||||
duration = _getDuration();
|
duration = _getDuration();
|
||||||
|
|
||||||
// Explicit position
|
// Explicit position
|
||||||
if (typeof input === 'number') {
|
if (_is.number(input)) {
|
||||||
targetTime = input;
|
targetTime = input;
|
||||||
}
|
}
|
||||||
// Event
|
// Event
|
||||||
else if (typeof input === 'object' && (input.type === 'input' || input.type === 'change')) {
|
else if (_is.object(input) && _inArray(['input', 'change'], input.type)) {
|
||||||
// It's the seek slider
|
// It's the seek slider
|
||||||
// Seek to the selected time
|
// Seek to the selected time
|
||||||
targetTime = ((input.target.value / input.target.max) * duration);
|
targetTime = ((input.target.value / input.target.max) * duration);
|
||||||
@ -1933,7 +1955,7 @@
|
|||||||
|
|
||||||
case 'vimeo':
|
case 'vimeo':
|
||||||
// Round to nearest second for vimeo
|
// Round to nearest second for vimeo
|
||||||
plyr.embed.api('seekTo', targetTime.toFixed(0));
|
plyr.embed.setCurrentTime(targetTime.toFixed(0));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'soundcloud':
|
case 'soundcloud':
|
||||||
@ -2054,7 +2076,9 @@
|
|||||||
_focusTrap(plyr.isFullscreen);
|
_focusTrap(plyr.isFullscreen);
|
||||||
|
|
||||||
// Set button state
|
// Set button state
|
||||||
|
if (plyr.buttons && plyr.buttons.fullscreen) {
|
||||||
_toggleState(plyr.buttons.fullscreen, plyr.isFullscreen);
|
_toggleState(plyr.buttons.fullscreen, plyr.isFullscreen);
|
||||||
|
}
|
||||||
|
|
||||||
// Trigger an event
|
// Trigger an event
|
||||||
_triggerEvent(plyr.container, plyr.isFullscreen ? 'enterfullscreen' : 'exitfullscreen', true);
|
_triggerEvent(plyr.container, plyr.isFullscreen ? 'enterfullscreen' : 'exitfullscreen', true);
|
||||||
@ -2076,7 +2100,7 @@
|
|||||||
// Mute
|
// Mute
|
||||||
function _toggleMute(muted) {
|
function _toggleMute(muted) {
|
||||||
// If the method is called without parameter, toggle based on current value
|
// If the method is called without parameter, toggle based on current value
|
||||||
if (typeof muted !== 'boolean') {
|
if (!_is.boolean(muted)) {
|
||||||
muted = !plyr.media.muted;
|
muted = !plyr.media.muted;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2100,9 +2124,6 @@
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'vimeo':
|
case 'vimeo':
|
||||||
plyr.embed.api('setVolume', plyr.media.muted ? 0 : parseFloat(config.volume / config.volumeMax));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'soundcloud':
|
case 'soundcloud':
|
||||||
plyr.embed.setVolume(plyr.media.muted ? 0 : parseFloat(config.volume / config.volumeMax));
|
plyr.embed.setVolume(plyr.media.muted ? 0 : parseFloat(config.volume / config.volumeMax));
|
||||||
break;
|
break;
|
||||||
@ -2119,7 +2140,7 @@
|
|||||||
min = config.volumeMin;
|
min = config.volumeMin;
|
||||||
|
|
||||||
// Use default if no value specified
|
// Use default if no value specified
|
||||||
if (typeof volume === 'undefined') {
|
if (_is.undefined(volume)) {
|
||||||
volume = config.volume;
|
volume = config.volume;
|
||||||
|
|
||||||
if (config.storage.enabled && _storage().supported) {
|
if (config.storage.enabled && _storage().supported) {
|
||||||
@ -2155,16 +2176,12 @@
|
|||||||
|
|
||||||
// Embeds
|
// Embeds
|
||||||
if (_inArray(config.types.embed, plyr.type)) {
|
if (_inArray(config.types.embed, plyr.type)) {
|
||||||
// YouTube
|
|
||||||
switch(plyr.type) {
|
switch(plyr.type) {
|
||||||
case 'youtube':
|
case 'youtube':
|
||||||
plyr.embed.setVolume(plyr.media.volume * 100);
|
plyr.embed.setVolume(plyr.media.volume * 100);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'vimeo':
|
case 'vimeo':
|
||||||
plyr.embed.api('setVolume', plyr.media.volume);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'soundcloud':
|
case 'soundcloud':
|
||||||
plyr.embed.setVolume(plyr.media.volume);
|
plyr.embed.setVolume(plyr.media.volume);
|
||||||
break;
|
break;
|
||||||
@ -2231,7 +2248,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If the method is called without parameter, toggle based on current value
|
// If the method is called without parameter, toggle based on current value
|
||||||
if (typeof show !== 'boolean') {
|
if (!_is.boolean(show)) {
|
||||||
show = (plyr.container.className.indexOf(config.classes.captions.active) === -1);
|
show = (plyr.container.className.indexOf(config.classes.captions.active) === -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2276,6 +2293,10 @@
|
|||||||
// Video playing
|
// Video playing
|
||||||
case 'timeupdate':
|
case 'timeupdate':
|
||||||
case 'seeking':
|
case 'seeking':
|
||||||
|
if (plyr.controls.pressed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
value = _getPercentage(plyr.media.currentTime, duration);
|
value = _getPercentage(plyr.media.currentTime, duration);
|
||||||
|
|
||||||
// Set seek range value only if it's a 'natural' time event
|
// Set seek range value only if it's a 'natural' time event
|
||||||
@ -2297,7 +2318,7 @@
|
|||||||
return _getPercentage(buffered.end(0), duration);
|
return _getPercentage(buffered.end(0), duration);
|
||||||
}
|
}
|
||||||
// YouTube returns between 0 and 1
|
// YouTube returns between 0 and 1
|
||||||
else if (typeof buffered === 'number') {
|
else if (_is.number(buffered)) {
|
||||||
return (buffered * 100);
|
return (buffered * 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2319,11 +2340,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Default to 0
|
// Default to 0
|
||||||
if (typeof value === 'undefined') {
|
if (_is.undefined(value)) {
|
||||||
value = 0;
|
value = 0;
|
||||||
}
|
}
|
||||||
// Default to buffer or bail
|
// Default to buffer or bail
|
||||||
if (typeof progress === 'undefined') {
|
if (_is.undefined(progress)) {
|
||||||
if (plyr.progress && plyr.progress.buffer) {
|
if (plyr.progress && plyr.progress.buffer) {
|
||||||
progress = plyr.progress.buffer;
|
progress = plyr.progress.buffer;
|
||||||
}
|
}
|
||||||
@ -2333,7 +2354,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// One progress element passed
|
// One progress element passed
|
||||||
if (progress instanceof HTMLElement) {
|
if (_is.htmlElement(progress)) {
|
||||||
progress.value = value;
|
progress.value = value;
|
||||||
}
|
}
|
||||||
// Object of progress + text element
|
// Object of progress + text element
|
||||||
@ -2414,7 +2435,7 @@
|
|||||||
// Update seek range and progress
|
// Update seek range and progress
|
||||||
function _updateSeekDisplay(time) {
|
function _updateSeekDisplay(time) {
|
||||||
// Default to 0
|
// Default to 0
|
||||||
if (typeof time !== 'number') {
|
if (!_is.number(time)) {
|
||||||
time = 0;
|
time = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2485,21 +2506,22 @@
|
|||||||
if (!config.hideControls || plyr.type === 'audio') {
|
if (!config.hideControls || plyr.type === 'audio') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var delay = 0,
|
var delay = 0,
|
||||||
isEnterFullscreen = false,
|
isEnterFullscreen = false,
|
||||||
show = toggle;
|
show = toggle;
|
||||||
|
|
||||||
// Default to false if no boolean
|
// Default to false if no boolean
|
||||||
if (typeof toggle !== "boolean") {
|
if (!_is.boolean(toggle)) {
|
||||||
if (toggle && toggle.type) {
|
if (toggle && toggle.type) {
|
||||||
// Is the enter fullscreen event
|
// Is the enter fullscreen event
|
||||||
isEnterFullscreen = (toggle.type === 'enterfullscreen');
|
isEnterFullscreen = (toggle.type === 'enterfullscreen');
|
||||||
|
|
||||||
// Whether to show controls
|
// Whether to show controls
|
||||||
show = _inArray(['mousemove', 'mouseenter', 'focus'], toggle.type);
|
show = _inArray(['mousemove', 'touchstart', 'mouseenter', 'focus'], toggle.type);
|
||||||
|
|
||||||
// Delay hiding on mousemove events
|
// Delay hiding on move events
|
||||||
if (toggle.type === 'mousemove') {
|
if (_inArray(['mousemove', 'touchmove'], toggle.type)) {
|
||||||
delay = 2000;
|
delay = 2000;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2509,7 +2531,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
show = !_hasClass(plyr.container, config.classes.hideControls);
|
show = _hasClass(plyr.container, config.classes.hideControls);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2526,7 +2548,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Delay for hiding on touch
|
// Delay for hiding on touch
|
||||||
if (plyr.browser.touch) {
|
if (plyr.browser.isTouch) {
|
||||||
delay = 3000;
|
delay = 3000;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2536,7 +2558,7 @@
|
|||||||
if (!show || !plyr.media.paused) {
|
if (!show || !plyr.media.paused) {
|
||||||
plyr.timers.hover = window.setTimeout(function() {
|
plyr.timers.hover = window.setTimeout(function() {
|
||||||
// If the mouse is over the controls (and not entering fullscreen), bail
|
// 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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2548,7 +2570,7 @@
|
|||||||
// Add common function to retrieve media source
|
// Add common function to retrieve media source
|
||||||
function _source(source) {
|
function _source(source) {
|
||||||
// If not null or undefined, parse it
|
// If not null or undefined, parse it
|
||||||
if (typeof source !== 'undefined') {
|
if (!_is.undefined(source)) {
|
||||||
_updateSource(source);
|
_updateSource(source);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2561,7 +2583,7 @@
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'vimeo':
|
case 'vimeo':
|
||||||
plyr.embed.api('getVideoUrl', function (value) {
|
plyr.embed.getVideoUrl.then(function (value) {
|
||||||
url = value;
|
url = value;
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
@ -2583,8 +2605,8 @@
|
|||||||
// Update source
|
// Update source
|
||||||
// Sources are not checked for support so be careful
|
// Sources are not checked for support so be careful
|
||||||
function _updateSource(source) {
|
function _updateSource(source) {
|
||||||
if (typeof source === 'undefined' || !('sources' in source) || !source.sources.length) {
|
if (!_is.object(source) || !('sources' in source) || !source.sources.length) {
|
||||||
_log('Invalid source format', true);
|
_warn('Invalid source format');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2660,7 +2682,7 @@
|
|||||||
_prependChild(plyr.container, plyr.media);
|
_prependChild(plyr.container, plyr.media);
|
||||||
|
|
||||||
// Autoplay the new source?
|
// Autoplay the new source?
|
||||||
if (typeof source.autoplay !== 'undefined') {
|
if (_is.boolean(source.autoplay)) {
|
||||||
config.autoplay = source.autoplay;
|
config.autoplay = source.autoplay;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2712,6 +2734,10 @@
|
|||||||
// Display duration if available
|
// Display duration if available
|
||||||
_displayDuration();
|
_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
|
// Set aria title and iframe title
|
||||||
config.title = source.title;
|
config.title = source.title;
|
||||||
@ -2785,7 +2811,7 @@
|
|||||||
for (var button in plyr.buttons) {
|
for (var button in plyr.buttons) {
|
||||||
var element = plyr.buttons[button];
|
var element = plyr.buttons[button];
|
||||||
|
|
||||||
if (element instanceof NodeList) {
|
if (_is.nodeList(element)) {
|
||||||
for (var i = 0; i < element.length; i++) {
|
for (var i = 0; i < element.length; i++) {
|
||||||
_toggleClass(element[i], config.classes.tabFocus, (element[i] === focused));
|
_toggleClass(element[i], config.classes.tabFocus, (element[i] === focused));
|
||||||
}
|
}
|
||||||
@ -2857,11 +2883,16 @@
|
|||||||
// Toggle controls visibility based on mouse movement
|
// Toggle controls visibility based on mouse movement
|
||||||
if (config.hideControls) {
|
if (config.hideControls) {
|
||||||
// Toggle controls on mouse events and entering fullscreen
|
// 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
|
// Watch for cursor over controls so they don't hide when trying to interact
|
||||||
_on(plyr.controls, 'mouseenter mouseleave', function(event) {
|
_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
|
// Focus in/out on controls
|
||||||
@ -2959,8 +2990,8 @@
|
|||||||
|
|
||||||
// On click play, pause ore restart
|
// On click play, pause ore restart
|
||||||
_on(wrapper, 'click', function() {
|
_on(wrapper, 'click', function() {
|
||||||
if (plyr.browser.touch && !plyr.media.paused) {
|
// Touch devices will just show controls (if we're hiding controls)
|
||||||
_toggleControls(true);
|
if (config.hideControls && plyr.browser.isTouch && !plyr.media.paused) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3003,9 +3034,8 @@
|
|||||||
|
|
||||||
// Set blank video src attribute
|
// Set blank video src attribute
|
||||||
// This is to prevent a MEDIA_ERR_SRC_NOT_SUPPORTED error
|
// This is to prevent a MEDIA_ERR_SRC_NOT_SUPPORTED error
|
||||||
// Small mp4: https://github.com/mathiasbynens/small/blob/master/mp4.mp4
|
|
||||||
// Info: http://stackoverflow.com/questions/32231579/how-to-properly-dispose-of-an-html5-video-and-close-socket-or-connection
|
// Info: http://stackoverflow.com/questions/32231579/how-to-properly-dispose-of-an-html5-video-and-close-socket-or-connection
|
||||||
plyr.media.setAttribute('src', 'data:video/mp4;base64,AAAAHGZ0eXBpc29tAAACAGlzb21pc28ybXA0MQAAAAhmcmVlAAAAGm1kYXQAAAGzABAHAAABthBgUYI9t+8AAAMNbW9vdgAAAGxtdmhkAAAAAMXMvvrFzL76AAAD6AAAACoAAQAAAQAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAABhpb2RzAAAAABCAgIAHAE/////+/wAAAiF0cmFrAAAAXHRraGQAAAAPxcy++sXMvvoAAAABAAAAAAAAACoAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAABAAAAAAAgAAAAIAAAAAAG9bWRpYQAAACBtZGhkAAAAAMXMvvrFzL76AAAAGAAAAAEVxwAAAAAALWhkbHIAAAAAAAAAAHZpZGUAAAAAAAAAAAAAAABWaWRlb0hhbmRsZXIAAAABaG1pbmYAAAAUdm1oZAAAAAEAAAAAAAAAAAAAACRkaW5mAAAAHGRyZWYAAAAAAAAAAQAAAAx1cmwgAAAAAQAAAShzdGJsAAAAxHN0c2QAAAAAAAAAAQAAALRtcDR2AAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAgACABIAAAASAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGP//AAAAXmVzZHMAAAAAA4CAgE0AAQAEgICAPyARAAAAAAMNQAAAAAAFgICALQAAAbABAAABtYkTAAABAAAAASAAxI2IAMUARAEUQwAAAbJMYXZjNTMuMzUuMAaAgIABAgAAABhzdHRzAAAAAAAAAAEAAAABAAAAAQAAABxzdHNjAAAAAAAAAAEAAAABAAAAAQAAAAEAAAAUc3RzegAAAAAAAAASAAAAAQAAABRzdGNvAAAAAAAAAAEAAAAsAAAAYHVkdGEAAABYbWV0YQAAAAAAAAAhaGRscgAAAAAAAAAAbWRpcmFwcGwAAAAAAAAAAAAAAAAraWxzdAAAACOpdG9vAAAAG2RhdGEAAAABAAAAAExhdmY1My4yMS4x');
|
plyr.media.setAttribute('src', 'https://cdn.selz.com/plyr/blank.mp4');
|
||||||
|
|
||||||
// Load the new empty source
|
// Load the new empty source
|
||||||
// This will cancel existing requests
|
// This will cancel existing requests
|
||||||
@ -3144,6 +3174,10 @@
|
|||||||
_play();
|
_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
|
// Successful setup
|
||||||
plyr.init = true;
|
plyr.init = true;
|
||||||
@ -3152,7 +3186,7 @@
|
|||||||
function _setupInterface() {
|
function _setupInterface() {
|
||||||
// Don't setup interface if no support
|
// Don't setup interface if no support
|
||||||
if (!plyr.supported.full) {
|
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 controls
|
||||||
_remove(_getElement(config.selectors.controls.wrapper));
|
_remove(_getElement(config.selectors.controls.wrapper));
|
||||||
@ -3240,7 +3274,8 @@
|
|||||||
isFullscreen: function() { return plyr.isFullscreen || false; },
|
isFullscreen: function() { return plyr.isFullscreen || false; },
|
||||||
support: function(mimeType) { return _supportMime(plyr, mimeType); },
|
support: function(mimeType) { return _supportMime(plyr, mimeType); },
|
||||||
destroy: _destroy,
|
destroy: _destroy,
|
||||||
restore: _init
|
restore: _init,
|
||||||
|
getCurrentTime: function() { return plyr.media.currentTime; }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3249,7 +3284,7 @@
|
|||||||
var x = new XMLHttpRequest();
|
var x = new XMLHttpRequest();
|
||||||
|
|
||||||
// If the id is set and sprite exists, bail
|
// If the id is set and sprite exists, bail
|
||||||
if (typeof id === 'string' && document.querySelector('#' + id) !== null) {
|
if (_is.string(id) && document.querySelector('#' + id) !== null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3265,7 +3300,7 @@
|
|||||||
x.onload = function() {
|
x.onload = function() {
|
||||||
var c = document.createElement('div');
|
var c = document.createElement('div');
|
||||||
c.setAttribute('hidden', '');
|
c.setAttribute('hidden', '');
|
||||||
if (typeof id === 'string') {
|
if (_is.string(id)) {
|
||||||
c.setAttribute('id', id);
|
c.setAttribute('id', id);
|
||||||
}
|
}
|
||||||
c.innerHTML = x.responseText;
|
c.innerHTML = x.responseText;
|
||||||
@ -3278,8 +3313,9 @@
|
|||||||
// Check for support
|
// Check for support
|
||||||
function supported(type) {
|
function supported(type) {
|
||||||
var browser = _browserSniff(),
|
var browser = _browserSniff(),
|
||||||
oldIE = (browser.isIE && browser.version <= 9),
|
isOldIE = (browser.isIE && browser.version <= 9),
|
||||||
iPhone = /iPhone|iPod/i.test(navigator.userAgent),
|
isIos = browser.isIos,
|
||||||
|
isIphone = /iPhone|iPod/i.test(navigator.userAgent),
|
||||||
audio = !!document.createElement('audio').canPlayType,
|
audio = !!document.createElement('audio').canPlayType,
|
||||||
video = !!document.createElement('video').canPlayType,
|
video = !!document.createElement('video').canPlayType,
|
||||||
basic, full;
|
basic, full;
|
||||||
@ -3287,24 +3323,24 @@
|
|||||||
switch (type) {
|
switch (type) {
|
||||||
case 'video':
|
case 'video':
|
||||||
basic = video;
|
basic = video;
|
||||||
full = (basic && (!oldIE && !iPhone));
|
full = (basic && (!isOldIE && !isIphone));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'audio':
|
case 'audio':
|
||||||
basic = audio;
|
basic = audio;
|
||||||
full = (basic && !oldIE);
|
full = (basic && !isOldIE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'vimeo':
|
case 'vimeo':
|
||||||
case 'youtube':
|
case 'youtube':
|
||||||
case 'soundcloud':
|
case 'soundcloud':
|
||||||
basic = true;
|
basic = true;
|
||||||
full = (!oldIE && !iPhone);
|
full = (!isOldIE && !isIos);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
basic = (audio && video);
|
basic = (audio && video);
|
||||||
full = (basic && !oldIE);
|
full = (basic && !isOldIE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -3322,17 +3358,17 @@
|
|||||||
|
|
||||||
// Select the elements
|
// Select the elements
|
||||||
// Assume elements is a NodeList by default
|
// Assume elements is a NodeList by default
|
||||||
if (typeof targets === 'string') {
|
if (_is.string(targets)) {
|
||||||
targets = document.querySelectorAll(targets);
|
targets = document.querySelectorAll(targets);
|
||||||
}
|
}
|
||||||
// Single HTMLElement passed
|
// Single HTMLElement passed
|
||||||
else if (targets instanceof HTMLElement) {
|
else if (_is.htmlElement(targets)) {
|
||||||
targets = [targets];
|
targets = [targets];
|
||||||
}
|
}
|
||||||
// No selector passed, possibly options as first argument
|
// No selector passed, possibly options as first argument
|
||||||
else if (!(targets instanceof NodeList) && typeof targets !== 'string') {
|
else if (!_is.nodeList(targets) && !_is.array(targets) && !_is.string(targets)) {
|
||||||
// If options are the first argument
|
// If options are the first argument
|
||||||
if (typeof options === 'undefined' && typeof targets === 'object') {
|
if (_is.undefined(options) && _is.object(targets)) {
|
||||||
options = targets;
|
options = targets;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3340,17 +3376,17 @@
|
|||||||
targets = document.querySelectorAll(selector);
|
targets = document.querySelectorAll(selector);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Convert NodeList to array
|
||||||
|
if (_is.nodeList(targets)) {
|
||||||
|
targets = Array.prototype.slice.call(targets);
|
||||||
|
}
|
||||||
|
|
||||||
// Bail if disabled or no basic support
|
// Bail if disabled or no basic support
|
||||||
// You may want to disable certain UAs etc
|
// You may want to disable certain UAs etc
|
||||||
if (!supported().basic || !targets.length) {
|
if (!supported().basic || !targets.length) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert NodeList to array
|
|
||||||
if (targets instanceof NodeList) {
|
|
||||||
targets = Array.prototype.slice.call(targets);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if the targets have multiple media elements
|
// Check if the targets have multiple media elements
|
||||||
for (var i = 0; i < targets.length; i++) {
|
for (var i = 0; i < targets.length; i++) {
|
||||||
var target = targets[i];
|
var target = targets[i];
|
||||||
@ -3426,10 +3462,10 @@
|
|||||||
// https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent
|
// https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent
|
||||||
(function () {
|
(function () {
|
||||||
if (typeof window.CustomEvent === 'function') {
|
if (typeof window.CustomEvent === 'function') {
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function CustomEvent (event, params) {
|
function CustomEvent(event, params) {
|
||||||
params = params || { bubbles: false, cancelable: false, detail: undefined };
|
params = params || { bubbles: false, cancelable: false, detail: undefined };
|
||||||
var evt = document.createEvent('CustomEvent');
|
var evt = document.createEvent('CustomEvent');
|
||||||
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
|
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
position: relative;
|
position: relative;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
min-width: 200px;
|
min-width: 200px;
|
||||||
font-family: Avenir, "Avenir Next", "Helvetica Neue", "Segoe UI", Helvetica, Arial, sans-serif;
|
font-family: @plyr-font-family;
|
||||||
direction: ltr;
|
direction: ltr;
|
||||||
|
|
||||||
& when (@plyr-border-box = true) {
|
& when (@plyr-border-box = true) {
|
||||||
@ -225,6 +225,8 @@
|
|||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
padding: floor(@plyr-control-spacing / 3) @plyr-control-spacing;
|
padding: floor(@plyr-control-spacing / 3) @plyr-control-spacing;
|
||||||
background: @plyr-captions-bg;
|
background: @plyr-captions-bg;
|
||||||
|
box-decoration-break: clone;
|
||||||
|
line-height: 150%;
|
||||||
}
|
}
|
||||||
span:empty {
|
span:empty {
|
||||||
display: none;
|
display: none;
|
||||||
@ -255,12 +257,9 @@
|
|||||||
.plyr__controls {
|
.plyr__controls {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|
||||||
transition: opacity .3s ease;
|
|
||||||
|
|
||||||
// Spacing
|
// Spacing
|
||||||
> button,
|
> button,
|
||||||
.plyr__progress,
|
.plyr__progress,
|
||||||
@ -324,6 +323,7 @@
|
|||||||
// Hide controls
|
// Hide controls
|
||||||
.plyr--hide-controls .plyr__controls {
|
.plyr--hide-controls .plyr__controls {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Video controls
|
// Video controls
|
||||||
@ -337,6 +337,7 @@
|
|||||||
border-bottom-left-radius: inherit;
|
border-bottom-left-radius: inherit;
|
||||||
border-bottom-right-radius: inherit;
|
border-bottom-right-radius: inherit;
|
||||||
color: @plyr-video-control-color;
|
color: @plyr-video-control-color;
|
||||||
|
transition: opacity .3s ease;
|
||||||
|
|
||||||
button {
|
button {
|
||||||
// Hover and tab focus
|
// Hover and tab focus
|
||||||
@ -354,7 +355,6 @@
|
|||||||
border-radius: inherit;
|
border-radius: inherit;
|
||||||
background: @plyr-audio-controls-bg;
|
background: @plyr-audio-controls-bg;
|
||||||
border: @plyr-audio-controls-border;
|
border: @plyr-audio-controls-border;
|
||||||
box-shadow: @plyr-audio-controls-box-shadow;
|
|
||||||
color: @plyr-audio-control-color;
|
color: @plyr-audio-control-color;
|
||||||
|
|
||||||
button {
|
button {
|
||||||
@ -371,6 +371,7 @@
|
|||||||
.plyr__play-large {
|
.plyr__play-large {
|
||||||
display: none;
|
display: none;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
z-index: 1;
|
||||||
top: 50%;
|
top: 50%;
|
||||||
left: 50%;
|
left: 50%;
|
||||||
transform: translate(-50%, -50%);
|
transform: translate(-50%, -50%);
|
||||||
@ -378,7 +379,7 @@
|
|||||||
background: @plyr-video-control-bg-hover;
|
background: @plyr-video-control-bg-hover;
|
||||||
border: 4px solid currentColor;
|
border: 4px solid currentColor;
|
||||||
border-radius: 100%;
|
border-radius: 100%;
|
||||||
box-shadow: 0 1px 1px fade(@plyr-video-controls-bg, 15%);
|
box-shadow: 0 1px 1px fade(#000, 15%);
|
||||||
color: @plyr-video-control-color;
|
color: @plyr-video-control-color;
|
||||||
transition: all .3s ease;
|
transition: all .3s ease;
|
||||||
|
|
||||||
@ -663,7 +664,6 @@
|
|||||||
display: inline-block;
|
display: inline-block;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
font-size: @plyr-font-size-small;
|
font-size: @plyr-font-size-small;
|
||||||
line-height: .95;
|
|
||||||
}
|
}
|
||||||
// Media duration hidden on small screens
|
// Media duration hidden on small screens
|
||||||
.plyr__time + .plyr__time {
|
.plyr__time + .plyr__time {
|
||||||
|
@ -11,7 +11,8 @@
|
|||||||
// Colors
|
// Colors
|
||||||
@plyr-color-main: #3498db;
|
@plyr-color-main: #3498db;
|
||||||
|
|
||||||
// Font sizes
|
// Font
|
||||||
|
@plyr-font-family: 'San Francisco', -apple-system, BlinkMacSystemFont, '.SFNSText-Regular', Avenir, 'Avenir Next', 'Helvetica Neue', 'Segoe UI', Helvetica, Arial, sans-serif;
|
||||||
@plyr-font-size-small: 14px;
|
@plyr-font-size-small: 14px;
|
||||||
@plyr-font-size-base: 16px;
|
@plyr-font-size-base: 16px;
|
||||||
|
|
||||||
@ -32,7 +33,6 @@
|
|||||||
@plyr-video-control-bg-hover: @plyr-color-main;
|
@plyr-video-control-bg-hover: @plyr-color-main;
|
||||||
@plyr-audio-controls-bg: #fff;
|
@plyr-audio-controls-bg: #fff;
|
||||||
@plyr-audio-controls-border: 1px solid #dbe3e8;
|
@plyr-audio-controls-border: 1px solid #dbe3e8;
|
||||||
@plyr-audio-controls-box-shadow: 0 1px 1px fade(#000, 5%);
|
|
||||||
@plyr-audio-control-color: #565D64;
|
@plyr-audio-control-color: #565D64;
|
||||||
@plyr-audio-control-color-hover: #fff;
|
@plyr-audio-control-color-hover: #fff;
|
||||||
@plyr-audio-control-bg-hover: @plyr-color-main;
|
@plyr-audio-control-bg-hover: @plyr-color-main;
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
position: relative;
|
position: relative;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
min-width: 200px;
|
min-width: 200px;
|
||||||
font-family: Avenir, "Avenir Next", "Helvetica Neue", "Segoe UI", Helvetica, Arial, sans-serif;
|
font-family: $plyr-font-family;
|
||||||
direction: ltr;
|
direction: ltr;
|
||||||
|
|
||||||
@if $plyr-border-box == true {
|
@if $plyr-border-box == true {
|
||||||
@ -225,6 +225,8 @@
|
|||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
padding: floor($plyr-control-spacing / 3) $plyr-control-spacing;
|
padding: floor($plyr-control-spacing / 3) $plyr-control-spacing;
|
||||||
background: $plyr-captions-bg;
|
background: $plyr-captions-bg;
|
||||||
|
box-decoration-break: clone;
|
||||||
|
line-height: 150%;
|
||||||
}
|
}
|
||||||
span:empty {
|
span:empty {
|
||||||
display: none;
|
display: none;
|
||||||
@ -255,12 +257,9 @@
|
|||||||
.plyr__controls {
|
.plyr__controls {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|
||||||
transition: opacity .3s ease;
|
|
||||||
|
|
||||||
// Spacing
|
// Spacing
|
||||||
> button,
|
> button,
|
||||||
.plyr__progress,
|
.plyr__progress,
|
||||||
@ -324,6 +323,7 @@
|
|||||||
// Hide controls
|
// Hide controls
|
||||||
.plyr--hide-controls .plyr__controls {
|
.plyr--hide-controls .plyr__controls {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Video controls
|
// Video controls
|
||||||
@ -337,6 +337,7 @@
|
|||||||
border-bottom-left-radius: inherit;
|
border-bottom-left-radius: inherit;
|
||||||
border-bottom-right-radius: inherit;
|
border-bottom-right-radius: inherit;
|
||||||
color: $plyr-video-control-color;
|
color: $plyr-video-control-color;
|
||||||
|
transition: opacity .3s ease;
|
||||||
|
|
||||||
button {
|
button {
|
||||||
// Hover and tab focus
|
// Hover and tab focus
|
||||||
@ -354,7 +355,6 @@
|
|||||||
border-radius: inherit;
|
border-radius: inherit;
|
||||||
background: $plyr-audio-controls-bg;
|
background: $plyr-audio-controls-bg;
|
||||||
border: $plyr-audio-controls-border;
|
border: $plyr-audio-controls-border;
|
||||||
box-shadow: $plyr-audio-controls-box-shadow;
|
|
||||||
color: $plyr-audio-control-color;
|
color: $plyr-audio-control-color;
|
||||||
|
|
||||||
button {
|
button {
|
||||||
@ -371,6 +371,7 @@
|
|||||||
.plyr__play-large {
|
.plyr__play-large {
|
||||||
display: none;
|
display: none;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
z-index: 1;
|
||||||
top: 50%;
|
top: 50%;
|
||||||
left: 50%;
|
left: 50%;
|
||||||
transform: translate(-50%, -50%);
|
transform: translate(-50%, -50%);
|
||||||
@ -378,7 +379,7 @@
|
|||||||
background: $plyr-video-control-bg-hover;
|
background: $plyr-video-control-bg-hover;
|
||||||
border: 4px solid currentColor;
|
border: 4px solid currentColor;
|
||||||
border-radius: 100%;
|
border-radius: 100%;
|
||||||
box-shadow: 0 1px 1px transparentize($plyr-video-controls-bg, .85);
|
box-shadow: 0 1px 1px transparentize(#000, .85);
|
||||||
color: $plyr-video-control-color;
|
color: $plyr-video-control-color;
|
||||||
transition: all .3s ease;
|
transition: all .3s ease;
|
||||||
|
|
||||||
@ -662,7 +663,6 @@
|
|||||||
display: inline-block;
|
display: inline-block;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
font-size: $plyr-font-size-small;
|
font-size: $plyr-font-size-small;
|
||||||
line-height: .95;
|
|
||||||
}
|
}
|
||||||
// Media duration hidden on small screens
|
// Media duration hidden on small screens
|
||||||
.plyr__time + .plyr__time {
|
.plyr__time + .plyr__time {
|
||||||
|
@ -13,6 +13,7 @@ $plyr-sr-only-important: true !default;
|
|||||||
$plyr-color-main: #3498db !default;
|
$plyr-color-main: #3498db !default;
|
||||||
|
|
||||||
// Font sizes
|
// Font sizes
|
||||||
|
$plyr-font-family: 'San Francisco', -apple-system, BlinkMacSystemFont, '.SFNSText-Regular', Avenir, 'Avenir Next', 'Helvetica Neue', 'Segoe UI', Helvetica, Arial, sans-serif;
|
||||||
$plyr-font-size-small: 14px !default;
|
$plyr-font-size-small: 14px !default;
|
||||||
$plyr-font-size-base: 16px !default;
|
$plyr-font-size-base: 16px !default;
|
||||||
|
|
||||||
@ -33,7 +34,6 @@ $plyr-video-control-color-hover: #fff !default;
|
|||||||
$plyr-video-control-bg-hover: $plyr-color-main !default;
|
$plyr-video-control-bg-hover: $plyr-color-main !default;
|
||||||
$plyr-audio-controls-bg: #fff !default;
|
$plyr-audio-controls-bg: #fff !default;
|
||||||
$plyr-audio-controls-border: 1px solid #dbe3e8 !default;
|
$plyr-audio-controls-border: 1px solid #dbe3e8 !default;
|
||||||
$plyr-audio-controls-box-shadow: 0 1px 1px transparentize(#000, .95) !default;
|
|
||||||
$plyr-audio-control-color: #565D64 !default;
|
$plyr-audio-control-color: #565D64 !default;
|
||||||
$plyr-audio-control-color-hover: #fff !default;
|
$plyr-audio-control-color-hover: #fff !default;
|
||||||
$plyr-audio-control-bg-hover: $plyr-color-main;
|
$plyr-audio-control-bg-hover: $plyr-color-main;
|
||||||
|
Reference in New Issue
Block a user