From eba09511764e7010c69f25ed74b27cc827fdde36 Mon Sep 17 00:00:00 2001 From: Austin Huang Date: Tue, 13 Jul 2021 21:46:13 -0400 Subject: [PATCH] close #1395 app will pause the video when navigating away and is independent of the play-in-background preference --- .../fragments/PostViewV2Fragment.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/app/src/main/java/awais/instagrabber/fragments/PostViewV2Fragment.java b/app/src/main/java/awais/instagrabber/fragments/PostViewV2Fragment.java index 7964e683..cd9199db 100644 --- a/app/src/main/java/awais/instagrabber/fragments/PostViewV2Fragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/PostViewV2Fragment.java @@ -274,6 +274,25 @@ public class PostViewV2Fragment extends Fragment implements EditTextDialogFragme } } + @Override + public void onPrimaryNavigationFragmentChanged(final boolean isPrimaryNavigationFragment) { + if (!isPrimaryNavigationFragment) { + final Media media = viewModel.getMedia(); + switch (media.getType()) { + case MEDIA_TYPE_VIDEO: + if (videoPlayerViewHelper != null) { + videoPlayerViewHelper.pause(); + } + return; + case MEDIA_TYPE_SLIDER: + if (sliderItemsAdapter != null) { + pauseSliderPlayer(); + } + default: + } + } + } + private void init() { final Bundle arguments = getArguments(); if (arguments == null) {