Add shuffle and repeat modes to media session playback state invalidation

Which ensures both get updated when the MediaSessionConnector player
changes.

Issue:#6582
PiperOrigin-RevId: 277254889
This commit is contained in:
aquilescanta 2019-10-29 11:39:18 +00:00 committed by Oliver Woodman
parent accb31e489
commit 6c7fbe8b52
2 changed files with 15 additions and 11 deletions

View file

@ -2,9 +2,11 @@
### 2.10.7 ###
* HLS: Fix detection of Dolby Atmos to match the HLS authoring specification.
* MediaSession extension: Update shuffle and repeat modes when playback state
is invalidated ([#6582](https://github.com/google/ExoPlayer/issues/6582)).
* Fix the start of audio getting truncated when transitioning to a new
item in a playlist of opus streams.
* Fix detection of Dolby Atmos in HLS to match the HLS authoring specification.
### 2.10.6 (2019-10-17) ###

View file

@ -751,6 +751,18 @@ public final class MediaSessionConnector {
sessionPlaybackSpeed,
/* updateTime= */ SystemClock.elapsedRealtime())
.setExtras(extras);
@Player.RepeatMode int repeatMode = player.getRepeatMode();
mediaSession.setRepeatMode(
repeatMode == Player.REPEAT_MODE_ONE
? PlaybackStateCompat.REPEAT_MODE_ONE
: repeatMode == Player.REPEAT_MODE_ALL
? PlaybackStateCompat.REPEAT_MODE_ALL
: PlaybackStateCompat.REPEAT_MODE_NONE);
mediaSession.setShuffleMode(
player.getShuffleModeEnabled()
? PlaybackStateCompat.SHUFFLE_MODE_ALL
: PlaybackStateCompat.SHUFFLE_MODE_NONE);
mediaSession.setPlaybackState(builder.build());
}
@ -1050,21 +1062,11 @@ public final class MediaSessionConnector {
@Override
public void onRepeatModeChanged(@Player.RepeatMode int repeatMode) {
mediaSession.setRepeatMode(
repeatMode == Player.REPEAT_MODE_ONE
? PlaybackStateCompat.REPEAT_MODE_ONE
: repeatMode == Player.REPEAT_MODE_ALL
? PlaybackStateCompat.REPEAT_MODE_ALL
: PlaybackStateCompat.REPEAT_MODE_NONE);
invalidateMediaSessionPlaybackState();
}
@Override
public void onShuffleModeEnabledChanged(boolean shuffleModeEnabled) {
mediaSession.setShuffleMode(
shuffleModeEnabled
? PlaybackStateCompat.SHUFFLE_MODE_ALL
: PlaybackStateCompat.SHUFFLE_MODE_NONE);
invalidateMediaSessionPlaybackState();
invalidateMediaSessionQueue();
}