Reset MediaSession shuffle/repeat modes if player is null

- 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
This commit is contained in:
olly 2019-11-01 14:44:54 +00:00 committed by Oliver Woodman
parent cc94ae7bfb
commit accb31e489
2 changed files with 9 additions and 1 deletions

View File

@ -700,6 +700,9 @@ public final class MediaSessionConnector {
/* position= */ 0, /* position= */ 0,
/* playbackSpeed= */ 0, /* playbackSpeed= */ 0,
/* updateTime= */ SystemClock.elapsedRealtime()); /* updateTime= */ SystemClock.elapsedRealtime());
mediaSession.setRepeatMode(PlaybackStateCompat.REPEAT_MODE_NONE);
mediaSession.setShuffleMode(PlaybackStateCompat.SHUFFLE_MODE_NONE);
mediaSession.setPlaybackState(builder.build()); mediaSession.setPlaybackState(builder.build());
return; return;
} }

View File

@ -1348,7 +1348,12 @@ public class PlayerNotificationManager {
} }
@Override @Override
public void onRepeatModeChanged(int repeatMode) { public void onRepeatModeChanged(@Player.RepeatMode int repeatMode) {
startOrUpdateNotification();
}
@Override
public void onShuffleModeEnabledChanged(boolean shuffleModeEnabled) {
startOrUpdateNotification(); startOrUpdateNotification();
} }
} }