Update playback info on prepare

This commit is contained in:
Naveen 2023-08-21 15:56:24 +05:30
parent 0686de36ba
commit da6b2822cb
No known key found for this signature in database
GPG key ID: 0E155DAD31671DA3
2 changed files with 3 additions and 1 deletions

View file

@ -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<Track>, startIndex: Int = 0,
runOnPlayerThread {
setMediaItems(mediaItems, startIndex, startPosition)
prepare()
updatePlaybackInfo(this)
callback(true)
}
}

View file

@ -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