From 004b39e89bc4617ceca75071d790fa7f277d545d Mon Sep 17 00:00:00 2001 From: Niels van Velzen Date: Fri, 8 Dec 2023 21:37:53 +0100 Subject: [PATCH] Close video player on resume with invalid state In some cases the video player may be stopped when the activity is paused. This ends up crashing the app on resume. Check for this kind of invalid state and close the video player to prevent crashing. --- .../ui/playback/CustomPlaybackOverlayFragment.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/src/main/java/org/jellyfin/androidtv/ui/playback/CustomPlaybackOverlayFragment.java b/app/src/main/java/org/jellyfin/androidtv/ui/playback/CustomPlaybackOverlayFragment.java index 59c1c351e8..cc28aec751 100644 --- a/app/src/main/java/org/jellyfin/androidtv/ui/playback/CustomPlaybackOverlayFragment.java +++ b/app/src/main/java/org/jellyfin/androidtv/ui/playback/CustomPlaybackOverlayFragment.java @@ -728,6 +728,17 @@ private void startFadeTimer() { public void onResume() { super.onResume(); + // Close player when resuming without a valid playback contoller + if (!mPlaybackController.hasFragment()) { + if (navigationRepository.getValue().getCanGoBack()) { + navigationRepository.getValue().goBack(); + } else { + navigationRepository.getValue().reset(Destinations.INSTANCE.getHome()); + } + + return; + } + // Hide system bars WindowCompat.setDecorFitsSystemWindows(requireActivity().getWindow(), false); WindowCompat.getInsetsController(requireActivity().getWindow(), requireActivity().getWindow().getDecorView()).hide(WindowInsetsCompat.Type.systemBars());