1
0
mirror of https://github.com/videojs/video.js.git synced 2024-12-04 10:34:51 +02:00

fix: call reset if we are paused or no promises, otherwise wait for play promise to resolve (#5876)

Calling video.load while the video is trying to play (that is between play and playing event) throws an error. Instead, just wait for playback to happen before resetting.

Fixes #5875
This commit is contained in:
Evan Farina 2019-04-11 15:53:31 -04:00 committed by Gary Katsevman
parent ad53b80b8a
commit 5973a62f67
2 changed files with 22 additions and 2 deletions

View File

@ -3151,6 +3151,18 @@ class Player extends Component {
* and calls `reset` on the `tech`.
*/
reset() {
const PromiseClass = this.options_.Promise || window.Promise;
if (this.paused() || !PromiseClass) {
this.doReset_();
} else {
const playPromise = this.play();
silencePromise(playPromise.then(() => this.doReset_()));
}
}
doReset_() {
if (this.tech_) {
this.tech_.clearTracks('text');
}

View File

@ -1391,7 +1391,11 @@ QUnit.test('player#reset loads the Html5 tech and then techCalls reset', functio
techCallMethod = method;
},
resetControlBarUI_() {},
poster() {}
poster() {},
paused() {
return true;
},
doReset_: Player.prototype.doReset_
};
Player.prototype.reset.call(testPlayer);
@ -1419,7 +1423,11 @@ QUnit.test('player#reset loads the first item in the techOrder and then techCall
techCallMethod = method;
},
resetControlBarUI_() {},
poster() {}
poster() {},
paused() {
return true;
},
doReset_: Player.prototype.doReset_
};
Player.prototype.reset.call(testPlayer);