Skip to content

Commit

Permalink
Reset MediaSession shuffle/repeat modes if player is null
Browse files Browse the repository at this point in the history
- This is for consistency with PlayerControlView.

- Also update PlayerNotificationManager notification if shuffle
  mode changes. This is for consistency with what happens when
  the repeat mode changes. By default the notification will be
  unchanged, but custom implementations can extend and then
  override createNotification, and given these modes change
  infrequently it feels like we can just do this. The alternative
  for achieving consistency would be to remove handling of repeat
  mode changes.

Issue: #6582
PiperOrigin-RevId: 277925094
  • Loading branch information
ojw28 committed Nov 5, 2019
1 parent a4e7274 commit c5c5007
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,9 @@ public final void invalidateMediaSessionPlaybackState() {
/* position= */ 0,
/* playbackSpeed= */ 0,
/* updateTime= */ SystemClock.elapsedRealtime());

mediaSession.setRepeatMode(PlaybackStateCompat.REPEAT_MODE_NONE);
mediaSession.setShuffleMode(PlaybackStateCompat.SHUFFLE_MODE_NONE);
mediaSession.setPlaybackState(builder.build());
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1348,7 +1348,12 @@ public void onPositionDiscontinuity(int reason) {
}

@Override
public void onRepeatModeChanged(int repeatMode) {
public void onRepeatModeChanged(@Player.RepeatMode int repeatMode) {
startOrUpdateNotification();
}

@Override
public void onShuffleModeEnabledChanged(boolean shuffleModeEnabled) {
startOrUpdateNotification();
}
}
Expand Down

0 comments on commit c5c5007

Please sign in to comment.