3.0.0-beta.20

This commit is contained in:
Sam Potts 2018-03-13 23:35:17 +11:00
parent 0538476d6f
commit c74b75e8e1
16 changed files with 118 additions and 66 deletions

53
dist/plyr.js vendored
View File

@ -3883,7 +3883,9 @@ var Listeners = function () {
}, { }, {
key: 'global', key: 'global',
value: function global(toggle) { value: function global() {
var toggle = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
// Keyboard shortcuts // Keyboard shortcuts
if (this.player.config.keyboard.global) { if (this.player.config.keyboard.global) {
utils.toggleListener(window, 'keydown keyup', this.handleKey, toggle, false); utils.toggleListener(window, 'keydown keyup', this.handleKey, toggle, false);
@ -4294,6 +4296,14 @@ var Listeners = function () {
}); });
}, false); }, false);
} }
// Reset on destroy
}, {
key: 'clear',
value: function clear() {
this.global(false);
}
}]); }]);
return Listeners; return Listeners;
}(); }();
@ -4565,7 +4575,7 @@ var Ads = function () {
var start = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; var start = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
if (!start) { if (!start) {
window.clearInterval(this.countdownTimer); clearInterval(this.countdownTimer);
this.elements.container.removeAttribute('data-badge-text'); this.elements.container.removeAttribute('data-badge-text');
return; return;
} }
@ -4576,7 +4586,7 @@ var Ads = function () {
_this5.elements.container.setAttribute('data-badge-text', label); _this5.elements.container.setAttribute('data-badge-text', label);
}; };
this.countdownTimer = window.setInterval(update, 100); this.countdownTimer = setInterval(update, 100);
} }
/** /**
@ -5351,10 +5361,10 @@ var youtube = {
utils.dispatchEvent.call(player, player.media, 'durationchange'); utils.dispatchEvent.call(player, player.media, 'durationchange');
// Reset timer // Reset timer
window.clearInterval(player.timers.buffering); clearInterval(player.timers.buffering);
// Setup buffering // Setup buffering
player.timers.buffering = window.setInterval(function () { player.timers.buffering = setInterval(function () {
// Get loaded % from YouTube // Get loaded % from YouTube
player.media.buffered = instance.getVideoLoadedFraction(); player.media.buffered = instance.getVideoLoadedFraction();
@ -5368,7 +5378,7 @@ var youtube = {
// Bail if we're at 100% // Bail if we're at 100%
if (player.media.buffered === 1) { if (player.media.buffered === 1) {
window.clearInterval(player.timers.buffering); clearInterval(player.timers.buffering);
// Trigger event // Trigger event
utils.dispatchEvent.call(player, player.media, 'canplaythrough'); utils.dispatchEvent.call(player, player.media, 'canplaythrough');
@ -5385,7 +5395,7 @@ var youtube = {
var instance = event.target; var instance = event.target;
// Reset timer // Reset timer
window.clearInterval(player.timers.playing); clearInterval(player.timers.playing);
// Handle events // Handle events
// -1 Unstarted // -1 Unstarted
@ -5425,7 +5435,7 @@ var youtube = {
utils.dispatchEvent.call(player, player.media, 'playing'); utils.dispatchEvent.call(player, player.media, 'playing');
// Poll to get playback progress // Poll to get playback progress
player.timers.playing = window.setInterval(function () { player.timers.playing = setInterval(function () {
utils.dispatchEvent.call(player, player.media, 'timeupdate'); utils.dispatchEvent.call(player, player.media, 'timeupdate');
}, 50); }, 50);
@ -6287,7 +6297,7 @@ var Plyr = function () {
this.listeners.container(); this.listeners.container();
// Global listeners // Global listeners
this.listeners.global(true); this.listeners.global();
// Setup fullscreen // Setup fullscreen
this.fullscreen = new Fullscreen(this); this.fullscreen = new Fullscreen(this);
@ -6547,7 +6557,7 @@ var Plyr = function () {
} }
// Clear timer on every call // Clear timer on every call
window.clearTimeout(this.timers.controls); clearTimeout(this.timers.controls);
// If the mouse is not over the controls, set a timeout to hide them // If the mouse is not over the controls, set a timeout to hide them
if (show || this.paused || this.loading) { if (show || this.paused || this.loading) {
@ -6666,12 +6676,12 @@ var Plyr = function () {
callback(); callback();
} }
} else { } else {
// Unbind listeners
_this4.listeners.clear();
// Replace the container with the original element provided // Replace the container with the original element provided
utils.replaceElement(_this4.elements.original, _this4.elements.container); utils.replaceElement(_this4.elements.original, _this4.elements.container);
// Unbind global listeners
_this4.listeners.global(false);
// Event // Event
utils.dispatchEvent.call(_this4, _this4.elements.original, 'destroyed', true); utils.dispatchEvent.call(_this4, _this4.elements.original, 'destroyed', true);
@ -6680,15 +6690,24 @@ var Plyr = function () {
callback.call(_this4.elements.original); callback.call(_this4.elements.original);
} }
// Clear for GC // Clear for garbage collection
_this4.elements = null; setTimeout(function () {
_this4.elements = null;
_this4.media = null;
}, 200);
} }
}; };
// Stop playback
this.stop();
// Type specific stuff // Type specific stuff
switch (this.provider + ':' + this.type) { switch (this.provider + ':' + this.type) {
case 'html5:video': case 'html5:video':
case 'html5:audio': case 'html5:audio':
// Clear timeout
clearTimeout(this.timers.loading);
// Restore native video controls // Restore native video controls
ui.toggleNativeControls.call(this, true); ui.toggleNativeControls.call(this, true);
@ -6699,8 +6718,8 @@ var Plyr = function () {
case 'youtube:video': case 'youtube:video':
// Clear timers // Clear timers
window.clearInterval(this.timers.buffering); clearInterval(this.timers.buffering);
window.clearInterval(this.timers.playing); clearInterval(this.timers.playing);
// Destroy YouTube API // Destroy YouTube API
if (this.embed !== null) { if (this.embed !== null) {

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) // Sprite (for icons)
loadSprite: true, loadSprite: true,
iconPrefix: 'plyr', iconPrefix: 'plyr',
iconUrl: 'https://cdn.plyr.io/3.0.0-beta.19/plyr.svg', iconUrl: 'https://cdn.plyr.io/3.0.0-beta.20/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',
@ -9074,7 +9074,9 @@ var Listeners = function () {
}, { }, {
key: 'global', key: 'global',
value: function global(toggle) { value: function global() {
var toggle = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
// Keyboard shortcuts // Keyboard shortcuts
if (this.player.config.keyboard.global) { if (this.player.config.keyboard.global) {
utils.toggleListener(window, 'keydown keyup', this.handleKey, toggle, false); utils.toggleListener(window, 'keydown keyup', this.handleKey, toggle, false);
@ -9485,6 +9487,14 @@ var Listeners = function () {
}); });
}, false); }, false);
} }
// Reset on destroy
}, {
key: 'clear',
value: function clear() {
this.global(false);
}
}]); }]);
return Listeners; return Listeners;
}(); }();
@ -9756,7 +9766,7 @@ var Ads = function () {
var start = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; var start = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
if (!start) { if (!start) {
window.clearInterval(this.countdownTimer); clearInterval(this.countdownTimer);
this.elements.container.removeAttribute('data-badge-text'); this.elements.container.removeAttribute('data-badge-text');
return; return;
} }
@ -9767,7 +9777,7 @@ var Ads = function () {
_this5.elements.container.setAttribute('data-badge-text', label); _this5.elements.container.setAttribute('data-badge-text', label);
}; };
this.countdownTimer = window.setInterval(update, 100); this.countdownTimer = setInterval(update, 100);
} }
/** /**
@ -10542,10 +10552,10 @@ var youtube = {
utils.dispatchEvent.call(player, player.media, 'durationchange'); utils.dispatchEvent.call(player, player.media, 'durationchange');
// Reset timer // Reset timer
window.clearInterval(player.timers.buffering); clearInterval(player.timers.buffering);
// Setup buffering // Setup buffering
player.timers.buffering = window.setInterval(function () { player.timers.buffering = setInterval(function () {
// Get loaded % from YouTube // Get loaded % from YouTube
player.media.buffered = instance.getVideoLoadedFraction(); player.media.buffered = instance.getVideoLoadedFraction();
@ -10559,7 +10569,7 @@ var youtube = {
// Bail if we're at 100% // Bail if we're at 100%
if (player.media.buffered === 1) { if (player.media.buffered === 1) {
window.clearInterval(player.timers.buffering); clearInterval(player.timers.buffering);
// Trigger event // Trigger event
utils.dispatchEvent.call(player, player.media, 'canplaythrough'); utils.dispatchEvent.call(player, player.media, 'canplaythrough');
@ -10576,7 +10586,7 @@ var youtube = {
var instance = event.target; var instance = event.target;
// Reset timer // Reset timer
window.clearInterval(player.timers.playing); clearInterval(player.timers.playing);
// Handle events // Handle events
// -1 Unstarted // -1 Unstarted
@ -10616,7 +10626,7 @@ var youtube = {
utils.dispatchEvent.call(player, player.media, 'playing'); utils.dispatchEvent.call(player, player.media, 'playing');
// Poll to get playback progress // Poll to get playback progress
player.timers.playing = window.setInterval(function () { player.timers.playing = setInterval(function () {
utils.dispatchEvent.call(player, player.media, 'timeupdate'); utils.dispatchEvent.call(player, player.media, 'timeupdate');
}, 50); }, 50);
@ -11222,7 +11232,7 @@ var source = {
// ========================================================================== // ==========================================================================
// Plyr // Plyr
// plyr.js v3.0.0-beta.19 // plyr.js v3.0.0-beta.20
// https://github.com/sampotts/plyr // https://github.com/sampotts/plyr
// License: The MIT License (MIT) // License: The MIT License (MIT)
// ========================================================================== // ==========================================================================
@ -11478,7 +11488,7 @@ var Plyr$1 = function () {
this.listeners.container(); this.listeners.container();
// Global listeners // Global listeners
this.listeners.global(true); this.listeners.global();
// Setup fullscreen // Setup fullscreen
this.fullscreen = new Fullscreen(this); this.fullscreen = new Fullscreen(this);
@ -11738,7 +11748,7 @@ var Plyr$1 = function () {
} }
// Clear timer on every call // Clear timer on every call
window.clearTimeout(this.timers.controls); clearTimeout(this.timers.controls);
// If the mouse is not over the controls, set a timeout to hide them // If the mouse is not over the controls, set a timeout to hide them
if (show || this.paused || this.loading) { if (show || this.paused || this.loading) {
@ -11857,12 +11867,12 @@ var Plyr$1 = function () {
callback(); callback();
} }
} else { } else {
// Unbind listeners
_this4.listeners.clear();
// Replace the container with the original element provided // Replace the container with the original element provided
utils.replaceElement(_this4.elements.original, _this4.elements.container); utils.replaceElement(_this4.elements.original, _this4.elements.container);
// Unbind global listeners
_this4.listeners.global(false);
// Event // Event
utils.dispatchEvent.call(_this4, _this4.elements.original, 'destroyed', true); utils.dispatchEvent.call(_this4, _this4.elements.original, 'destroyed', true);
@ -11871,15 +11881,24 @@ var Plyr$1 = function () {
callback.call(_this4.elements.original); callback.call(_this4.elements.original);
} }
// Clear for GC // Clear for garbage collection
_this4.elements = null; setTimeout(function () {
_this4.elements = null;
_this4.media = null;
}, 200);
} }
}; };
// Stop playback
this.stop();
// Type specific stuff // Type specific stuff
switch (this.provider + ':' + this.type) { switch (this.provider + ':' + this.type) {
case 'html5:video': case 'html5:video':
case 'html5:audio': case 'html5:audio':
// Clear timeout
clearTimeout(this.timers.loading);
// Restore native video controls // Restore native video controls
ui.toggleNativeControls.call(this, true); ui.toggleNativeControls.call(this, true);
@ -11890,8 +11909,8 @@ var Plyr$1 = function () {
case 'youtube:video': case 'youtube:video':
// Clear timers // Clear timers
window.clearInterval(this.timers.buffering); clearInterval(this.timers.buffering);
window.clearInterval(this.timers.playing); clearInterval(this.timers.playing);
// Destroy YouTube API // Destroy YouTube API
if (this.embed !== null) { if (this.embed !== null) {

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", "name": "plyr",
"version": "3.0.0-beta.19", "version": "3.0.0-beta.20",
"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",

View File

@ -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: 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.19/plyr.js"></script> <script src="https://cdn.plyr.io/3.0.0-beta.20/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.19/plyr.css"> <link rel="stylesheet" href="https://cdn.plyr.io/3.0.0-beta.20/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.19/plyr.svg`. reference, the CDN hosted SVG sprite can be found at `https://cdn.plyr.io/3.0.0-beta.20/plyr.svg`.
## Advanced ## Advanced

View File

@ -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.19/plyr.svg', iconUrl: 'https://cdn.plyr.io/3.0.0-beta.20/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',

View File

@ -188,7 +188,7 @@ class Listeners {
} }
// Global window & document listeners // Global window & document listeners
global(toggle) { global(toggle = true) {
// Keyboard shortcuts // Keyboard shortcuts
if (this.player.config.keyboard.global) { if (this.player.config.keyboard.global) {
utils.toggleListener(window, 'keydown keyup', this.handleKey, toggle, false); utils.toggleListener(window, 'keydown keyup', this.handleKey, toggle, false);
@ -585,6 +585,11 @@ class Listeners {
false, false,
); );
} }
// Reset on destroy
clear() {
this.global(false);
}
} }
export default Listeners; export default Listeners;

View File

@ -171,7 +171,7 @@ class Ads {
*/ */
pollCountdown(start = false) { pollCountdown(start = false) {
if (!start) { if (!start) {
window.clearInterval(this.countdownTimer); clearInterval(this.countdownTimer);
this.elements.container.removeAttribute('data-badge-text'); this.elements.container.removeAttribute('data-badge-text');
return; return;
} }
@ -182,7 +182,7 @@ class Ads {
this.elements.container.setAttribute('data-badge-text', label); this.elements.container.setAttribute('data-badge-text', label);
}; };
this.countdownTimer = window.setInterval(update, 100); this.countdownTimer = setInterval(update, 100);
} }
/** /**

View File

@ -305,10 +305,10 @@ const youtube = {
utils.dispatchEvent.call(player, player.media, 'durationchange'); utils.dispatchEvent.call(player, player.media, 'durationchange');
// Reset timer // Reset timer
window.clearInterval(player.timers.buffering); clearInterval(player.timers.buffering);
// Setup buffering // Setup buffering
player.timers.buffering = window.setInterval(() => { player.timers.buffering = setInterval(() => {
// Get loaded % from YouTube // Get loaded % from YouTube
player.media.buffered = instance.getVideoLoadedFraction(); player.media.buffered = instance.getVideoLoadedFraction();
@ -322,7 +322,7 @@ const youtube = {
// Bail if we're at 100% // Bail if we're at 100%
if (player.media.buffered === 1) { if (player.media.buffered === 1) {
window.clearInterval(player.timers.buffering); clearInterval(player.timers.buffering);
// Trigger event // Trigger event
utils.dispatchEvent.call(player, player.media, 'canplaythrough'); utils.dispatchEvent.call(player, player.media, 'canplaythrough');
@ -337,7 +337,7 @@ const youtube = {
const instance = event.target; const instance = event.target;
// Reset timer // Reset timer
window.clearInterval(player.timers.playing); clearInterval(player.timers.playing);
// Handle events // Handle events
// -1 Unstarted // -1 Unstarted
@ -377,7 +377,7 @@ const youtube = {
utils.dispatchEvent.call(player, player.media, 'playing'); utils.dispatchEvent.call(player, player.media, 'playing');
// Poll to get playback progress // Poll to get playback progress
player.timers.playing = window.setInterval(() => { player.timers.playing = setInterval(() => {
utils.dispatchEvent.call(player, player.media, 'timeupdate'); utils.dispatchEvent.call(player, player.media, 'timeupdate');
}, 50); }, 50);

View File

@ -1,6 +1,6 @@
// ========================================================================== // ==========================================================================
// Plyr // Plyr
// plyr.js v3.0.0-beta.19 // plyr.js v3.0.0-beta.20
// https://github.com/sampotts/plyr // https://github.com/sampotts/plyr
// License: The MIT License (MIT) // License: The MIT License (MIT)
// ========================================================================== // ==========================================================================
@ -276,7 +276,7 @@ class Plyr {
this.listeners.container(); this.listeners.container();
// Global listeners // Global listeners
this.listeners.global(true); this.listeners.global();
// Setup fullscreen // Setup fullscreen
this.fullscreen = new Fullscreen(this); this.fullscreen = new Fullscreen(this);
@ -951,7 +951,7 @@ class Plyr {
} }
// Clear timer on every call // Clear timer on every call
window.clearTimeout(this.timers.controls); clearTimeout(this.timers.controls);
// If the mouse is not over the controls, set a timeout to hide them // If the mouse is not over the controls, set a timeout to hide them
if (show || this.paused || this.loading) { if (show || this.paused || this.loading) {
@ -1057,12 +1057,12 @@ class Plyr {
callback(); callback();
} }
} else { } else {
// Unbind listeners
this.listeners.clear();
// Replace the container with the original element provided // Replace the container with the original element provided
utils.replaceElement(this.elements.original, this.elements.container); utils.replaceElement(this.elements.original, this.elements.container);
// Unbind global listeners
this.listeners.global(false);
// Event // Event
utils.dispatchEvent.call(this, this.elements.original, 'destroyed', true); utils.dispatchEvent.call(this, this.elements.original, 'destroyed', true);
@ -1071,15 +1071,24 @@ class Plyr {
callback.call(this.elements.original); callback.call(this.elements.original);
} }
// Clear for GC // Clear for garbage collection
this.elements = null; setTimeout(() => {
this.elements = null;
this.media = null;
}, 200);
} }
}; };
// Stop playback
this.stop();
// Type specific stuff // Type specific stuff
switch (`${this.provider}:${this.type}`) { switch (`${this.provider}:${this.type}`) {
case 'html5:video': case 'html5:video':
case 'html5:audio': case 'html5:audio':
// Clear timeout
clearTimeout(this.timers.loading);
// Restore native video controls // Restore native video controls
ui.toggleNativeControls.call(this, true); ui.toggleNativeControls.call(this, true);
@ -1090,8 +1099,8 @@ class Plyr {
case 'youtube:video': case 'youtube:video':
// Clear timers // Clear timers
window.clearInterval(this.timers.buffering); clearInterval(this.timers.buffering);
window.clearInterval(this.timers.playing); clearInterval(this.timers.playing);
// Destroy YouTube API // Destroy YouTube API
if (this.embed !== null) { if (this.embed !== null) {

View File

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