Skip to content

Commit

Permalink
Don't close player with invalid state in onCreate
Browse files Browse the repository at this point in the history
(cherry picked from commit bc4f246)
  • Loading branch information
nielsvanvelzen committed Nov 2, 2024
1 parent 255215e commit b3b8820
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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);
}
Expand All @@ -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();

Expand Down Expand Up @@ -702,6 +704,7 @@ public void onResume() {
@Override
public void onPause() {
super.onPause();
if (mItemsToPlay == null || mItemsToPlay.isEmpty()) return;

setPlayPauseActionState(0);

Expand Down

0 comments on commit b3b8820

Please sign in to comment.