Skip to content

Commit

Permalink
Remove invalid item id usage as media source id
Browse files Browse the repository at this point in the history
Looking at the change history, an ` || item.Id` was introduced in
4c31742 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.
  • Loading branch information
Kevinjil committed Jan 28, 2025
1 parent e8e4ff0 commit 8f64bee
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/components/playback/playbackmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -2602,16 +2602,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;
});
Expand Down Expand Up @@ -2644,13 +2639,20 @@ export class PlaybackManager {
playOptions.items = null;

const trackOptions = {};
let isIdFallbackNeeded = false;

autoSetNextTracks(prevSource, mediaStreams, trackOptions, user.Configuration.RememberAudioSelections, user.Configuration.RememberSubtitleSelections);
if (trackOptions.DefaultAudioStreamIndex != null) {
options.audioStreamIndex = trackOptions.DefaultAudioStreamIndex;
isIdFallbackNeeded = true;
}
if (trackOptions.DefaultSubtitleStreamIndex != null) {
options.subtitleStreamIndex = trackOptions.DefaultSubtitleStreamIndex;
isIdFallbackNeeded = true;
}

if (isIdFallbackNeeded) {
mediaSourceId ||= item.Id;
}

return getPlaybackMediaSource(player, apiClient, deviceProfile, item, mediaSourceId, options).then(async (mediaSource) => {
Expand Down

0 comments on commit 8f64bee

Please sign in to comment.