From 9b322cc92211b41638864b68ff7cfca7e5f8751a Mon Sep 17 00:00:00 2001 From: Thomas Date: Sat, 9 Jan 2021 10:42:37 +0100 Subject: [PATCH] Fix issue #165 --- .../fedilab/fedilabtube/PeertubeActivity.java | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java b/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java index 6cffd83..f105b1b 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java +++ b/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java @@ -220,6 +220,8 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd private boolean willPlayFromIntent; private String chromeCastVideoURL; private app.fedilab.fedilabtube.client.mastodon.Status status; + Uri captionURI; + String captionLang; public static void hideKeyboard(Activity activity) { if (activity != null && activity.getWindow() != null) { @@ -664,7 +666,8 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd secInt = Integer.parseInt(sec.replace("s", "")); totalSeconds += secInt; } - + captionURI = null; + captionLang = null; if (instance != null && uuid != null) { peertubeInstance = instance.replace("https://", "").replace("http://", ""); sepiaSearch = true; // Sepia search flag is used because, at this time we don't know if the video is federated. @@ -1018,7 +1021,8 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd secInt = Integer.parseInt(sec.replace("strue", "")); totalSeconds += secInt; } - + captionURI = null; + captionLang = null; if (instance != null && uuid != null) { peertubeInstance = instance.replace("https://", "").replace("http://", ""); sepiaSearch = true; // Sepia search flag is used because, at this time we don't know if the video is federated. @@ -1941,11 +1945,12 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd binding.mediaVideo.player(player); binding.doubleTapPlayerView.setPlayer(player); binding.loader.setVisibility(View.GONE); + startStream( peertube, null, res, - true, position, null, null, false); + true, position, captionURI, captionLang, false); } break; case SPEED: @@ -1957,7 +1962,6 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd } break; case CAPTION: - Uri uri = null; Caption captionToUse = null; for (Caption caption : captions) { if (caption.getLanguage().getId().compareTo(item.getStrId()) == 0) { @@ -1967,10 +1971,12 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd } if (captionToUse != null) { if (!sepiaSearch) { - uri = Uri.parse("https://" + HelperInstance.getLiveInstance(PeertubeActivity.this) + captionToUse.getCaptionPath()); + captionURI = Uri.parse("https://" + HelperInstance.getLiveInstance(PeertubeActivity.this) + captionToUse.getCaptionPath()); } else { - uri = Uri.parse("https://" + peertubeInstance + captionToUse.getCaptionPath()); + captionURI = Uri.parse("https://" + peertubeInstance + captionToUse.getCaptionPath()); } + } else { + captionURI = null; } currentCaption = item.getStrId(); long newPosition = player.getCurrentPosition(); @@ -1982,14 +1988,15 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd player = new SimpleExoPlayer.Builder(PeertubeActivity.this).setTrackSelector(trackSelector).build(); binding.mediaVideo.player(player); binding.doubleTapPlayerView.setPlayer(player); + captionLang = item.getStrId(); startStream( peertube, null, null, true, newPosition, - uri, - item.getStrId(), + captionURI, + captionLang, false ); break;