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

refactor: Unify handling of play success

This commit is contained in:
Dmitry Lyzo 2022-02-26 13:03:41 +03:00
parent 56080df163
commit 801c29d3b9

View file

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