Compare commits

...

7 Commits

Author SHA1 Message Date
0d0ece94d3 Fix regression 2018-03-29 20:20:37 +11:00
1c06f6d06d Vimeo hotfix 2018-03-29 19:35:02 +11:00
dda8e30b92 Merge branch 'master' of github.com:sampotts/plyr 2018-03-28 22:45:18 +11:00
c4e2e24643 Bug fixes 2018-03-28 22:45:11 +11:00
e020a105a3 Update readme.md 2018-03-28 00:55:55 +11:00
2b7fe9a4f9 v3.0.6 2018-03-28 00:17:15 +11:00
951df64b7f v3.0.5 2018-03-27 23:52:26 +11:00
24 changed files with 179 additions and 88 deletions

View File

@ -1,4 +1,32 @@
# v3.0.3
## v3.0.9
* Demo fix
* Fix Vimeo regression
## v3.0.8
* Vimeo hotfix for private videos
## v3.0.7
* Fix for keyboard shortcut error with fast forward
* Fix for Vimeo trying to set playback rate when not allowed
## v3.0.6
* Improved the logic for the custom handlers preventing default handlers
## v3.0.5
* Removed console messages
## v3.0.4
* Fixes for fullscreen not working inside iframes
* Fixes for custom handlers being able to prevent default
* Fixes for controls not hiding/showing correctly on Mobile Safari
## v3.0.3
* Vimeo offset tweak (fixes #826)
* Fix for .stop() method (fixes #819)
@ -9,11 +37,11 @@
* Fix fast-forward control (thanks @saadshahd)
* Fix the options link in the readme (thanks @DanielRuf)
# v3.0.2
## v3.0.2
* Fix for Safari not firing error events when trying to load blocked scripts
# v3.0.1
## v3.0.1
* Fix for trying to accessing local storage when it's blocked

2
demo/dist/demo.js vendored
View File

@ -3843,7 +3843,7 @@ var singleton = Raven;
google: 'AIzaSyDrNwtN3nLH_8rjCmu5Wq3ZCm4MNAVdc0c'
},
ads: {
// enabled: true,
enabled: true,
publisherId: '918848828995742'
}
});

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -80,7 +80,7 @@ import Raven from 'raven-js';
google: 'AIzaSyDrNwtN3nLH_8rjCmu5Wq3ZCm4MNAVdc0c',
},
ads: {
// enabled: true,
enabled: true,
publisherId: '918848828995742',
},
});

59
dist/plyr.js vendored
View File

@ -77,7 +77,7 @@ var defaults = {
// Sprite (for icons)
loadSprite: true,
iconPrefix: 'plyr',
iconUrl: 'https://cdn.plyr.io/3.0.3/plyr.svg',
iconUrl: 'https://cdn.plyr.io/3.0.8/plyr.svg',
// Blank video (used to prevent errors on source change)
blankVideo: 'https://cdn.plyr.io/static/blank.mp4',
@ -2130,8 +2130,6 @@ var Fullscreen = function () {
return;
}
console.warn(this.prefix);
// iOS native fullscreen doesn't need the request step
if (browser.isIos && this.player.config.fullscreen.iosNative) {
if (this.player.playing) {
@ -2174,8 +2172,6 @@ var Fullscreen = function () {
}, {
key: 'toggle',
value: function toggle() {
console.warn('TOGGLE');
if (!this.active) {
this.enter();
} else {
@ -3537,9 +3533,14 @@ var controls = {
// Set a list of available captions languages
setSpeedMenu: function setSpeedMenu() {
setSpeedMenu: function setSpeedMenu(options) {
var _this4 = this;
// Do nothing if not selected
if (!this.config.controls.includes('settings') || !this.config.settings.includes('speed')) {
return;
}
// Menu required
if (!utils.is.element(this.elements.settings.panes.speed)) {
return;
@ -3547,9 +3548,11 @@ var controls = {
var type = 'speed';
// Set the default speeds
if (!utils.is.array(this.options.speed) || !this.options.speed.length) {
// Set the speed options
if (!utils.is.array(options)) {
this.options.speed = [0.5, 0.75, 1, 1.25, 1.5, 1.75, 2];
} else {
this.options.speed = options;
}
// Set options if passed and filter based on config
@ -3561,6 +3564,9 @@ var controls = {
var toggle = !utils.is.empty(this.options.speed);
controls.toggleTab.call(this, type, toggle);
// Check if we need to toggle the parent
controls.checkMenu.call(this);
// If we're hiding, nothing more to do
if (!toggle) {
return;
@ -3585,6 +3591,15 @@ var controls = {
},
// Check if we need to hide/show the settings menu
checkMenu: function checkMenu() {
var speedHidden = this.elements.settings.tabs.speed.getAttribute('hidden') !== null;
var languageHidden = this.elements.settings.tabs.captions.getAttribute('hidden') !== null;
utils.toggleHidden(this.elements.settings.menu, speedHidden && languageHidden);
},
// Show/hide menu
toggleMenu: function toggleMenu(event) {
var form = this.elements.settings.form;
@ -3975,9 +3990,7 @@ var controls = {
this.elements.controls = container;
if (this.config.controls.includes('settings') && this.config.settings.includes('speed')) {
controls.setSpeedMenu.call(this);
}
controls.setSpeedMenu.call(this);
return container;
},
@ -4183,7 +4196,7 @@ var Listeners = function () {
case 39:
// Arrow forward
this.player.fastForward();
this.player.forward();
break;
case 37:
@ -4480,14 +4493,15 @@ var Listeners = function () {
var proxy = function proxy(event, defaultHandler, customHandlerKey) {
var customHandler = _this4.player.config.listeners[customHandlerKey];
var hasCustomHandler = utils.is.function(customHandler);
var returned = true;
// Execute custom handler
if (hasCustomHandler) {
customHandler.call(_this4.player, event);
returned = customHandler.call(_this4.player, event);
}
// Only call default handler if not prevented in custom handler
if (!event.defaultPrevented && utils.is.function(defaultHandler)) {
if (returned && utils.is.function(defaultHandler)) {
defaultHandler.call(_this4.player, event);
}
};
@ -5713,7 +5727,8 @@ var youtube = {
});
// Get available speeds
player.options.speed = instance.getAvailablePlaybackRates();
var options = instance.getAvailablePlaybackRates();
controls.setSpeedMenu.call(player, options);
// Set the tabindex to avoid focus entering iframe
if (player.supported.ui) {
@ -5760,8 +5775,6 @@ var youtube = {
// Reset timer
clearInterval(player.timers.playing);
console.warn(event.data);
// Handle events
// -1 Unstarted
// 0 Ended
@ -5992,6 +6005,11 @@ var vimeo = {
player.embed.setPlaybackRate(input).then(function () {
speed = input;
utils.dispatchEvent.call(player, player.media, 'ratechange');
}).catch(function (error) {
// Hide menu item (and menu if empty)
if (error.name === 'Error') {
controls.setSpeedMenu.call(player, []);
}
});
}
});
@ -6048,7 +6066,10 @@ var vimeo = {
var currentSrc = void 0;
player.embed.getVideoUrl().then(function (value) {
currentSrc = value;
}).catch(function (error) {
_this2.debug.warn(error);
});
Object.defineProperty(player.media, 'currentSrc', {
get: function get() {
return currentSrc;
@ -6414,7 +6435,7 @@ var source = {
// ==========================================================================
// Plyr
// plyr.js v3.0.3
// plyr.js v3.0.8
// https://github.com/sampotts/plyr
// License: The MIT License (MIT)
// ==========================================================================
@ -6973,8 +6994,6 @@ var Plyr = function () {
// then set the timer to hide the controls
if (!show || this.playing) {
this.timers.controls = setTimeout(function () {
console.warn(_this3.elements.controls.pressed, _this3.elements.controls.hover, delay);
// If the mouse is over the controls (and not entering fullscreen), bail
if ((_this3.elements.controls.pressed || _this3.elements.controls.hover) && !isEnterFullscreen) {
return;

2
dist/plyr.js.map vendored

File diff suppressed because one or more lines are too long

2
dist/plyr.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -5268,7 +5268,7 @@ var defaults = {
// Sprite (for icons)
loadSprite: true,
iconPrefix: 'plyr',
iconUrl: 'https://cdn.plyr.io/3.0.4/plyr.svg',
iconUrl: 'https://cdn.plyr.io/3.0.9/plyr.svg',
// Blank video (used to prevent errors on source change)
blankVideo: 'https://cdn.plyr.io/static/blank.mp4',
@ -7311,8 +7311,6 @@ var Fullscreen = function () {
return;
}
console.warn(this.prefix);
// iOS native fullscreen doesn't need the request step
if (browser.isIos && this.player.config.fullscreen.iosNative) {
if (this.player.playing) {
@ -7355,8 +7353,6 @@ var Fullscreen = function () {
}, {
key: 'toggle',
value: function toggle() {
console.warn('TOGGLE');
if (!this.active) {
this.enter();
} else {
@ -8718,9 +8714,14 @@ var controls = {
// Set a list of available captions languages
setSpeedMenu: function setSpeedMenu() {
setSpeedMenu: function setSpeedMenu(options) {
var _this4 = this;
// Do nothing if not selected
if (!this.config.controls.includes('settings') || !this.config.settings.includes('speed')) {
return;
}
// Menu required
if (!utils.is.element(this.elements.settings.panes.speed)) {
return;
@ -8728,9 +8729,11 @@ var controls = {
var type = 'speed';
// Set the default speeds
if (!utils.is.array(this.options.speed) || !this.options.speed.length) {
// Set the speed options
if (!utils.is.array(options)) {
this.options.speed = [0.5, 0.75, 1, 1.25, 1.5, 1.75, 2];
} else {
this.options.speed = options;
}
// Set options if passed and filter based on config
@ -8742,6 +8745,9 @@ var controls = {
var toggle = !utils.is.empty(this.options.speed);
controls.toggleTab.call(this, type, toggle);
// Check if we need to toggle the parent
controls.checkMenu.call(this);
// If we're hiding, nothing more to do
if (!toggle) {
return;
@ -8766,6 +8772,15 @@ var controls = {
},
// Check if we need to hide/show the settings menu
checkMenu: function checkMenu() {
var speedHidden = this.elements.settings.tabs.speed.getAttribute('hidden') !== null;
var languageHidden = this.elements.settings.tabs.captions.getAttribute('hidden') !== null;
utils.toggleHidden(this.elements.settings.menu, speedHidden && languageHidden);
},
// Show/hide menu
toggleMenu: function toggleMenu(event) {
var form = this.elements.settings.form;
@ -9156,9 +9171,7 @@ var controls = {
this.elements.controls = container;
if (this.config.controls.includes('settings') && this.config.settings.includes('speed')) {
controls.setSpeedMenu.call(this);
}
controls.setSpeedMenu.call(this);
return container;
},
@ -9364,7 +9377,7 @@ var Listeners = function () {
case 39:
// Arrow forward
this.player.fastForward();
this.player.forward();
break;
case 37:
@ -9661,14 +9674,15 @@ var Listeners = function () {
var proxy = function proxy(event, defaultHandler, customHandlerKey) {
var customHandler = _this4.player.config.listeners[customHandlerKey];
var hasCustomHandler = utils.is.function(customHandler);
var returned = true;
// Execute custom handler
if (hasCustomHandler) {
customHandler.call(_this4.player, event);
returned = customHandler.call(_this4.player, event);
}
// Only call default handler if not prevented in custom handler
if (!event.defaultPrevented && utils.is.function(defaultHandler)) {
if (returned && utils.is.function(defaultHandler)) {
defaultHandler.call(_this4.player, event);
}
};
@ -10894,7 +10908,8 @@ var youtube = {
});
// Get available speeds
player.options.speed = instance.getAvailablePlaybackRates();
var options = instance.getAvailablePlaybackRates();
controls.setSpeedMenu.call(player, options);
// Set the tabindex to avoid focus entering iframe
if (player.supported.ui) {
@ -10941,8 +10956,6 @@ var youtube = {
// Reset timer
clearInterval(player.timers.playing);
console.warn(event.data);
// Handle events
// -1 Unstarted
// 0 Ended
@ -11173,6 +11186,11 @@ var vimeo = {
player.embed.setPlaybackRate(input).then(function () {
speed = input;
utils.dispatchEvent.call(player, player.media, 'ratechange');
}).catch(function (error) {
// Hide menu item (and menu if empty)
if (error.name === 'Error') {
controls.setSpeedMenu.call(player, []);
}
});
}
});
@ -11229,7 +11247,10 @@ var vimeo = {
var currentSrc = void 0;
player.embed.getVideoUrl().then(function (value) {
currentSrc = value;
}).catch(function (error) {
_this2.debug.warn(error);
});
Object.defineProperty(player.media, 'currentSrc', {
get: function get() {
return currentSrc;
@ -11595,7 +11616,7 @@ var source = {
// ==========================================================================
// Plyr
// plyr.js v3.0.4
// plyr.js v3.0.9
// https://github.com/sampotts/plyr
// License: The MIT License (MIT)
// ==========================================================================
@ -12154,8 +12175,6 @@ var Plyr$1 = function () {
// then set the timer to hide the controls
if (!show || this.playing) {
this.timers.controls = setTimeout(function () {
console.warn(_this3.elements.controls.pressed, _this3.elements.controls.hover, delay);
// If the mouse is over the controls (and not entering fullscreen), bail
if ((_this3.elements.controls.pressed || _this3.elements.controls.hover) && !isEnterFullscreen) {
return;
@ -12913,7 +12932,7 @@ var Plyr$1 = function () {
// ==========================================================================
// Plyr Polyfilled Build
// plyr.js v3.0.3
// plyr.js v3.0.8
// https://github.com/sampotts/plyr
// License: The MIT License (MIT)
// ==========================================================================

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{
"name": "plyr",
"version": "3.0.4",
"version": "3.0.9",
"description": "A simple, accessible and customizable HTML5, YouTube and Vimeo media player",
"homepage": "https://plyr.io",
"main": "./dist/plyr.js",

View File

@ -2,7 +2,7 @@
A simple, lightweight, accessible and customizable HTML5, YouTube and Vimeo media player that supports [_modern_](#browser-support) browsers.
[Checkout the demo](https://plyr.io) - [Donate to support Plyr](#donate) - [Chat on Slack](https://bit.ly/plyr-slack)
[Checkout the demo](https://plyr.io) - [Donate to support Plyr](#donate) - [Chat on Slack](https://bit.ly/plyr-chat)
[![Image of Plyr](https://cdn.plyr.io/static/demo/screenshot.png?v=3)](https://plyr.io)
@ -128,7 +128,7 @@ See [initialising](#initialising) for more information on advanced setups.
If you want to use our CDN (provided by [Fastly](https://www.fastly.com/)) for the JavaScript, you can use the following:
```html
<script src="https://cdn.plyr.io/3.0.4/plyr.js"></script>
<script src="https://cdn.plyr.io/3.0.9/plyr.js"></script>
```
_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:
```html
<link rel="stylesheet" href="https://cdn.plyr.io/3.0.4/plyr.css">
<link rel="stylesheet" href="https://cdn.plyr.io/3.0.9/plyr.css">
```
### 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
reference, the CDN hosted SVG sprite can be found at `https://cdn.plyr.io/3.0.4/plyr.svg`.
reference, the CDN hosted SVG sprite can be found at `https://cdn.plyr.io/3.0.9/plyr.svg`.
## Ads

28
src/js/controls.js vendored
View File

@ -706,7 +706,12 @@ const controls = {
},
// Set a list of available captions languages
setSpeedMenu() {
setSpeedMenu(options) {
// Do nothing if not selected
if (!this.config.controls.includes('settings') || !this.config.settings.includes('speed')) {
return;
}
// Menu required
if (!utils.is.element(this.elements.settings.panes.speed)) {
return;
@ -714,8 +719,8 @@ const controls = {
const type = 'speed';
// Set the default speeds
if (!utils.is.array(this.options.speed) || !this.options.speed.length) {
// Set the speed options
if (!utils.is.array(options)) {
this.options.speed = [
0.5,
0.75,
@ -725,6 +730,8 @@ const controls = {
1.75,
2,
];
} else {
this.options.speed = options;
}
// Set options if passed and filter based on config
@ -734,6 +741,9 @@ const controls = {
const toggle = !utils.is.empty(this.options.speed);
controls.toggleTab.call(this, type, toggle);
// Check if we need to toggle the parent
controls.checkMenu.call(this);
// If we're hiding, nothing more to do
if (!toggle) {
return;
@ -755,6 +765,14 @@ const controls = {
controls.updateSetting.call(this, type, list);
},
// Check if we need to hide/show the settings menu
checkMenu() {
const speedHidden = this.elements.settings.tabs.speed.getAttribute('hidden') !== null;
const languageHidden = this.elements.settings.tabs.captions.getAttribute('hidden') !== null;
utils.toggleHidden(this.elements.settings.menu, speedHidden && languageHidden);
},
// Show/hide menu
toggleMenu(event) {
const { form } = this.elements.settings;
@ -1159,9 +1177,7 @@ const controls = {
this.elements.controls = container;
if (this.config.controls.includes('settings') && this.config.settings.includes('speed')) {
controls.setSpeedMenu.call(this);
}
controls.setSpeedMenu.call(this);
return container;
},

View File

@ -56,7 +56,7 @@ const defaults = {
// Sprite (for icons)
loadSprite: true,
iconPrefix: 'plyr',
iconUrl: 'https://cdn.plyr.io/3.0.4/plyr.svg',
iconUrl: 'https://cdn.plyr.io/3.0.9/plyr.svg',
// Blank video (used to prevent errors on source change)
blankVideo: 'https://cdn.plyr.io/static/blank.mp4',

View File

@ -164,8 +164,6 @@ class Fullscreen {
return;
}
console.warn(this.prefix);
// iOS native fullscreen doesn't need the request step
if (browser.isIos && this.player.config.fullscreen.iosNative) {
if (this.player.playing) {
@ -202,8 +200,6 @@ class Fullscreen {
// Toggle state
toggle() {
console.warn('TOGGLE');
if (!this.active) {
this.enter();
} else {

View File

@ -129,7 +129,7 @@ class Listeners {
case 39:
// Arrow forward
this.player.fastForward();
this.player.forward();
break;
case 37:
@ -398,14 +398,15 @@ class Listeners {
const proxy = (event, defaultHandler, customHandlerKey) => {
const customHandler = this.player.config.listeners[customHandlerKey];
const hasCustomHandler = utils.is.function(customHandler);
let returned = true;
// Execute custom handler
if (hasCustomHandler) {
customHandler.call(this.player, event);
returned = customHandler.call(this.player, event);
}
// Only call default handler if not prevented in custom handler
if (!event.defaultPrevented && utils.is.function(defaultHandler)) {
if (returned && utils.is.function(defaultHandler)) {
defaultHandler.call(this.player, event);
}
};

View File

@ -4,6 +4,7 @@
import utils from './../utils';
import captions from './../captions';
import controls from './../controls';
import ui from './../ui';
const vimeo = {
@ -139,10 +140,18 @@ const vimeo = {
return speed;
},
set(input) {
player.embed.setPlaybackRate(input).then(() => {
speed = input;
utils.dispatchEvent.call(player, player.media, 'ratechange');
});
player.embed
.setPlaybackRate(input)
.then(() => {
speed = input;
utils.dispatchEvent.call(player, player.media, 'ratechange');
})
.catch(error => {
// Hide menu item (and menu if empty)
if (error.name === 'Error') {
controls.setSpeedMenu.call(player, []);
}
});
},
});
@ -193,9 +202,15 @@ const vimeo = {
// Source
let currentSrc;
player.embed.getVideoUrl().then(value => {
currentSrc = value;
});
player.embed
.getVideoUrl()
.then(value => {
currentSrc = value;
})
.catch(error => {
this.debug.warn(error);
});
Object.defineProperty(player.media, 'currentSrc', {
get() {
return currentSrc;

View File

@ -294,7 +294,8 @@ const youtube = {
});
// Get available speeds
player.options.speed = instance.getAvailablePlaybackRates();
const options = instance.getAvailablePlaybackRates();
controls.setSpeedMenu.call(player, options);
// Set the tabindex to avoid focus entering iframe
if (player.supported.ui) {
@ -339,8 +340,6 @@ const youtube = {
// Reset timer
clearInterval(player.timers.playing);
console.warn(event.data);
// Handle events
// -1 Unstarted
// 0 Ended

View File

@ -1,6 +1,6 @@
// ==========================================================================
// Plyr
// plyr.js v3.0.4
// plyr.js v3.0.9
// https://github.com/sampotts/plyr
// License: The MIT License (MIT)
// ==========================================================================
@ -1019,8 +1019,6 @@ class Plyr {
// then set the timer to hide the controls
if (!show || this.playing) {
this.timers.controls = setTimeout(() => {
console.warn(this.elements.controls.pressed, this.elements.controls.hover, delay);
// If the mouse is over the controls (and not entering fullscreen), bail
if ((this.elements.controls.pressed || this.elements.controls.hover) && !isEnterFullscreen) {
return;

View File

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