From 61ee1c61dfd7a784b33ff8c647faa0ba984b1a4e Mon Sep 17 00:00:00 2001 From: iTrooz_ <42669835+iTrooz@users.noreply.github.com> Date: Mon, 9 May 2022 20:48:48 +0200 Subject: [PATCH] Make volume progress bar match system volume when we start sliding --- .../newpipe/player/event/PlayerGestureListener.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/src/main/java/org/schabi/newpipe/player/event/PlayerGestureListener.java b/app/src/main/java/org/schabi/newpipe/player/event/PlayerGestureListener.java index 794fe9b3c..a7fb40c47 100644 --- a/app/src/main/java/org/schabi/newpipe/player/event/PlayerGestureListener.java +++ b/app/src/main/java/org/schabi/newpipe/player/event/PlayerGestureListener.java @@ -126,6 +126,14 @@ public class PlayerGestureListener } private void onScrollMainVolume(final float distanceX, final float distanceY) { + // If we just started sliding, change the progress bar to match the system volume + if (player.getVolumeRelativeLayout().getVisibility() != View.VISIBLE) { + final float volumePercent = player + .getAudioReactor().getVolume() / (float) maxVolume; + player.getVolumeProgressBar().setProgress( + (int) (volumePercent * player.getMaxGestureLength())); + } + player.getVolumeProgressBar().incrementProgressBy((int) distanceY); final float currentProgressPercent = (float) player .getVolumeProgressBar().getProgress() / player.getMaxGestureLength();