From da6b2822cbfe4029656453430384b4665e77cbb6 Mon Sep 17 00:00:00 2001 From: Naveen Date: Mon, 21 Aug 2023 15:56:24 +0530 Subject: [PATCH] Update playback info on prepare --- .../simplemobiletools/musicplayer/extensions/MediaController.kt | 2 ++ .../musicplayer/playback/player/SimpleMusicPlayer.kt | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/extensions/MediaController.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/extensions/MediaController.kt index 3101d9a5..c5b03508 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/extensions/MediaController.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/extensions/MediaController.kt @@ -7,6 +7,7 @@ import com.simplemobiletools.commons.helpers.ensureBackgroundThread import com.simplemobiletools.musicplayer.models.Track import com.simplemobiletools.musicplayer.models.toMediaItems import com.simplemobiletools.musicplayer.playback.CustomCommands +import com.simplemobiletools.musicplayer.playback.PlaybackService.Companion.updatePlaybackInfo import kotlin.time.Duration.Companion.seconds fun MediaController.sendCommand(command: CustomCommands) = sendCustomCommand(command.sessionCommand, Bundle.EMPTY) @@ -34,6 +35,7 @@ fun MediaController.prepareUsingTracks(tracks: List, startIndex: Int = 0, runOnPlayerThread { setMediaItems(mediaItems, startIndex, startPosition) prepare() + updatePlaybackInfo(this) callback(true) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/playback/player/SimpleMusicPlayer.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/playback/player/SimpleMusicPlayer.kt index 12fa6b6c..62d7ba03 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/playback/player/SimpleMusicPlayer.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/playback/player/SimpleMusicPlayer.kt @@ -6,7 +6,7 @@ import androidx.media3.common.util.UnstableApi import androidx.media3.exoplayer.ExoPlayer @UnstableApi -class SimpleMusicPlayer(val exoPlayer: ExoPlayer) : ForwardingPlayer(exoPlayer) { +class SimpleMusicPlayer(private val exoPlayer: ExoPlayer) : ForwardingPlayer(exoPlayer) { /** * The default implementation only advertises the seek to next and previous item in the case