From 9369d3d3c795c2dae8a71708d97f611ebc1ab8b5 Mon Sep 17 00:00:00 2001 From: Mark Raynsford Date: Tue, 5 Nov 2024 15:00:05 +0000 Subject: [PATCH] Handle paused-but-downloading streamed books correctly (PP-1852). --- .../audiobook/media3/ExoAdapter.kt | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/org.librarysimplified.audiobook.media3/src/main/java/org/librarysimplified/audiobook/media3/ExoAdapter.kt b/org.librarysimplified.audiobook.media3/src/main/java/org/librarysimplified/audiobook/media3/ExoAdapter.kt index 8d7280ef..a9fd647b 100644 --- a/org.librarysimplified.audiobook.media3/src/main/java/org/librarysimplified/audiobook/media3/ExoAdapter.kt +++ b/org.librarysimplified.audiobook.media3/src/main/java/org/librarysimplified/audiobook/media3/ExoAdapter.kt @@ -191,13 +191,18 @@ class ExoAdapter( ) { this.logger.debug("onPlayWhenReadyChanged: {} {})", playWhenReady, reason) - if (this.exoPlayer.isPlaying) { - this.newState(ExoPlayerPlaybackStatus.PLAYING) - } else { - if (this.exoPlayer.isLoading) { - this.isBufferingNow = true - this.newState(ExoPlayerPlaybackStatus.BUFFERING) - } else { + when (playWhenReady) { + true -> { + if (this.exoPlayer.isPlaying) { + this.newState(ExoPlayerPlaybackStatus.PLAYING) + return + } + if (this.exoPlayer.isLoading) { + this.isBufferingNow = true + this.newState(ExoPlayerPlaybackStatus.BUFFERING) + } + } + false -> { this.newState(ExoPlayerPlaybackStatus.PAUSED) } }