aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSam Potts <sam@potts.es>2018-03-18 01:37:24 +1100
committerSam Potts <sam@potts.es>2018-03-18 01:37:24 +1100
commit43e6dcd41dac1ea3615f1ee92a2ec665e8c7edbc (patch)
treee290a6e508452f5cd466606a9937de7412c71643 /src
parentb06c8ae43fa9cce4d395dcef8a55067cb9198e8f (diff)
downloadplyr-43e6dcd41dac1ea3615f1ee92a2ec665e8c7edbc.tar.lz
plyr-43e6dcd41dac1ea3615f1ee92a2ec665e8c7edbc.tar.xz
plyr-43e6dcd41dac1ea3615f1ee92a2ec665e8c7edbc.zip
Fix for local storage issue
Diffstat (limited to 'src')
-rw-r--r--src/js/defaults.js2
-rw-r--r--src/js/plyr.js8
-rw-r--r--src/js/plyr.polyfilled.js2
-rw-r--r--src/js/storage.js21
4 files changed, 21 insertions, 12 deletions
diff --git a/src/js/defaults.js b/src/js/defaults.js
index 21132620..468b1888 100644
--- a/src/js/defaults.js
+++ b/src/js/defaults.js
@@ -56,7 +56,7 @@ const defaults = {
// Sprite (for icons)
loadSprite: true,
iconPrefix: 'plyr',
- iconUrl: 'https://cdn.plyr.io/3.0.0/plyr.svg',
+ iconUrl: 'https://cdn.plyr.io/3.0.1/plyr.svg',
// Blank video (used to prevent errors on source change)
blankVideo: 'https://cdn.plyr.io/static/blank.mp4',
diff --git a/src/js/plyr.js b/src/js/plyr.js
index e835b8c7..37dd14d3 100644
--- a/src/js/plyr.js
+++ b/src/js/plyr.js
@@ -1,6 +1,6 @@
// ==========================================================================
// Plyr
-// plyr.js v3.0.0
+// plyr.js v3.0.1
// https://github.com/sampotts/plyr
// License: The MIT License (MIT)
// ==========================================================================
@@ -315,6 +315,10 @@ class Plyr {
* Play the media, or play the advertisement (if they are not blocked)
*/
play() {
+ if (!utils.is.function(this.media.play)) {
+ return null;
+ }
+
// If ads are enabled, wait for them first
if (this.ads.enabled && !this.ads.initialized) {
return this.ads.managerPromise.then(() => this.ads.play()).catch(() => this.media.play());
@@ -328,7 +332,7 @@ class Plyr {
* Pause the media
*/
pause() {
- if (!this.playing) {
+ if (!this.playing || !utils.is.function(this.media.pause)) {
return;
}
diff --git a/src/js/plyr.polyfilled.js b/src/js/plyr.polyfilled.js
index 9ff59397..c2f35b50 100644
--- a/src/js/plyr.polyfilled.js
+++ b/src/js/plyr.polyfilled.js
@@ -1,6 +1,6 @@
// ==========================================================================
// Plyr Polyfilled Build
-// plyr.js v3.0.0
+// plyr.js v3.0.1
// https://github.com/sampotts/plyr
// License: The MIT License (MIT)
// ==========================================================================
diff --git a/src/js/storage.js b/src/js/storage.js
index 5f663ab5..5b914331 100644
--- a/src/js/storage.js
+++ b/src/js/storage.js
@@ -12,17 +12,18 @@ class Storage {
// Check for actual support (see if we can use it)
static get supported() {
- if (!('localStorage' in window)) {
- return false;
- }
+ try {
+ if (!('localStorage' in window)) {
+ return false;
+ }
- const test = '___test';
+ const test = '___test';
- // Try to use it (it might be disabled, e.g. user is in private mode)
- // see: https://github.com/sampotts/plyr/issues/131
- try {
+ // Try to use it (it might be disabled, e.g. user is in private mode)
+ // see: https://github.com/sampotts/plyr/issues/131
window.localStorage.setItem(test, test);
window.localStorage.removeItem(test);
+
return true;
} catch (e) {
return false;
@@ -30,9 +31,13 @@ class Storage {
}
get(key) {
+ if (!Storage.supported) {
+ return null;
+ }
+
const store = window.localStorage.getItem(this.key);
- if (!Storage.supported || utils.is.empty(store)) {
+ if (utils.is.empty(store)) {
return null;
}