From c5c50078d77572e988a14d7afd05412b13ea3748 Mon Sep 17 00:00:00 2001 From: olly Date: Fri, 1 Nov 2019 14:44:54 +0000 Subject: [PATCH] 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 --- .../exoplayer2/ext/mediasession/MediaSessionConnector.java | 3 +++ .../android/exoplayer2/ui/PlayerNotificationManager.java | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/extensions/mediasession/src/main/java/com/google/android/exoplayer2/ext/mediasession/MediaSessionConnector.java b/extensions/mediasession/src/main/java/com/google/android/exoplayer2/ext/mediasession/MediaSessionConnector.java index 50777dd4d6..8def61aead 100644 --- a/extensions/mediasession/src/main/java/com/google/android/exoplayer2/ext/mediasession/MediaSessionConnector.java +++ b/extensions/mediasession/src/main/java/com/google/android/exoplayer2/ext/mediasession/MediaSessionConnector.java @@ -701,6 +701,9 @@ public final class MediaSessionConnector { /* position= */ 0, /* playbackSpeed= */ 0, /* updateTime= */ SystemClock.elapsedRealtime()); + + mediaSession.setRepeatMode(PlaybackStateCompat.REPEAT_MODE_NONE); + mediaSession.setShuffleMode(PlaybackStateCompat.SHUFFLE_MODE_NONE); mediaSession.setPlaybackState(builder.build()); return; } diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerNotificationManager.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerNotificationManager.java index fb11dfae71..9decf900a7 100644 --- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerNotificationManager.java +++ b/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerNotificationManager.java @@ -1348,7 +1348,12 @@ public class PlayerNotificationManager { } @Override - public void onRepeatModeChanged(int repeatMode) { + public void onRepeatModeChanged(@Player.RepeatMode int repeatMode) { + startOrUpdateNotification(); + } + + @Override + public void onShuffleModeEnabledChanged(boolean shuffleModeEnabled) { startOrUpdateNotification(); } }