mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Merge pull request #5573 from thornbill/fix-playback-access
Fix playback interceptor rejecting
This commit is contained in:
commit
add01e332b
2 changed files with 41 additions and 26 deletions
|
@ -2284,32 +2284,17 @@ class PlaybackManager {
|
||||||
// TODO: This should be the media type requested, not the original media type
|
// TODO: This should be the media type requested, not the original media type
|
||||||
const mediaType = item.MediaType;
|
const mediaType = item.MediaType;
|
||||||
|
|
||||||
return runInterceptors(item, playOptions)
|
|
||||||
.then(() => {
|
|
||||||
if (playOptions.fullscreen) {
|
if (playOptions.fullscreen) {
|
||||||
loading.show();
|
loading.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isServerItem(item) || itemHelper.isLocalItem(item)) {
|
return runInterceptors(item, playOptions)
|
||||||
return Promise.reject('skip bitrate detection');
|
|
||||||
}
|
|
||||||
|
|
||||||
return apiClient.getEndpointInfo().then((endpointInfo) => {
|
|
||||||
if ((mediaType === 'Video' || mediaType === 'Audio') && appSettings.enableAutomaticBitrateDetection(endpointInfo.IsInNetwork, mediaType)) {
|
|
||||||
return apiClient.detectBitrate().then((bitrate) => {
|
|
||||||
appSettings.maxStreamingBitrate(endpointInfo.IsInNetwork, mediaType, bitrate);
|
|
||||||
return bitrate;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return Promise.reject('skip bitrate detection');
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch(() => getSavedMaxStreamingBitrate(apiClient, mediaType))
|
|
||||||
.then((bitrate) => {
|
|
||||||
return playAfterBitrateDetect(bitrate, item, playOptions, onPlaybackStartedFn, prevSource);
|
|
||||||
})
|
|
||||||
.catch(onInterceptorRejection)
|
.catch(onInterceptorRejection)
|
||||||
|
.then(() => detectBitrate(apiClient, item, mediaType))
|
||||||
|
.then((bitrate) => {
|
||||||
|
return playAfterBitrateDetect(bitrate, item, playOptions, onPlaybackStartedFn, prevSource)
|
||||||
|
.catch(onPlaybackRejection);
|
||||||
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
if (playOptions.fullscreen) {
|
if (playOptions.fullscreen) {
|
||||||
loading.hide();
|
loading.hide();
|
||||||
|
@ -2328,7 +2313,13 @@ class PlaybackManager {
|
||||||
Events.trigger(self, 'playbackcancelled');
|
Events.trigger(self, 'playbackcancelled');
|
||||||
}
|
}
|
||||||
|
|
||||||
function onInterceptorRejection(e) {
|
function onInterceptorRejection() {
|
||||||
|
cancelPlayback();
|
||||||
|
|
||||||
|
return Promise.reject();
|
||||||
|
}
|
||||||
|
|
||||||
|
function onPlaybackRejection(e) {
|
||||||
cancelPlayback();
|
cancelPlayback();
|
||||||
|
|
||||||
let displayErrorCode = 'ErrorDefault';
|
let displayErrorCode = 'ErrorDefault';
|
||||||
|
@ -2502,6 +2493,29 @@ class PlaybackManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function detectBitrate(apiClient, item, mediaType) {
|
||||||
|
// FIXME: This is gnarly, but don't want to change too much here in a bugfix
|
||||||
|
return Promise.resolve()
|
||||||
|
.then(() => {
|
||||||
|
if (!isServerItem(item) || itemHelper.isLocalItem(item)) {
|
||||||
|
return Promise.reject('skip bitrate detection');
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiClient.getEndpointInfo()
|
||||||
|
.then((endpointInfo) => {
|
||||||
|
if ((mediaType === 'Video' || mediaType === 'Audio') && appSettings.enableAutomaticBitrateDetection(endpointInfo.IsInNetwork, mediaType)) {
|
||||||
|
return apiClient.detectBitrate().then((bitrate) => {
|
||||||
|
appSettings.maxStreamingBitrate(endpointInfo.IsInNetwork, mediaType, bitrate);
|
||||||
|
return bitrate;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return Promise.reject('skip bitrate detection');
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(() => getSavedMaxStreamingBitrate(apiClient, mediaType));
|
||||||
|
}
|
||||||
|
|
||||||
function playAfterBitrateDetect(maxBitrate, item, playOptions, onPlaybackStartedFn, prevSource) {
|
function playAfterBitrateDetect(maxBitrate, item, playOptions, onPlaybackStartedFn, prevSource) {
|
||||||
const startPosition = playOptions.startPositionTicks;
|
const startPosition = playOptions.startPositionTicks;
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,8 @@ class PlayAccessValidation {
|
||||||
return Promise.reject();
|
return Promise.reject();
|
||||||
}
|
}
|
||||||
|
|
||||||
return showErrorMessage().finally(Promise.reject);
|
return showErrorMessage()
|
||||||
|
.finally(() => Promise.reject());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue