From 41ae4b4c8eaa42964d404b9283dad6ddc3931d00 Mon Sep 17 00:00:00 2001 From: Oliver Woodman Date: Fri, 15 May 2020 10:58:46 +0100 Subject: [PATCH] Merge pull request #7367 from inv3rse:keep-paused-state-during-buffering PiperOrigin-RevId: 311623784 --- RELEASENOTES.md | 3 +++ .../exoplayer2/ext/mediasession/MediaSessionConnector.java | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index cc03d8621c7..4ac4648d0c5 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -29,6 +29,9 @@ Services rather than Cronet Embedded. This allows Cronet to be used with a negligible increase in application size, compared to approximately 8MB when embedding the library. +* MediaSession extension: Set session playback state to BUFFERING only when + actually playing ([#7367](https://github.com/google/ExoPlayer/pull/7367), + [#7206](https://github.com/google/ExoPlayer/issues/7206)). * DownloadService: Fix "Not allowed to start service" `IllegalStateException`. ### 2.11.4 (2020-04-08) ### 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 41a20718276..0847686d215 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 @@ -987,7 +987,9 @@ private static int getMediaSessionPlaybackState( @Player.State int exoPlayerPlaybackState, boolean playWhenReady) { switch (exoPlayerPlaybackState) { case Player.STATE_BUFFERING: - return PlaybackStateCompat.STATE_BUFFERING; + return playWhenReady + ? PlaybackStateCompat.STATE_BUFFERING + : PlaybackStateCompat.STATE_PAUSED; case Player.STATE_READY: return playWhenReady ? PlaybackStateCompat.STATE_PLAYING : PlaybackStateCompat.STATE_PAUSED; case Player.STATE_ENDED: