Closed
Description
I am using androidx.media3 to develop an audio player app which provides users with an option to rate currently playng media. So, inside my MediaSessionCallback I do this:
override fun onSetRating(
session: MediaSession,
controller: ControllerInfo,
rating: Rating
): ListenableFuture {
val item = session.player.currentMediaItem
item?.let {
val metadata = it.mediaMetadata.buildUpon().setUserRating(rating).build()
val mediaItem = it.buildUpon().setMediaMetadata(metadata).build()
session.player.setMediaItem(mediaItem, false)
}
return Futures.immediateFuture(SessionResult(SessionResult.RESULT_SUCCESS))
}
This works, but with the only caveat - it interrupts the audio for the moment. Please, help me to understand how user rating should work.