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

Add playback error messages and fix error propogation

This commit is contained in:
Bill Thornton 2024-03-10 01:17:53 -05:00
parent 15d30ffaeb
commit 5a5a70dad0
4 changed files with 26 additions and 14 deletions

View file

@ -190,7 +190,7 @@ export function playWithPromise(elem, onErrorFn) {
// swallow this error because the user can still click the play button on the video element
return Promise.resolve();
}
return Promise.reject();
return Promise.reject(e);
})
.then(() => {
onSuccessfulPlay(elem, onErrorFn);

View file

@ -20,6 +20,7 @@ import { getItems } from '../../utils/jellyfin-apiclient/getItems.ts';
import { getItemBackdropImageUrl } from '../../utils/jellyfin-apiclient/backdropImage';
import { MediaError } from 'types/mediaError';
import { getMediaError } from 'utils/mediaError';
const UNLIMITED_ITEMS = -1;
@ -1781,7 +1782,7 @@ class PlaybackManager {
playerData.isChangingStream = false;
onPlaybackError.call(player, e, {
type: MediaError.PLAYER_ERROR,
type: getMediaError(e),
streamInfo: streamInfo
});
});
@ -2564,7 +2565,7 @@ class PlaybackManager {
onPlaybackStarted(player, playOptions, streamInfo, mediaSource);
setTimeout(function () {
onPlaybackError.call(player, err, {
type: MediaError.PLAYER_ERROR,
type: getMediaError(err),
streamInfo
});
}, 100);
@ -3232,7 +3233,7 @@ class PlaybackManager {
const errorType = error.type;
console.warn('[playbackmanager] onPlaybackError:', error);
console.warn('[playbackmanager] onPlaybackError:', e, error);
const streamInfo = error.streamInfo || getPlayerData(player).streamInfo;

View file

@ -1228,16 +1228,16 @@
"Play": "Play",
"PlayAllFromHere": "Play all from here",
"PlaybackData": "Playback Info",
"PlaybackError.ASS_RENDER_ERROR": "",
"PlaybackError.FATAL_HLS_ERROR": "",
"PlaybackError.MEDIA_DECODE_ERROR": "",
"PlaybackError.MEDIA_NOT_SUPPORTED": "",
"PlaybackError.NETWORK_ERROR": "",
"PlaybackError.NO_MEDIA_ERROR": "",
"PlaybackError.PLAYER_ERROR": "",
"PlaybackError.SERVER_ERROR": "",
"PlaybackError.NotAllowed": "",
"PlaybackError.RateLimitExceeded": "",
"PlaybackError.ASS_RENDER_ERROR": "An error was encountered in the ASS/SSA subtitle renderer.",
"PlaybackError.FATAL_HLS_ERROR": "A fatal error was encountered in the HLS stream.",
"PlaybackError.MEDIA_DECODE_ERROR": "Playback failed due to an error decoding the media.",
"PlaybackError.MEDIA_NOT_SUPPORTED": "Playback failed because the media is not supported by this client.",
"PlaybackError.NETWORK_ERROR": "Playback failed due to a network error.",
"PlaybackError.NO_MEDIA_ERROR": "Unable to find a valid media source to play.",
"PlaybackError.PLAYER_ERROR": "Playback failed due to a fatal player error.",
"PlaybackError.SERVER_ERROR": "Playback failed due to a server error.",
"PlaybackError.NotAllowed": "Playback of this media is not allowed.",
"PlaybackError.RateLimitExceeded": "This media cannot be played at this time due to rate limits.",
"PlaybackErrorNoCompatibleStream": "This client isn't compatible with the media and the server isn't sending a compatible media format.",
"PlaybackErrorPlaceHolder": "This is a placeholder for physical media that Jellyfin cannot play. Please insert the disc to play.",
"PlaybackRate": "Playback Speed",

11
src/utils/mediaError.ts Normal file
View file

@ -0,0 +1,11 @@
import { MediaError } from 'types/mediaError';
/**
* Maps a DOMException name to an equivalent {@link MediaError}.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMException#error_names
*/
export function getMediaError(e?: DOMException): MediaError {
if (e?.name === 'NotSupportedError') return MediaError.MEDIA_NOT_SUPPORTED;
return MediaError.PLAYER_ERROR;
}