diff --git a/src/components/playback/playbackmanager.js b/src/components/playback/playbackmanager.js index eb9d40a83b..d118b1aaf6 100644 --- a/src/components/playback/playbackmanager.js +++ b/src/components/playback/playbackmanager.js @@ -2256,35 +2256,37 @@ class PlaybackManager { playOptions.isFirstItem = true; } - return runInterceptors(item, playOptions).then(function () { - if (playOptions.fullscreen) { - loading.show(); - } + const apiClient = ServerConnections.getApiClient(item.ServerId); - // TODO: This should be the media type requested, not the original media type - const mediaType = item.MediaType; + // TODO: This should be the media type requested, not the original media type + const mediaType = item.MediaType; - const onBitrateDetectionFailure = function () { - return playAfterBitrateDetect(getSavedMaxStreamingBitrate(ServerConnections.getApiClient(item.ServerId), mediaType), item, playOptions, onPlaybackStartedFn, prevSource); - }; - - if (!isServerItem(item) || itemHelper.isLocalItem(item)) { - return onBitrateDetectionFailure(); - } - - const apiClient = ServerConnections.getApiClient(item.ServerId); - apiClient.getEndpointInfo().then(function (endpointInfo) { - if ((mediaType === 'Video' || mediaType === 'Audio') && appSettings.enableAutomaticBitrateDetection(endpointInfo.IsInNetwork, mediaType)) { - return apiClient.detectBitrate().then(function (bitrate) { - appSettings.maxStreamingBitrate(endpointInfo.IsInNetwork, mediaType, bitrate); - - return playAfterBitrateDetect(bitrate, item, playOptions, onPlaybackStartedFn, prevSource); - }, onBitrateDetectionFailure); - } else { - onBitrateDetectionFailure(); + return runInterceptors(item, playOptions) + .then(() => { + if (playOptions.fullscreen) { + loading.show(); } - }, onBitrateDetectionFailure); - }, onInterceptorRejection); + + 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)) + .then((bitrate) => { + return playAfterBitrateDetect(bitrate, item, playOptions, onPlaybackStartedFn, prevSource); + }) + .catch(onInterceptorRejection); } function cancelPlayback() {