Skip to content

Commit

Permalink
Make BasePlayer.get[Next/Previous]WindowIndex more useful
Browse files Browse the repository at this point in the history
When in REPEAT_MODE_ONE, it's unlikely apps want next/previous methods
on the player to keep them in the same window. Music apps in particular
tend to implement next/previous functionality as though repeat mode were
off when in this mode (i.e. current song loops forever during playback,
but next/previous navigation still navigates to next/previous items).

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=220469655
  • Loading branch information
ojw28 committed Nov 7, 2018
1 parent fd98d70 commit 6bc0408
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public final int getNextWindowIndex() {
return timeline.isEmpty()
? C.INDEX_UNSET
: timeline.getNextWindowIndex(
getCurrentWindowIndex(), getRepeatMode(), getShuffleModeEnabled());
getCurrentWindowIndex(), getRepeatModeForNavigation(), getShuffleModeEnabled());
}

@Override
Expand All @@ -88,7 +88,7 @@ public final int getPreviousWindowIndex() {
return timeline.isEmpty()
? C.INDEX_UNSET
: timeline.getPreviousWindowIndex(
getCurrentWindowIndex(), getRepeatMode(), getShuffleModeEnabled());
getCurrentWindowIndex(), getRepeatModeForNavigation(), getShuffleModeEnabled());
}

@Override
Expand Down Expand Up @@ -129,4 +129,10 @@ public final long getContentDuration() {
? C.TIME_UNSET
: timeline.getWindow(getCurrentWindowIndex(), window).getDurationMs();
}

@RepeatMode
private int getRepeatModeForNavigation() {
@RepeatMode int repeatMode = getRepeatMode();
return repeatMode == REPEAT_MODE_ONE ? REPEAT_MODE_OFF : repeatMode;
}
}

0 comments on commit 6bc0408

Please sign in to comment.