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 Dec 21, 2024
1 parent 052eb6d commit b984b91
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 @@ -2580,16 +2580,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 @@ -2622,13 +2617,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) => {
Expand Down

0 comments on commit b984b91

Please sign in to comment.