Skip to content

Commit

Permalink
@mister-ben silenced chrome's play() request was interrupted by pause…
Browse files Browse the repository at this point in the history
…() error. closes #3518
  • Loading branch information
mister-ben authored and gkatsev committed Aug 15, 2016
1 parent bf2eabf commit fa1c643
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ CHANGELOG
* @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))
* @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))

--------------------

Expand Down
10 changes: 9 additions & 1 deletion src/js/tech/html5.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,15 @@ class Html5 extends Tech {
*
* @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
Expand Down
17 changes: 17 additions & 0 deletions test/unit/tech/html5.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -442,3 +442,20 @@ test('Html5#reset calls Html5.resetMediaElement when called', function() {

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;
});

0 comments on commit fa1c643

Please sign in to comment.