diff options
author | Sam Potts <sam@potts.es> | 2018-05-28 10:42:11 +1000 |
---|---|---|
committer | Sam Potts <sam@potts.es> | 2018-05-28 10:42:11 +1000 |
commit | d70a787af19ece0b9eeeba60d947225c73ded291 (patch) | |
tree | 7241df3a362b24a8def20448d3aef5548735dcb4 /src | |
parent | 6f256d09b2b594289b369f8815e484ecdc07a1d9 (diff) | |
parent | 69bb0917ad0e2a1ff2c033a0c4ddd2582de8124b (diff) | |
download | plyr-d70a787af19ece0b9eeeba60d947225c73ded291.tar.lz plyr-d70a787af19ece0b9eeeba60d947225c73ded291.tar.xz plyr-d70a787af19ece0b9eeeba60d947225c73ded291.zip |
Merge branch 'develop'
Diffstat (limited to 'src')
-rw-r--r-- | src/js/defaults.js | 2 | ||||
-rw-r--r-- | src/js/plyr.js | 27 | ||||
-rw-r--r-- | src/js/plyr.polyfilled.js | 2 | ||||
-rw-r--r-- | src/js/storage.js | 2 | ||||
-rw-r--r-- | src/js/utils.js | 2 |
5 files changed, 15 insertions, 20 deletions
diff --git a/src/js/defaults.js b/src/js/defaults.js index 5b1a4dd3..505520a5 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.3.8/plyr.svg', + iconUrl: 'https://cdn.plyr.io/3.3.9/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 4c984fd7..4a064e09 100644 --- a/src/js/plyr.js +++ b/src/js/plyr.js @@ -1,6 +1,6 @@ // ========================================================================== // Plyr -// plyr.js v3.3.8 +// plyr.js v3.3.9 // https://github.com/sampotts/plyr // License: The MIT License (MIT) // ========================================================================== @@ -432,21 +432,16 @@ class Plyr { * @param {number} input - where to seek to in seconds. Defaults to 0 (the start) */ set currentTime(input) { - let targetTime = 0; - - if (utils.is.number(input)) { - targetTime = input; + // Bail if media duration isn't available yet + if (!this.duration) { + return; } - // Normalise targetTime - if (targetTime < 0) { - targetTime = 0; - } else if (targetTime > this.duration) { - targetTime = this.duration; - } + // Validate input + const inputIsValid = utils.is.number(input) && input > 0; // Set - this.media.currentTime = targetTime; + this.media.currentTime = inputIsValid ? Math.min(input, this.duration) : 0; // Logging this.debug.log(`Seeking to ${this.currentTime} seconds`); @@ -494,11 +489,11 @@ class Plyr { // Faux duration set via config const fauxDuration = parseFloat(this.config.duration); - // True duration - const realDuration = this.media ? Number(this.media.duration) : 0; + // Media duration can be NaN before the media has loaded + const duration = (this.media || {}).duration || 0; - // If custom duration is funky, use regular duration - return !Number.isNaN(fauxDuration) ? fauxDuration : realDuration; + // If config duration is funky, use regular duration + return fauxDuration || duration; } /** diff --git a/src/js/plyr.polyfilled.js b/src/js/plyr.polyfilled.js index 9570d753..3f45ec40 100644 --- a/src/js/plyr.polyfilled.js +++ b/src/js/plyr.polyfilled.js @@ -1,6 +1,6 @@ // ========================================================================== // Plyr Polyfilled Build -// plyr.js v3.3.8 +// plyr.js v3.3.9 // https://github.com/sampotts/plyr // License: The MIT License (MIT) // ========================================================================== diff --git a/src/js/storage.js b/src/js/storage.js index 5b914331..e4dc9e1b 100644 --- a/src/js/storage.js +++ b/src/js/storage.js @@ -31,7 +31,7 @@ class Storage { } get(key) { - if (!Storage.supported) { + if (!Storage.supported || !this.enabled) { return null; } diff --git a/src/js/utils.js b/src/js/utils.js index 0c5a28d7..0334879d 100644 --- a/src/js/utils.js +++ b/src/js/utils.js @@ -44,7 +44,7 @@ const utils = { return this.instanceof(input, Event); }, cue(input) { - return this.instanceof(input, TextTrackCue) || this.instanceof(input, VTTCue); + return this.instanceof(input, window.TextTrackCue) || this.instanceof(input, window.VTTCue); }, track(input) { return this.instanceof(input, TextTrack) || (!this.nullOrUndefined(input) && this.string(input.kind)); |