Merge pull request #978 from friday/ie-issues
Fix InvalidStateError and IE11 issues
This commit is contained in:
commit
14b6309aef
@ -432,21 +432,16 @@ class Plyr {
|
|||||||
* @param {number} input - where to seek to in seconds. Defaults to 0 (the start)
|
* @param {number} input - where to seek to in seconds. Defaults to 0 (the start)
|
||||||
*/
|
*/
|
||||||
set currentTime(input) {
|
set currentTime(input) {
|
||||||
let targetTime = 0;
|
// Bail if media duration isn't available yet
|
||||||
|
if (!this.duration) {
|
||||||
if (utils.is.number(input)) {
|
return;
|
||||||
targetTime = input;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Normalise targetTime
|
// Validate input
|
||||||
if (targetTime < 0) {
|
const inputIsValid = utils.is.number(input) && input > 0;
|
||||||
targetTime = 0;
|
|
||||||
} else if (targetTime > this.duration) {
|
|
||||||
targetTime = this.duration;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set
|
// Set
|
||||||
this.media.currentTime = targetTime;
|
this.media.currentTime = inputIsValid ? Math.min(input, this.duration) : 0;
|
||||||
|
|
||||||
// Logging
|
// Logging
|
||||||
this.debug.log(`Seeking to ${this.currentTime} seconds`);
|
this.debug.log(`Seeking to ${this.currentTime} seconds`);
|
||||||
@ -494,11 +489,11 @@ class Plyr {
|
|||||||
// Faux duration set via config
|
// Faux duration set via config
|
||||||
const fauxDuration = parseFloat(this.config.duration);
|
const fauxDuration = parseFloat(this.config.duration);
|
||||||
|
|
||||||
// True duration
|
// Media duration can be NaN before the media has loaded
|
||||||
const realDuration = this.media ? Number(this.media.duration) : 0;
|
const duration = (this.media || {}).duration || 0;
|
||||||
|
|
||||||
// If custom duration is funky, use regular duration
|
// If config duration is funky, use regular duration
|
||||||
return !Number.isNaN(fauxDuration) ? fauxDuration : realDuration;
|
return fauxDuration || duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user