Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix version selection #3677

Merged
merged 2 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1163,11 +1163,11 @@ private void addVersionsMenu(View v) {
PopupMenu menu = new PopupMenu(requireContext(), v, Gravity.END);

for (int i = 0; i < versions.size(); i++) {
MenuItem item = menu.getMenu().add(Menu.NONE, i, Menu.NONE, versions.get(i).getName());
item.setChecked(i == mDetailsOverviewRow.getSelectedMediaSourceIndex());
menu.getMenu().add(Menu.NONE, i, Menu.NONE, versions.get(i).getName());
}

menu.getMenu().setGroupCheckable(0, true, false);
menu.getMenu().setGroupCheckable(0, true, true);
menu.getMenu().getItem(mDetailsOverviewRow.getSelectedMediaSourceIndex()).setChecked(true);
menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.jellyfin.sdk.model.api.MediaSourceInfo;
import org.jellyfin.sdk.model.api.MediaStream;
import org.jellyfin.sdk.model.api.MediaStreamType;
import org.jellyfin.sdk.model.serializer.UUIDSerializerKt;
import org.koin.java.KoinJavaComponent;

import java.time.Instant;
Expand Down Expand Up @@ -179,11 +180,19 @@ public org.jellyfin.sdk.model.api.MediaSourceInfo getCurrentMediaSource() {
if (mCurrentStreamInfo != null && mCurrentStreamInfo.getMediaSource() != null) {
return mCurrentStreamInfo.getMediaSource();
} else {
List<org.jellyfin.sdk.model.api.MediaSourceInfo> mediaSources = getCurrentlyPlayingItem().getMediaSources();
org.jellyfin.sdk.model.api.BaseItemDto item = getCurrentlyPlayingItem();
List<org.jellyfin.sdk.model.api.MediaSourceInfo> mediaSources = item.getMediaSources();

if (mediaSources == null || mediaSources.isEmpty()) {
return null;
} else {
// Prefer the media source with the same id as the item
for (MediaSourceInfo mediaSource : mediaSources) {
if (UUIDSerializerKt.toUUIDOrNull(mediaSource.getId()).equals(item.getId())) {
return mediaSource;
}
}
// Or fallback to the first media source if none match
return mediaSources.get(0);
}
}
Expand Down Expand Up @@ -514,7 +523,7 @@ private VideoOptions buildExoPlayerOptions(@Nullable Integer forcedSubtitleIndex
internalOptions.setEnableDirectStream(false);
internalOptions.setMaxAudioChannels(Utils.downMixAudio(mFragment.getContext()) ? 2 : null); //have to downmix at server
internalOptions.setSubtitleStreamIndex(forcedSubtitleIndex);
internalOptions.setMediaSourceId(forcedSubtitleIndex != null ? getCurrentMediaSource().getId() : null);
internalOptions.setMediaSourceId(getCurrentMediaSource().getId());
DeviceProfile internalProfile = new ExoPlayerProfile(
mFragment.getContext(),
isLiveTv && !userPreferences.getValue().get(UserPreferences.Companion.getLiveTvDirectPlayEnabled()),
Expand Down
Loading