From 991a98b571d7dc4dd1a0a67cfdeaa6a0a6621dd9 Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Wed, 23 Sep 2020 16:35:59 +0100 Subject: [PATCH] fix shuffle mode player getting stuck --- .../ui/findcontent/ShuffleFragment.java | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/lbry/browser/ui/findcontent/ShuffleFragment.java b/app/src/main/java/io/lbry/browser/ui/findcontent/ShuffleFragment.java index 115bd6f..27ce376 100644 --- a/app/src/main/java/io/lbry/browser/ui/findcontent/ShuffleFragment.java +++ b/app/src/main/java/io/lbry/browser/ui/findcontent/ShuffleFragment.java @@ -21,6 +21,7 @@ import androidx.annotation.NonNull; import androidx.preference.PreferenceManager; import com.google.android.exoplayer2.C; +import com.google.android.exoplayer2.PlaybackParameters; import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.SimpleExoPlayer; import com.google.android.exoplayer2.audio.AudioAttributes; @@ -243,6 +244,23 @@ public class ShuffleFragment extends BaseFragment { } loadAndScheduleDurations(); } + + if (MainActivity.appPlayer != null) { + if (MainActivity.playerReassigned) { + setPlayerForPlayerView(); + MainActivity.playerReassigned = false; + } + } + } + + private void setPlayerForPlayerView() { + View root = getView(); + if (root != null) { + PlayerView view = root.findViewById(R.id.shuffle_exoplayer_view); + view.setVisibility(View.VISIBLE); + view.setPlayer(null); + view.setPlayer(MainActivity.appPlayer); + } } public void onPause() { @@ -502,8 +520,7 @@ public class ShuffleFragment extends BaseFragment { playbackStarted = false; startTimeMillis = 0; - /* - if (MainActivity.appPlayer != null) { + /*if (MainActivity.appPlayer != null) { MainActivity.appPlayer.stop(true); MainActivity.appPlayer.removeListener(fileViewPlayerListener); PlaybackParameters params = new PlaybackParameters(1.0f);