Skip to content

Conversation

@FuAndTuan
Copy link

What is it?

  • Bugfix (user facing)
  • Feature (user facing)
  • Codebase improvement (dev facing)
  • Meta improvement to the project (dev facing)

Description of the changes in your PR

This PR adds persistence for the player’s shuffle and repeat modes, allowing users’ playback preferences to be saved and restored across app restarts.

Details of the implementation:

  • Added helper methods for saving and loading playback modes using SharedPreferences:
    private void saveShuffleToPrefs(final boolean enabled)
    private void saveRepeatToPrefs(@RepeatMode final int repeatMode)
    private boolean loadShuffleFromPrefs()
    private int loadRepeatFromPrefs()
  • Restored persisted states during player initialization:
    final int persistedRepeat = loadRepeatFromPrefs();
    final boolean persistedShuffle = loadShuffleFromPrefs();
    
    simpleExoPlayer.setRepeatMode(persistedRepeat);
    simpleExoPlayer.setShuffleModeEnabled(persistedShuffle);
  • Synced UI and playback queue behavior with the restored states:
    if (persistedShuffle && !playQueue.isShuffled()) {
        playQueue.shuffle();
    } else if (!persistedShuffle && playQueue.isShuffled()) {
        playQueue.unshuffle();
    }
    
    UIs.call(ui -> ui.onRepeatModeChanged(persistedRepeat));
    UIs.call(ui -> ui.onShuffleModeEnabledChanged(persistedShuffle));
    notifyPlaybackUpdateToListeners();
  • Ensures the shuffle/repeat state remains consistent across app sessions and UI updates.

Before/After Screenshots/Screen Record

Fixes the following issue(s)

APK testing

The change was tested locally using the debug build from Android Studio.
Shuffle and repeat modes were verified to persist correctly after restarting the app.
No additional APK testing was performed via the CI artifacts.

Due diligence

@github-actions github-actions bot added the size/small PRs with less than 50 changed lines label Oct 13, 2025
@FuAndTuan
Copy link
Author

Hi, this PR implements persistence for shuffle and repeat modes as discussed in issue #1795.
Please let me know if any adjustments are needed. Thank you!

@TobiGr TobiGr added feature request Issue is related to a feature in the app player Issues related to any player (main, popup and background) labels Oct 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature request Issue is related to a feature in the app player Issues related to any player (main, popup and background) size/small PRs with less than 50 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remember player states like Shuffle, Repeat, etc.

2 participants