From 84de865daf689852fb8bc781f2ce5be74eaed6b3 Mon Sep 17 00:00:00 2001 From: Tom <25043847+Douile@users.noreply.github.com> Date: Mon, 29 Mar 2021 16:00:00 +0000 Subject: [PATCH] Allow the user to pause while a video is buffering (#5929) Fix pause while buffering Use getPlayWhenReady wrapper everywhere playWhenReady is checked Remove duplicate `playPause()` code --- .../java/org/schabi/newpipe/player/Player.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/player/Player.java b/app/src/main/java/org/schabi/newpipe/player/Player.java index f8e0732b3..1c11a3948 100644 --- a/app/src/main/java/org/schabi/newpipe/player/Player.java +++ b/app/src/main/java/org/schabi/newpipe/player/Player.java @@ -706,11 +706,7 @@ public final class Player implements // Android TV: without it focus will frame the whole player binding.playPauseButton.requestFocus(); - if (simpleExoPlayer.getPlayWhenReady()) { - play(); - } else { - pause(); - } + playPause(); } NavigationHelper.sendPlayerStartedEvent(context); } @@ -1687,7 +1683,7 @@ public final class Player implements } public void saveWasPlaying() { - this.wasPlaying = simpleExoPlayer.getPlayWhenReady(); + this.wasPlaying = getPlayWhenReady(); } //endregion @@ -2686,7 +2682,7 @@ public final class Player implements Log.d(TAG, "onPlayPause() called"); } - if (isPlaying()) { + if (getPlayWhenReady()) { pause(); } else { play(); @@ -4012,6 +4008,10 @@ public final class Player implements return !exoPlayerIsNull() && simpleExoPlayer.isPlaying(); } + public boolean getPlayWhenReady() { + return !exoPlayerIsNull() && simpleExoPlayer.getPlayWhenReady(); + } + private boolean isLoading() { return !exoPlayerIsNull() && simpleExoPlayer.isLoading(); }