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

@mister-ben silenced chrome's play() request was interrupted by pause() error. closes #3518

This commit is contained in:
mister-ben 2016-08-15 17:49:52 -04:00 committed by Gary Katsevman
parent bf2eabf82d
commit fa1c6430f4
3 changed files with 27 additions and 1 deletions

View File

@ -5,6 +5,7 @@ CHANGELOG
* @vdeshpande fixed control text for fullscreen button ([view](https://github.com/videojs/video.js/pull/3485)) * @vdeshpande fixed control text for fullscreen button ([view](https://github.com/videojs/video.js/pull/3485))
* @mister-ben fixed android treating swipe as a tap ([view](https://github.com/videojs/video.js/pull/3514)) * @mister-ben fixed android treating swipe as a tap ([view](https://github.com/videojs/video.js/pull/3514))
* @mboles updated duration() method documentation ([view](https://github.com/videojs/video.js/pull/3515)) * @mboles updated duration() method documentation ([view](https://github.com/videojs/video.js/pull/3515))
* @mister-ben silenced chrome's play() request was interrupted by pause() error ([view](https://github.com/videojs/video.js/pull/3518))
-------------------- --------------------

View File

@ -423,7 +423,15 @@ class Html5 extends Tech {
* *
* @method play * @method play
*/ */
play() { this.el_.play(); } play() {
const playPromise = this.el_.play();
// Catch/silence error when a pause interrupts a play request
// on browsers which return a promise
if (playPromise !== undefined && typeof playPromise.then === 'function') {
playPromise.then(null, (e) => {});
}
}
/** /**
* Pause for html5 tech * Pause for html5 tech

View File

@ -442,3 +442,20 @@ test('Html5#reset calls Html5.resetMediaElement when called', function() {
Html5.resetMediaElement = oldResetMedia; Html5.resetMediaElement = oldResetMedia;
}); });
QUnit.test('Exception in play promise should be caught', function() {
const oldEl = tech.el_;
tech.el_ = {
play: () => {
return new Promise(function(resolve, reject) {
reject(new DOMException());
});
}
};
tech.play();
QUnit.ok(true, 'error was caught');
tech.el_ = oldEl;
});