aboutsummaryrefslogtreecommitdiffstats
path: root/src/js
diff options
context:
space:
mode:
Diffstat (limited to 'src/js')
-rw-r--r--src/js/captions.js2
-rw-r--r--src/js/controls.js4
-rw-r--r--src/js/fullscreen.js4
-rw-r--r--src/js/listeners.js4
-rw-r--r--src/js/media.js4
-rw-r--r--src/js/plyr.js49
-rw-r--r--src/js/source.js2
-rw-r--r--src/js/ui.js2
-rw-r--r--src/js/utils.js2
9 files changed, 39 insertions, 34 deletions
diff --git a/src/js/captions.js b/src/js/captions.js
index 851bf58d..247bf5db 100644
--- a/src/js/captions.js
+++ b/src/js/captions.js
@@ -183,7 +183,7 @@ const captions = {
// Set new caption text
this.elements.captions.appendChild(content);
} else {
- this.warn('No captions element to render to');
+ this.console.warn('No captions element to render to');
}
},
diff --git a/src/js/controls.js b/src/js/controls.js
index 895dfa2b..748d848c 100644
--- a/src/js/controls.js
+++ b/src/js/controls.js
@@ -542,13 +542,13 @@ const controls = {
// Unsupported value
if (!this.options[setting].includes(value)) {
- this.warn(`Unsupported value of '${value}' for ${setting}`);
+ this.console.warn(`Unsupported value of '${value}' for ${setting}`);
return;
}
// Disabled value
if (!this.config[setting].options.includes(value)) {
- this.warn(`Disabled value of '${value}' for ${setting}`);
+ this.console.warn(`Disabled value of '${value}' for ${setting}`);
return;
}
diff --git a/src/js/fullscreen.js b/src/js/fullscreen.js
index 3e46150d..3dcdc1bf 100644
--- a/src/js/fullscreen.js
+++ b/src/js/fullscreen.js
@@ -108,12 +108,12 @@ const fullscreen = {
const nativeSupport = fullscreen.enabled;
if (nativeSupport || (this.config.fullscreen.fallback && !utils.inFrame())) {
- this.log(`${nativeSupport ? 'Native' : 'Fallback'} fullscreen enabled`);
+ this.console.log(`${nativeSupport ? 'Native' : 'Fallback'} fullscreen enabled`);
// Add styling hook to show button
utils.toggleClass(this.elements.container, this.config.classNames.fullscreen.enabled, true);
} else {
- this.log('Fullscreen not supported and fallback disabled');
+ this.console.log('Fullscreen not supported and fallback disabled');
}
// Toggle state
diff --git a/src/js/listeners.js b/src/js/listeners.js
index 00f4c9b8..71f381f7 100644
--- a/src/js/listeners.js
+++ b/src/js/listeners.js
@@ -101,7 +101,7 @@ const listeners = {
case 75:
// Space and K key
if (!held) {
- this.warn('togglePlay', event.type);
+ this.console.warn('togglePlay', event.type);
this.togglePlay();
}
break;
@@ -475,7 +475,7 @@ const listeners = {
// TODO: This should be done in the method itself I think
// var value = event.target.getAttribute('data-loop__value') || event.target.getAttribute('data-loop__type');
- this.warn('Set loop');
+ this.console.warn('Set loop');
});
}
});
diff --git a/src/js/media.js b/src/js/media.js
index 46e6bec6..7904bd5b 100644
--- a/src/js/media.js
+++ b/src/js/media.js
@@ -16,7 +16,7 @@ const media = {
setup() {
// If there's no media, bail
if (!this.media) {
- this.warn('No media element found!');
+ this.console.warn('No media element found!');
return;
}
@@ -105,7 +105,7 @@ const media = {
this.media.load();
// Debugging
- this.log('Cancelled network requests');
+ this.console.log('Cancelled network requests');
},
};
diff --git a/src/js/plyr.js b/src/js/plyr.js
index 8733d4a2..35df7073 100644
--- a/src/js/plyr.js
+++ b/src/js/plyr.js
@@ -97,42 +97,46 @@ class Plyr {
};
// Debugging
- this.log = () => {};
- this.warn = () => {};
- this.error = () => {};
+ this.console = {
+ log() {},
+ warn() {},
+ error() {},
+ };
if (this.config.debug && 'console' in window) {
- this.log = console.log; // eslint-disable-line
- this.warn = console.warn; // eslint-disable-line
- this.error = console.error; // eslint-disable-line
- this.log('Debugging enabled');
+ this.console = {
+ log: console.log, // eslint-disable-line
+ warn: console.warn, // eslint-disable-line
+ error: console.error, // eslint-disable-line
+ };
+ this.console.log('Debugging enabled');
}
// Log config options and support
- this.log('Config', this.config);
- this.log('Support', support);
+ this.console.log('Config', this.config);
+ this.console.log('Support', support);
// We need an element to setup
if (this.media === null || utils.is.undefined(this.media) || !utils.is.htmlElement(this.media)) {
- this.error('Setup failed: no suitable element passed');
+ this.console.error('Setup failed: no suitable element passed');
return;
}
// Bail if the element is initialized
if (this.media.plyr) {
- this.warn('Target already setup');
+ this.console.warn('Target already setup');
return;
}
// Bail if not enabled
if (!this.config.enabled) {
- this.error('Setup failed: disabled by config');
+ this.console.error('Setup failed: disabled by config');
return;
}
// Bail if disabled or no basic support
// You may want to disable certain UAs etc
if (!support.check().api) {
- this.error('Setup failed: no support');
+ this.console.error('Setup failed: no support');
return;
}
@@ -152,12 +156,12 @@ class Plyr {
this.embedId = this.media.getAttribute('data-video-id');
if (utils.is.empty(this.type)) {
- this.error('Setup failed: embed type missing');
+ this.console.error('Setup failed: embed type missing');
return;
}
if (utils.is.empty(this.embedId)) {
- this.error('Setup failed: video id missing');
+ this.console.error('Setup failed: video id missing');
return;
}
@@ -189,7 +193,7 @@ class Plyr {
break;
default:
- this.error('Setup failed: unsupported type');
+ this.console.error('Setup failed: unsupported type');
return;
}
@@ -201,7 +205,7 @@ class Plyr {
// If no support for even API, bail
if (!this.supported.api) {
- this.error('Setup failed: no support');
+ this.console.error('Setup failed: no support');
return;
}
@@ -227,7 +231,7 @@ class Plyr {
// Listen for events if debugging
if (this.config.debug) {
utils.on(this.elements.container, this.config.events.join(' '), event => {
- this.log(`event: ${event.type}`);
+ this.console.log(`event: ${event.type}`);
});
}
@@ -352,7 +356,7 @@ class Plyr {
this.media.currentTime = targetTime.toFixed(4);
// Logging
- this.log(`Seeking to ${this.currentTime} seconds`);
+ this.console.log(`Seeking to ${this.currentTime} seconds`);
}
get currentTime() {
@@ -488,7 +492,7 @@ class Plyr {
}
if (!this.config.speed.options.includes(speed)) {
- this.warn(`Unsupported speed (${speed})`);
+ this.console.warn(`Unsupported speed (${speed})`);
return;
}
@@ -516,7 +520,7 @@ class Plyr {
}
if (!this.options.quality.includes(quality)) {
- this.warn(`Unsupported quality option (${quality})`);
+ this.console.warn(`Unsupported quality option (${quality})`);
return;
}
@@ -598,7 +602,7 @@ class Plyr {
// Poster image
set poster(input) {
if (this.type !== 'video') {
- this.warn('Poster can only be set on HTML5 video');
+ this.console.warn('Poster can only be set on HTML5 video');
return;
}
@@ -914,6 +918,7 @@ class Plyr {
// GC for embed
this.embed = null;
+ this.embedId = null;
// If it's a soft destroy, make minimal changes
if (soft) {
diff --git a/src/js/source.js b/src/js/source.js
index d0881675..228d8f3a 100644
--- a/src/js/source.js
+++ b/src/js/source.js
@@ -26,7 +26,7 @@ const source = {
// Sources are not checked for support so be careful
change(input) {
if (!utils.is.object(input) || !('sources' in input) || !input.sources.length) {
- this.warn('Invalid source format');
+ this.console.warn('Invalid source format');
return;
}
diff --git a/src/js/ui.js b/src/js/ui.js
index 1c6290cf..0ecc5621 100644
--- a/src/js/ui.js
+++ b/src/js/ui.js
@@ -31,7 +31,7 @@ const ui = {
// Don't setup interface if no support
if (!this.supported.ui) {
- this.warn(`Basic support only for ${this.type}`);
+ this.console.warn(`Basic support only for ${this.type}`);
// Remove controls
utils.removeElement.call(this, 'controls');
diff --git a/src/js/utils.js b/src/js/utils.js
index 84947e58..a635e021 100644
--- a/src/js/utils.js
+++ b/src/js/utils.js
@@ -418,7 +418,7 @@ const utils = {
return true;
} catch (error) {
// Log it
- this.warn('It looks like there is a problem with your custom controls HTML', error);
+ this.console.warn('It looks like there is a problem with your custom controls HTML', error);
// Restore native video controls
this.toggleNativeControls(true);