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:
parent
56080df163
commit
801c29d3b9
1 changed files with 4 additions and 5 deletions
|
@ -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);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue