From f7b659f3c14a927dc3aae026058e5453c42c637e Mon Sep 17 00:00:00 2001 From: Courville Software Date: Thu, 9 May 2024 20:27:06 +0200 Subject: [PATCH] PlayUtils: revert to passing subs via http proxy to 3rd party external players See https://github.com/nova-video-player/aos-AVP/issues/1177#issuecomment-2102596086 note that it may cause some encoding interpretation issues (not in french though) --- .../mediacenter/video/utils/PlayUtils.java | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/archos/mediacenter/video/utils/PlayUtils.java b/src/main/java/com/archos/mediacenter/video/utils/PlayUtils.java index b76d477a..e98e1648 100644 --- a/src/main/java/com/archos/mediacenter/video/utils/PlayUtils.java +++ b/src/main/java/com/archos/mediacenter/video/utils/PlayUtils.java @@ -55,6 +55,9 @@ public class PlayUtils implements IndexHelper.Listener { private static final Logger log = LoggerFactory.getLogger(PlayUtils.class); + // pass subs with http proxy to 3rd party players + private static final boolean EXTERNAL_PLAYER_HTTP_SUBS = true; + private IndexHelper mIndexHelper; private VideoDbInfo mVideoDbInfo; private int mResume; @@ -335,12 +338,29 @@ private void onResumeReady(Context context, Video video, final String mimeType, // find first external subtitle file and pass it to vlc while (n < listOfSubtitles.size()) { subPath = listOfSubtitles.get(n); - subFile = new File(subPath); - subUri = FileProvider.getUriForFile(context, "org.courville.nova.provider", subFile); + MxSubFileList.add(subPath); subLanguage = SubtitleManager.getSubLanguageFromSubPath(context, subPath); - MxSubPaths.add(subUri); MxSubNameList.add(subLanguage); - MxSubFileList.add(subPath); + if (EXTERNAL_PLAYER_HTTP_SUBS) { + subUri = Uri.parse(subPath); // these files are in local nova cache not accessible from 3rd party players + try { + StreamOverHttp stream = new StreamOverHttp(subUri, mimeType); + dataUri = stream.getUri(subUri.getLastPathSegment()); + // vlc + if (!subFound) intent.putExtra("subtitles_location", dataUri); + subFound = true; + // mxplayer/justplayer + MxSubPaths.add(dataUri); + log.debug("onResumeReady: adding external subtitle " + dataUri); + } catch (IOException e) { + log.error("onResumeReady: failed to start " + subUri + e); + } + } else { + // TODO FIXME passing file to 3rd party player is not working + subFile = new File(subPath); + subUri = FileProvider.getUriForFile(context, "org.courville.nova.provider", subFile); + MxSubPaths.add(subUri); + } log.debug("onResumeReady: subPath " + subPath + " -> subUri " + subUri + "-> subLanguage " + subLanguage); n++; }