From a0f0a0d765f8745afa5698318fca9fb0ac15b41a Mon Sep 17 00:00:00 2001 From: Kevin Jilissen Date: Tue, 17 Dec 2024 22:03:03 +0100 Subject: [PATCH] Remove invalid item id usage as media source id Looking at the change history, an ` || item.Id` was introduced in 4c31742cc50c19702f2c1610c2bcfc0d6c4d210b to query for the item, but this workaround is only needed for track selection in some cases and breaks playback in others. Only apply it when a track is selected. --- src/components/playback/playbackmanager.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/components/playback/playbackmanager.js b/src/components/playback/playbackmanager.js index 86acdff7a698..d17d34a62d19 100644 --- a/src/components/playback/playbackmanager.js +++ b/src/components/playback/playbackmanager.js @@ -2603,16 +2603,11 @@ export class PlaybackManager { }); } - const apiClient = ServerConnections.getApiClient(item.ServerId); - let mediaSourceId; + let mediaSourceId = playOptions.mediaSourceId; + const apiClient = ServerConnections.getApiClient(item.ServerId); const isLiveTv = [BaseItemKind.TvChannel, BaseItemKind.LiveTvChannel].includes(item.Type); - - if (!isLiveTv) { - mediaSourceId = playOptions.mediaSourceId || item.Id; - } - - const getMediaStreams = isLiveTv ? Promise.resolve([]) : apiClient.getItem(apiClient.getCurrentUserId(), mediaSourceId) + const getMediaStreams = isLiveTv ? Promise.resolve([]) : apiClient.getItem(apiClient.getCurrentUserId(), mediaSourceId || item.Id) .then(fullItem => { return fullItem.MediaStreams; }); @@ -2645,13 +2640,20 @@ export class PlaybackManager { playOptions.items = null; const trackOptions = {}; + let needsTrackWorkaround = false; autoSetNextTracks(prevSource, mediaStreams, trackOptions, user.Configuration.RememberAudioSelections, user.Configuration.RememberSubtitleSelections); if (trackOptions.DefaultAudioStreamIndex != null) { options.audioStreamIndex = trackOptions.DefaultAudioStreamIndex; + needsTrackWorkaround = true; } if (trackOptions.DefaultSubtitleStreamIndex != null) { options.subtitleStreamIndex = trackOptions.DefaultSubtitleStreamIndex; + needsTrackWorkaround = true; + } + + if (needsTrackWorkaround) { + mediaSourceId ||= item.Id; } return getPlaybackMediaSource(player, apiClient, deviceProfile, item, mediaSourceId, options).then(async (mediaSource) => {