1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Merge pull request #3374 from dmitrylyzo/play-resolved

Handle resolved play promise
This commit is contained in:
Bill Thornton 2022-02-13 00:58:21 -05:00 committed by GitHub
commit 26f22c1ab4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -200,17 +200,22 @@ import { Events } from 'jellyfin-apiclient';
const promise = elem.play();
if (promise && promise.then) {
// Chrome now returns a promise
return promise.catch(function (e) {
const errorName = (e.name || '').toLowerCase();
// safari uses aborterror
if (errorName === 'notallowederror' ||
errorName === 'aborterror') {
// swallow this error because the user can still click the play button on the video element
return promise
.then(() => {
onSuccessfulPlay(elem, onErrorFn);
return Promise.resolve();
}
return Promise.reject();
});
})
.catch((e) => {
const errorName = (e.name || '').toLowerCase();
// safari uses aborterror
if (errorName === 'notallowederror' ||
errorName === 'aborterror') {
// swallow this error because the user can still click the play button on the video element
onSuccessfulPlay(elem, onErrorFn);
return Promise.resolve();
}
return Promise.reject();
});
} else {
onSuccessfulPlay(elem, onErrorFn);
return Promise.resolve();