1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00
jellyfin-web/src/legacy/htmlMediaElement.js
Dmitry Lyzo 270430f6a1 Polyfill HTMLMediaElement.play
Return a `Promise` to match the new standard.
2022-02-26 14:01:08 +03:00

26 lines
627 B
JavaScript

/**
* Polyfill for HTMLMediaElement
* - HTMLMediaElement.play
* Return a `Promise`.
*/
(function (HTMLMediaElement) {
'use strict';
const HTMLMediaElement_proto = HTMLMediaElement.prototype;
const real_play = HTMLMediaElement_proto.play;
HTMLMediaElement_proto.play = function () {
try {
const promise = real_play.apply(this, arguments);
if (typeof promise?.then === 'function') {
return promise;
}
return Promise.resolve();
} catch (err) {
return Promise.reject(err);
}
};
}(HTMLMediaElement));