Compare commits
2 Commits
v3.0.0-bet
...
v3.0.0-bet
Author | SHA1 | Date | |
---|---|---|---|
174234c166 | |||
24b4220de5 |
39
dist/plyr.js
vendored
39
dist/plyr.js
vendored
@ -649,6 +649,8 @@ var utils = {
|
|||||||
// Fetch wrapper
|
// Fetch wrapper
|
||||||
// Using XHR to avoid issues with older browsers
|
// Using XHR to avoid issues with older browsers
|
||||||
fetch: function fetch(url) {
|
fetch: function fetch(url) {
|
||||||
|
var responseType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'text';
|
||||||
|
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
try {
|
try {
|
||||||
var request = new XMLHttpRequest();
|
var request = new XMLHttpRequest();
|
||||||
@ -659,11 +661,15 @@ var utils = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
request.addEventListener('load', function () {
|
request.addEventListener('load', function () {
|
||||||
|
if (responseType === 'text') {
|
||||||
try {
|
try {
|
||||||
resolve(JSON.parse(request.responseText));
|
resolve(JSON.parse(request.responseText));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
resolve(request.responseText);
|
resolve(request.responseText);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
resolve(request.response);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
request.addEventListener('error', function () {
|
request.addEventListener('error', function () {
|
||||||
@ -671,6 +677,10 @@ var utils = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
request.open('GET', url, true);
|
request.open('GET', url, true);
|
||||||
|
|
||||||
|
// Set the required response type
|
||||||
|
request.responseType = responseType;
|
||||||
|
|
||||||
request.send();
|
request.send();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
reject(e);
|
reject(e);
|
||||||
@ -4741,6 +4751,7 @@ var controls = {
|
|||||||
|
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
// Plyr Captions
|
// Plyr Captions
|
||||||
|
// TODO: Create as class
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
|
|
||||||
var captions = {
|
var captions = {
|
||||||
@ -4782,7 +4793,6 @@ var captions = {
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inject the container
|
// Inject the container
|
||||||
if (!utils.is.element(this.elements.captions)) {
|
if (!utils.is.element(this.elements.captions)) {
|
||||||
this.elements.captions = utils.createElement('div', utils.getAttributesFromSelector(this.config.selectors.captions));
|
this.elements.captions = utils.createElement('div', utils.getAttributesFromSelector(this.config.selectors.captions));
|
||||||
@ -4793,11 +4803,36 @@ var captions = {
|
|||||||
// Set the class hook
|
// Set the class hook
|
||||||
utils.toggleClass(this.elements.container, this.config.classNames.captions.enabled, !utils.is.empty(captions.getTracks.call(this)));
|
utils.toggleClass(this.elements.container, this.config.classNames.captions.enabled, !utils.is.empty(captions.getTracks.call(this)));
|
||||||
|
|
||||||
|
// Get tracks
|
||||||
|
var tracks = captions.getTracks.call(this);
|
||||||
|
|
||||||
// If no caption file exists, hide container for caption text
|
// If no caption file exists, hide container for caption text
|
||||||
if (utils.is.empty(captions.getTracks.call(this))) {
|
if (utils.is.empty(tracks)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get browser info
|
||||||
|
var browser = utils.getBrowser();
|
||||||
|
|
||||||
|
// Fix IE captions if CORS is used
|
||||||
|
// Fetch captions and inject as blobs instead (data URIs not supported!)
|
||||||
|
if (browser.isIE && window.URL) {
|
||||||
|
var elements = this.media.querySelectorAll('track');
|
||||||
|
|
||||||
|
Array.from(elements).forEach(function (track) {
|
||||||
|
var src = track.getAttribute('src');
|
||||||
|
var href = utils.parseUrl(src);
|
||||||
|
|
||||||
|
if (href.hostname !== window.location.href.hostname && ['http:', 'https:'].includes(href.protocol)) {
|
||||||
|
utils.fetch(src, 'blob').then(function (blob) {
|
||||||
|
track.setAttribute('src', window.URL.createObjectURL(blob));
|
||||||
|
}).catch(function () {
|
||||||
|
utils.removeElement(track);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Set language
|
// Set language
|
||||||
captions.setLanguage.call(this);
|
captions.setLanguage.call(this);
|
||||||
|
|
||||||
|
2
dist/plyr.js.map
vendored
2
dist/plyr.js.map
vendored
File diff suppressed because one or more lines are too long
2
dist/plyr.min.js
vendored
2
dist/plyr.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/plyr.min.js.map
vendored
2
dist/plyr.min.js.map
vendored
File diff suppressed because one or more lines are too long
43
dist/plyr.polyfilled.js
vendored
43
dist/plyr.polyfilled.js
vendored
@ -5268,7 +5268,7 @@ var defaults = {
|
|||||||
// Sprite (for icons)
|
// Sprite (for icons)
|
||||||
loadSprite: true,
|
loadSprite: true,
|
||||||
iconPrefix: 'plyr',
|
iconPrefix: 'plyr',
|
||||||
iconUrl: 'https://cdn.plyr.io/3.0.0-beta.14/plyr.svg',
|
iconUrl: 'https://cdn.plyr.io/3.0.0-beta.15/plyr.svg',
|
||||||
|
|
||||||
// Blank video (used to prevent errors on source change)
|
// Blank video (used to prevent errors on source change)
|
||||||
blankVideo: 'https://cdn.plyr.io/static/blank.mp4',
|
blankVideo: 'https://cdn.plyr.io/static/blank.mp4',
|
||||||
@ -5840,6 +5840,8 @@ var utils = {
|
|||||||
// Fetch wrapper
|
// Fetch wrapper
|
||||||
// Using XHR to avoid issues with older browsers
|
// Using XHR to avoid issues with older browsers
|
||||||
fetch: function fetch(url) {
|
fetch: function fetch(url) {
|
||||||
|
var responseType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'text';
|
||||||
|
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
try {
|
try {
|
||||||
var request = new XMLHttpRequest();
|
var request = new XMLHttpRequest();
|
||||||
@ -5850,11 +5852,15 @@ var utils = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
request.addEventListener('load', function () {
|
request.addEventListener('load', function () {
|
||||||
|
if (responseType === 'text') {
|
||||||
try {
|
try {
|
||||||
resolve(JSON.parse(request.responseText));
|
resolve(JSON.parse(request.responseText));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
resolve(request.responseText);
|
resolve(request.responseText);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
resolve(request.response);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
request.addEventListener('error', function () {
|
request.addEventListener('error', function () {
|
||||||
@ -5862,6 +5868,10 @@ var utils = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
request.open('GET', url, true);
|
request.open('GET', url, true);
|
||||||
|
|
||||||
|
// Set the required response type
|
||||||
|
request.responseType = responseType;
|
||||||
|
|
||||||
request.send();
|
request.send();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
reject(e);
|
reject(e);
|
||||||
@ -9932,6 +9942,7 @@ var controls = {
|
|||||||
|
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
// Plyr Captions
|
// Plyr Captions
|
||||||
|
// TODO: Create as class
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
|
|
||||||
var captions = {
|
var captions = {
|
||||||
@ -9973,7 +9984,6 @@ var captions = {
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inject the container
|
// Inject the container
|
||||||
if (!utils.is.element(this.elements.captions)) {
|
if (!utils.is.element(this.elements.captions)) {
|
||||||
this.elements.captions = utils.createElement('div', utils.getAttributesFromSelector(this.config.selectors.captions));
|
this.elements.captions = utils.createElement('div', utils.getAttributesFromSelector(this.config.selectors.captions));
|
||||||
@ -9984,11 +9994,36 @@ var captions = {
|
|||||||
// Set the class hook
|
// Set the class hook
|
||||||
utils.toggleClass(this.elements.container, this.config.classNames.captions.enabled, !utils.is.empty(captions.getTracks.call(this)));
|
utils.toggleClass(this.elements.container, this.config.classNames.captions.enabled, !utils.is.empty(captions.getTracks.call(this)));
|
||||||
|
|
||||||
|
// Get tracks
|
||||||
|
var tracks = captions.getTracks.call(this);
|
||||||
|
|
||||||
// If no caption file exists, hide container for caption text
|
// If no caption file exists, hide container for caption text
|
||||||
if (utils.is.empty(captions.getTracks.call(this))) {
|
if (utils.is.empty(tracks)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get browser info
|
||||||
|
var browser = utils.getBrowser();
|
||||||
|
|
||||||
|
// Fix IE captions if CORS is used
|
||||||
|
// Fetch captions and inject as blobs instead (data URIs not supported!)
|
||||||
|
if (browser.isIE && window.URL) {
|
||||||
|
var elements = this.media.querySelectorAll('track');
|
||||||
|
|
||||||
|
Array.from(elements).forEach(function (track) {
|
||||||
|
var src = track.getAttribute('src');
|
||||||
|
var href = utils.parseUrl(src);
|
||||||
|
|
||||||
|
if (href.hostname !== window.location.href.hostname && ['http:', 'https:'].includes(href.protocol)) {
|
||||||
|
utils.fetch(src, 'blob').then(function (blob) {
|
||||||
|
track.setAttribute('src', window.URL.createObjectURL(blob));
|
||||||
|
}).catch(function () {
|
||||||
|
utils.removeElement(track);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Set language
|
// Set language
|
||||||
captions.setLanguage.call(this);
|
captions.setLanguage.call(this);
|
||||||
|
|
||||||
@ -11125,7 +11160,7 @@ var source = {
|
|||||||
|
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
// Plyr
|
// Plyr
|
||||||
// plyr.js v3.0.0-beta.14
|
// plyr.js v3.0.0-beta.15
|
||||||
// https://github.com/sampotts/plyr
|
// https://github.com/sampotts/plyr
|
||||||
// License: The MIT License (MIT)
|
// License: The MIT License (MIT)
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
|
2
dist/plyr.polyfilled.js.map
vendored
2
dist/plyr.polyfilled.js.map
vendored
File diff suppressed because one or more lines are too long
2
dist/plyr.polyfilled.min.js
vendored
2
dist/plyr.polyfilled.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/plyr.polyfilled.min.js.map
vendored
2
dist/plyr.polyfilled.min.js.map
vendored
File diff suppressed because one or more lines are too long
12
package.json
12
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "plyr",
|
"name": "plyr",
|
||||||
"version": "3.0.0-beta.14",
|
"version": "3.0.0-beta.15",
|
||||||
"description": "A simple, accessible and customizable HTML5, YouTube and Vimeo media player",
|
"description": "A simple, accessible and customizable HTML5, YouTube and Vimeo media player",
|
||||||
"homepage": "https://plyr.io",
|
"homepage": "https://plyr.io",
|
||||||
"main": "./dist/plyr.js",
|
"main": "./dist/plyr.js",
|
||||||
@ -47,15 +47,7 @@
|
|||||||
"stylelint-scss": "^2.3.0",
|
"stylelint-scss": "^2.3.0",
|
||||||
"stylelint-selector-bem-pattern": "^2.0.0"
|
"stylelint-selector-bem-pattern": "^2.0.0"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": ["HTML5 Video", "HTML5 Audio", "Media Player", "DASH", "Shaka", "WordPress", "HLS"],
|
||||||
"HTML5 Video",
|
|
||||||
"HTML5 Audio",
|
|
||||||
"Media Player",
|
|
||||||
"DASH",
|
|
||||||
"Shaka",
|
|
||||||
"WordPress",
|
|
||||||
"HLS"
|
|
||||||
],
|
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git://github.com/sampotts/plyr.git"
|
"url": "git://github.com/sampotts/plyr.git"
|
||||||
|
@ -128,7 +128,7 @@ Include the `plyr.js` script before the closing `</body>` tag and then call `ply
|
|||||||
If you want to use our CDN (provided by [Fastly](https://www.fastly.com/)) for the JavaScript, you can use the following:
|
If you want to use our CDN (provided by [Fastly](https://www.fastly.com/)) for the JavaScript, you can use the following:
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<script src="https://cdn.plyr.io/3.0.0-beta.14/plyr.js"></script>
|
<script src="https://cdn.plyr.io/3.0.0-beta.15/plyr.js"></script>
|
||||||
```
|
```
|
||||||
|
|
||||||
_Note_: Be sure to read the [polyfills](#polyfills) section below about browser compatibility
|
_Note_: Be sure to read the [polyfills](#polyfills) section below about browser compatibility
|
||||||
@ -144,13 +144,13 @@ Include the `plyr.css` stylsheet into your `<head>`
|
|||||||
If you want to use our CDN (provided by [Fastly](https://www.fastly.com/)) for the default CSS, you can use the following:
|
If you want to use our CDN (provided by [Fastly](https://www.fastly.com/)) for the default CSS, you can use the following:
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<link rel="stylesheet" href="https://cdn.plyr.io/3.0.0-beta.14/plyr.css">
|
<link rel="stylesheet" href="https://cdn.plyr.io/3.0.0-beta.15/plyr.css">
|
||||||
```
|
```
|
||||||
|
|
||||||
### SVG Sprite
|
### SVG Sprite
|
||||||
|
|
||||||
The SVG sprite is loaded automatically from our CDN (provided by [Fastly](https://www.fastly.com/)). To change this, see the [options](#options) below. For
|
The SVG sprite is loaded automatically from our CDN (provided by [Fastly](https://www.fastly.com/)). To change this, see the [options](#options) below. For
|
||||||
reference, the CDN hosted SVG sprite can be found at `https://cdn.plyr.io/3.0.0-beta.14/plyr.svg`.
|
reference, the CDN hosted SVG sprite can be found at `https://cdn.plyr.io/3.0.0-beta.15/plyr.svg`.
|
||||||
|
|
||||||
## Advanced
|
## Advanced
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
// Plyr Captions
|
// Plyr Captions
|
||||||
|
// TODO: Create as class
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
|
|
||||||
import support from './support';
|
import support from './support';
|
||||||
@ -45,7 +46,6 @@ const captions = {
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inject the container
|
// Inject the container
|
||||||
if (!utils.is.element(this.elements.captions)) {
|
if (!utils.is.element(this.elements.captions)) {
|
||||||
this.elements.captions = utils.createElement('div', utils.getAttributesFromSelector(this.config.selectors.captions));
|
this.elements.captions = utils.createElement('div', utils.getAttributesFromSelector(this.config.selectors.captions));
|
||||||
@ -56,11 +56,42 @@ const captions = {
|
|||||||
// Set the class hook
|
// Set the class hook
|
||||||
utils.toggleClass(this.elements.container, this.config.classNames.captions.enabled, !utils.is.empty(captions.getTracks.call(this)));
|
utils.toggleClass(this.elements.container, this.config.classNames.captions.enabled, !utils.is.empty(captions.getTracks.call(this)));
|
||||||
|
|
||||||
|
// Get tracks
|
||||||
|
const tracks = captions.getTracks.call(this);
|
||||||
|
|
||||||
// If no caption file exists, hide container for caption text
|
// If no caption file exists, hide container for caption text
|
||||||
if (utils.is.empty(captions.getTracks.call(this))) {
|
if (utils.is.empty(tracks)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get browser info
|
||||||
|
const browser = utils.getBrowser();
|
||||||
|
|
||||||
|
// Fix IE captions if CORS is used
|
||||||
|
// Fetch captions and inject as blobs instead (data URIs not supported!)
|
||||||
|
if (browser.isIE && window.URL) {
|
||||||
|
const elements = this.media.querySelectorAll('track');
|
||||||
|
|
||||||
|
Array.from(elements).forEach(track => {
|
||||||
|
const src = track.getAttribute('src');
|
||||||
|
const href = utils.parseUrl(src);
|
||||||
|
|
||||||
|
if (href.hostname !== window.location.href.hostname && [
|
||||||
|
'http:',
|
||||||
|
'https:',
|
||||||
|
].includes(href.protocol)) {
|
||||||
|
utils
|
||||||
|
.fetch(src, 'blob')
|
||||||
|
.then(blob => {
|
||||||
|
track.setAttribute('src', window.URL.createObjectURL(blob));
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
utils.removeElement(track);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Set language
|
// Set language
|
||||||
captions.setLanguage.call(this);
|
captions.setLanguage.call(this);
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ const defaults = {
|
|||||||
// Sprite (for icons)
|
// Sprite (for icons)
|
||||||
loadSprite: true,
|
loadSprite: true,
|
||||||
iconPrefix: 'plyr',
|
iconPrefix: 'plyr',
|
||||||
iconUrl: 'https://cdn.plyr.io/3.0.0-beta.14/plyr.svg',
|
iconUrl: 'https://cdn.plyr.io/3.0.0-beta.15/plyr.svg',
|
||||||
|
|
||||||
// Blank video (used to prevent errors on source change)
|
// Blank video (used to prevent errors on source change)
|
||||||
blankVideo: 'https://cdn.plyr.io/static/blank.mp4',
|
blankVideo: 'https://cdn.plyr.io/static/blank.mp4',
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
// Plyr
|
// Plyr
|
||||||
// plyr.js v3.0.0-beta.14
|
// plyr.js v3.0.0-beta.15
|
||||||
// https://github.com/sampotts/plyr
|
// https://github.com/sampotts/plyr
|
||||||
// License: The MIT License (MIT)
|
// License: The MIT License (MIT)
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
// Plyr Polyfilled Build
|
// Plyr Polyfilled Build
|
||||||
// plyr.js v3.0.0-beta.14
|
// plyr.js v3.0.0-beta.15
|
||||||
// https://github.com/sampotts/plyr
|
// https://github.com/sampotts/plyr
|
||||||
// License: The MIT License (MIT)
|
// License: The MIT License (MIT)
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
|
@ -83,7 +83,7 @@ const utils = {
|
|||||||
|
|
||||||
// Fetch wrapper
|
// Fetch wrapper
|
||||||
// Using XHR to avoid issues with older browsers
|
// Using XHR to avoid issues with older browsers
|
||||||
fetch(url) {
|
fetch(url, responseType = 'text') {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
try {
|
try {
|
||||||
const request = new XMLHttpRequest();
|
const request = new XMLHttpRequest();
|
||||||
@ -94,11 +94,16 @@ const utils = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
request.addEventListener('load', () => {
|
request.addEventListener('load', () => {
|
||||||
|
if (responseType === 'text') {
|
||||||
try {
|
try {
|
||||||
resolve(JSON.parse(request.responseText));
|
resolve(JSON.parse(request.responseText));
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
resolve(request.responseText);
|
resolve(request.responseText);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
resolve(request.response);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
request.addEventListener('error', () => {
|
request.addEventListener('error', () => {
|
||||||
@ -106,6 +111,10 @@ const utils = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
request.open('GET', url, true);
|
request.open('GET', url, true);
|
||||||
|
|
||||||
|
// Set the required response type
|
||||||
|
request.responseType = responseType;
|
||||||
|
|
||||||
request.send();
|
request.send();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
reject(e);
|
reject(e);
|
||||||
|
Reference in New Issue
Block a user