diff --git a/src/js/tech/html5.js b/src/js/tech/html5.js index bc9ae8dfd9..f875e5548b 100644 --- a/src/js/tech/html5.js +++ b/src/js/tech/html5.js @@ -437,7 +437,13 @@ class Html5 extends Tech { * @method play */ play() { - this.el_.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) => {}); + } } /** diff --git a/test/unit/tech/html5.test.js b/test/unit/tech/html5.test.js index b83d843fbb..aeb30b7b61 100644 --- a/test/unit/tech/html5.test.js +++ b/test/unit/tech/html5.test.js @@ -517,3 +517,20 @@ QUnit.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; +});