Files
jellyfin-web/src/lib/legacy/htmlMediaElement.js
T
Bill Thornton 4730a30c3d Fix lint errors
2025-02-20 12:51:59 -05:00

28 lines
693 B
JavaScript

/**
* Polyfill for HTMLMediaElement
* - HTMLMediaElement.play
* Return a `Promise`.
*/
(function (HTMLMediaElement) {
'use strict';
const HTMLMediaElementPrototype = HTMLMediaElement.prototype;
const realPlay = HTMLMediaElementPrototype.play;
HTMLMediaElementPrototype.play = function () {
// eslint-disable-next-line sonarjs/no-try-promise
try {
const promise = realPlay.apply(this, arguments);
if (typeof promise?.then === 'function') {
return promise;
}
return Promise.resolve();
} catch (err) {
return Promise.reject(err);
}
};
}(HTMLMediaElement));