Skip to content

Commit 61ee1c6

Browse files
committed
Make volume progress bar match system volume when we start sliding
1 parent 212a413 commit 61ee1c6

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

app/src/main/java/org/schabi/newpipe/player/event/PlayerGestureListener.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,14 @@ public void onScroll(@NonNull final MainPlayer.PlayerType playerType,
126126
}
127127

128128
private void onScrollMainVolume(final float distanceX, final float distanceY) {
129+
// If we just started sliding, change the progress bar to match the system volume
130+
if (player.getVolumeRelativeLayout().getVisibility() != View.VISIBLE) {
131+
final float volumePercent = player
132+
.getAudioReactor().getVolume() / (float) maxVolume;
133+
player.getVolumeProgressBar().setProgress(
134+
(int) (volumePercent * player.getMaxGestureLength()));
135+
}
136+
129137
player.getVolumeProgressBar().incrementProgressBy((int) distanceY);
130138
final float currentProgressPercent = (float) player
131139
.getVolumeProgressBar().getProgress() / player.getMaxGestureLength();

0 commit comments

Comments
 (0)