From 25db7d52867fb11d6e1151f5f838fd509ea779d5 Mon Sep 17 00:00:00 2001 From: Niels van Velzen Date: Tue, 17 Dec 2024 22:32:20 +0100 Subject: [PATCH] Fix external subtitles not added to external player --- .../androidtv/data/compat/StreamInfo.java | 25 +++++++++---------- .../ui/playback/ExternalPlayerActivity.java | 4 +-- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/org/jellyfin/androidtv/data/compat/StreamInfo.java b/app/src/main/java/org/jellyfin/androidtv/data/compat/StreamInfo.java index 4c7a52872e..98af59b723 100644 --- a/app/src/main/java/org/jellyfin/androidtv/data/compat/StreamInfo.java +++ b/app/src/main/java/org/jellyfin/androidtv/data/compat/StreamInfo.java @@ -5,12 +5,14 @@ import org.jellyfin.apiclient.model.dlna.SubtitleProfile; import org.jellyfin.apiclient.model.dlna.TranscodeSeekInfo; import org.jellyfin.apiclient.model.session.PlayMethod; +import org.jellyfin.sdk.api.client.ApiClient; 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.api.SubtitleDeliveryMethod; import java.util.ArrayList; +import java.util.HashMap; import java.util.UUID; public class StreamInfo { @@ -120,28 +122,22 @@ public final String getMediaSourceId() { return getMediaSource() == null ? null : getMediaSource().getId(); } - public final ArrayList getSubtitleProfiles(boolean includeSelectedTrackOnly, String baseUrl, String accessToken) { - return getSubtitleProfiles(includeSelectedTrackOnly, false, baseUrl, accessToken); - } - - public final ArrayList getSubtitleProfiles(boolean includeSelectedTrackOnly, boolean enableAllProfiles, String baseUrl, String accessToken) { + public final ArrayList getSubtitleProfiles(ApiClient api) { ArrayList list = new ArrayList(); - if (!includeSelectedTrackOnly) { - if (getMediaSource() == null) return list; + if (getMediaSource() == null) return list; - for (org.jellyfin.sdk.model.api.MediaStream stream : getMediaSource().getMediaStreams()) { - if (stream.getType() == org.jellyfin.sdk.model.api.MediaStreamType.SUBTITLE) { - SubtitleStreamInfo info = getSubtitleStreamInfo(stream, getDeviceProfile().getSubtitleProfiles()); - list.add(info); - } + for (org.jellyfin.sdk.model.api.MediaStream stream : getMediaSource().getMediaStreams()) { + if (stream.getType() == org.jellyfin.sdk.model.api.MediaStreamType.SUBTITLE) { + SubtitleStreamInfo info = getSubtitleStreamInfo(api, stream, getDeviceProfile().getSubtitleProfiles()); + list.add(info); } } return list; } - private SubtitleStreamInfo getSubtitleStreamInfo(org.jellyfin.sdk.model.api.MediaStream stream, SubtitleProfile[] subtitleProfiles) { + private SubtitleStreamInfo getSubtitleStreamInfo(ApiClient api, org.jellyfin.sdk.model.api.MediaStream stream, SubtitleProfile[] subtitleProfiles) { SubtitleProfile subtitleProfile = StreamBuilder.getSubtitleProfile(stream, subtitleProfiles, getPlayMethod()); SubtitleStreamInfo info = new SubtitleStreamInfo(); String tempVar2 = stream.getLanguage(); @@ -150,6 +146,9 @@ private SubtitleStreamInfo getSubtitleStreamInfo(org.jellyfin.sdk.model.api.Medi info.setIndex(stream.getIndex()); info.setDeliveryMethod(subtitleProfile.getMethod()); info.setDisplayTitle(stream.getDisplayTitle()); + if (stream.getDeliveryUrl() != null) { + info.setUrl(api.createUrl(stream.getDeliveryUrl(), new HashMap<>(), new HashMap<>(), true)); + } return info; } diff --git a/app/src/main/java/org/jellyfin/androidtv/ui/playback/ExternalPlayerActivity.java b/app/src/main/java/org/jellyfin/androidtv/ui/playback/ExternalPlayerActivity.java index 7d0b0c1404..5c9a460015 100644 --- a/app/src/main/java/org/jellyfin/androidtv/ui/playback/ExternalPlayerActivity.java +++ b/app/src/main/java/org/jellyfin/androidtv/ui/playback/ExternalPlayerActivity.java @@ -392,9 +392,7 @@ protected void startExternalActivity(String path, String container) { * @param playerIntent Put player API params of sub urls. */ private void adaptExternalSubtitles(StreamInfo mediaStreamInfo, Intent playerIntent) { - - List externalSubs = mediaStreamInfo.getSubtitleProfiles(false, - apiClient.getValue().getBaseUrl(), apiClient.getValue().getAccessToken()).stream() + List externalSubs = mediaStreamInfo.getSubtitleProfiles(apiClient.getValue()).stream() .filter(stream -> stream.getDeliveryMethod() == SubtitleDeliveryMethod.External && stream.getUrl() != null) .collect(Collectors.toList());