From b3b882040ff91eb9af51aef8f7591ccca8098d21 Mon Sep 17 00:00:00 2001 From: Niels van Velzen Date: Tue, 29 Oct 2024 18:23:42 +0100 Subject: [PATCH] Don't close player with invalid state in onCreate (cherry picked from commit bc4f246b66b7a658118508d2b0c24ff4e6462f29) --- .../playback/CustomPlaybackOverlayFragment.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) 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 9a824b6b54..b365f848a4 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 @@ -176,11 +176,7 @@ public void onCreate(Bundle savedInstanceState) { requireActivity().setVolumeControlStream(AudioManager.STREAM_MUSIC); mItemsToPlay = videoQueueManager.getValue().getCurrentVideoQueue(); - if (mItemsToPlay == null || mItemsToPlay.size() == 0) { - Utils.showToast(requireContext(), getString(R.string.msg_no_playable_items)); - closePlayer(); - return; - } + if (mItemsToPlay == null || mItemsToPlay.isEmpty()) return; int mediaPosition = videoQueueManager.getValue().getCurrentMediaPosition(); @@ -241,6 +237,12 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); + if (mItemsToPlay == null || mItemsToPlay.isEmpty()) { + Utils.showToast(requireContext(), getString(R.string.msg_no_playable_items)); + closePlayer(); + return; + } + if (playbackControllerContainer.getValue().getPlaybackController() != null) { playbackControllerContainer.getValue().getPlaybackController().init(new VideoManager((requireActivity()), view, helper), this); } @@ -258,7 +260,7 @@ public void onDestroyView() { @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); - if (mItemsToPlay == null || mItemsToPlay.size() == 0) return; + if (mItemsToPlay == null || mItemsToPlay.isEmpty()) return; prepareOverlayFragment(); @@ -702,6 +704,7 @@ public void onResume() { @Override public void onPause() { super.onPause(); + if (mItemsToPlay == null || mItemsToPlay.isEmpty()) return; setPlayPauseActionState(0);