Skip to content

Commit a4037a8

Browse files
authored
Merge pull request #8377 from iTrooz/vol_slider
Make volume progress bar match system volume when we start sliding
2 parents 212a413 + 61ee1c6 commit a4037a8

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)