Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions app/src/main/java/org/schabi/newpipe/player/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,11 @@ private void initPlayer(final boolean playOnReady) {
simpleExoPlayer.setWakeMode(C.WAKE_MODE_NETWORK);
simpleExoPlayer.setHandleAudioBecomingNoisy(true);

final int repeatMode = prefs.getInt(
context.getString(R.string.repeat_mode_key), REPEAT_MODE_OFF
);
simpleExoPlayer.setRepeatMode(repeatMode);

audioReactor = new AudioReactor(context, simpleExoPlayer);

registerBroadcastReceiver();
Expand Down Expand Up @@ -1286,6 +1291,10 @@ public void onRepeatModeChanged(@RepeatMode final int repeatMode) {
}
UIs.call(playerUi -> playerUi.onRepeatModeChanged(repeatMode));
notifyPlaybackUpdateToListeners();
prefs
.edit()
.putInt(context.getString(R.string.repeat_mode_key), repeatMode)
.apply();
}

@Override
Expand Down
26 changes: 16 additions & 10 deletions app/src/main/java/org/schabi/newpipe/player/ui/VideoPlayerUi.java
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,8 @@ public void initPlayback() {

// #6825 - Ensure that the shuffle-button is in the correct state on the UI
setShuffleButton(player.getExoPlayer().getShuffleModeEnabled());
// Ensure that the repeat-button is in the correct state on the UI
setRepeatButton(player.getRepeatMode());
}

public abstract void removeViewFromParent();
Expand Down Expand Up @@ -951,16 +953,7 @@ public void onShuffleClicked() {
public void onRepeatModeChanged(@RepeatMode final int repeatMode) {
super.onRepeatModeChanged(repeatMode);

if (repeatMode == REPEAT_MODE_ALL) {
binding.repeatButton.setImageResource(
com.google.android.exoplayer2.ui.R.drawable.exo_controls_repeat_all);
} else if (repeatMode == REPEAT_MODE_ONE) {
binding.repeatButton.setImageResource(
com.google.android.exoplayer2.ui.R.drawable.exo_controls_repeat_one);
} else /* repeatMode == REPEAT_MODE_OFF */ {
binding.repeatButton.setImageResource(
com.google.android.exoplayer2.ui.R.drawable.exo_controls_repeat_off);
}
setRepeatButton(repeatMode);
}

@Override
Expand All @@ -980,6 +973,19 @@ private void setMuteButton(final boolean isMuted) {
? R.drawable.ic_volume_off : R.drawable.ic_volume_up));
}

private void setRepeatButton(@RepeatMode final int repeatMode) {
if (repeatMode == REPEAT_MODE_ALL) {
binding.repeatButton.setImageResource(
com.google.android.exoplayer2.ui.R.drawable.exo_controls_repeat_all);
} else if (repeatMode == REPEAT_MODE_ONE) {
binding.repeatButton.setImageResource(
com.google.android.exoplayer2.ui.R.drawable.exo_controls_repeat_one);
} else /* repeatMode == REPEAT_MODE_OFF */ {
binding.repeatButton.setImageResource(
com.google.android.exoplayer2.ui.R.drawable.exo_controls_repeat_off);
}
}

private void setShuffleButton(final boolean shuffled) {
binding.shuffleButton.setImageAlpha(shuffled ? 255 : 77);
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/settings_keys.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1514,4 +1514,5 @@
<item>@string/image_quality_medium_key</item>
<item>@string/image_quality_high_key</item>
</string-array>
<string name="repeat_mode_key">repeat_mode_key</string>
</resources>
Loading