From 92e13dafe534eb40b0c8309cca15d943f1095852 Mon Sep 17 00:00:00 2001 From: Avently <7953703+avently@users.noreply.github.com> Date: Thu, 17 Sep 2020 19:01:20 +0300 Subject: [PATCH] Correct exit from fullscreen in case of error or close from notification, --- .../schabi/newpipe/fragments/detail/VideoDetailFragment.java | 5 ++++- app/src/main/java/org/schabi/newpipe/player/MainPlayer.java | 4 ++++ .../newpipe/player/event/CustomBottomSheetBehavior.java | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java index 06bff16e0..9e17ae817 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java @@ -1902,10 +1902,11 @@ public class VideoDetailFragment public void onPlayerError(final ExoPlaybackException error) { if (error.type == ExoPlaybackException.TYPE_SOURCE || error.type == ExoPlaybackException.TYPE_UNEXPECTED) { - hideMainPlayer(); + // Properly exit from fullscreen if (playerService != null && player.isFullscreen()) { player.toggleFullscreen(); } + hideMainPlayer(); } } @@ -2307,6 +2308,7 @@ public class VideoDetailFragment && player.videoPlayerSelected()) { player.toggleFullscreen(); } + setOverlayLook(appBarLayout, behavior, 1); break; case BottomSheetBehavior.STATE_COLLAPSED: moveFocusToMainFragment(true); @@ -2316,6 +2318,7 @@ public class VideoDetailFragment if (player != null) { player.onQueueClosed(); } + setOverlayLook(appBarLayout, behavior, 0); break; case BottomSheetBehavior.STATE_DRAGGING: case BottomSheetBehavior.STATE_SETTLING: diff --git a/app/src/main/java/org/schabi/newpipe/player/MainPlayer.java b/app/src/main/java/org/schabi/newpipe/player/MainPlayer.java index c78ddf036..26d45511e 100644 --- a/app/src/main/java/org/schabi/newpipe/player/MainPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/MainPlayer.java @@ -220,6 +220,10 @@ public final class MainPlayer extends Service { } if (playerImpl != null) { + // Exit from fullscreen when user closes the player via notification + if (playerImpl.isFullscreen()) { + playerImpl.toggleFullscreen(); + } removeViewFromParent(); playerImpl.setRecovery(); diff --git a/app/src/main/java/org/schabi/newpipe/player/event/CustomBottomSheetBehavior.java b/app/src/main/java/org/schabi/newpipe/player/event/CustomBottomSheetBehavior.java index 463331074..47c0624b8 100644 --- a/app/src/main/java/org/schabi/newpipe/player/event/CustomBottomSheetBehavior.java +++ b/app/src/main/java/org/schabi/newpipe/player/event/CustomBottomSheetBehavior.java @@ -39,7 +39,7 @@ public class CustomBottomSheetBehavior extends BottomSheetBehavior } // Found that user still swiping, continue following - if (skippingInterception) { + if (skippingInterception || getState() == BottomSheetBehavior.STATE_SETTLING) { return false; }