Skip to content

Commit

Permalink
Add shuffle and repeat modes to media session playback state invalida…
Browse files Browse the repository at this point in the history
…tion

Which ensures both get updated when the MediaSessionConnector player
changes.

Issue:#6582
PiperOrigin-RevId: 277254889
  • Loading branch information
AquilesCanta authored and ojw28 committed Nov 5, 2019
1 parent accb31e commit 6c7fbe8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
4 changes: 3 additions & 1 deletion RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:/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) ###

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,18 @@ public final void invalidateMediaSessionPlaybackState() {
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());
}

Expand Down Expand Up @@ -1050,21 +1062,11 @@ public void onIsPlayingChanged(boolean isPlaying) {

@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();
}
Expand Down

0 comments on commit 6c7fbe8

Please sign in to comment.