Answer the question
In order to leave comments, you need to log in
How to update metadata for playing media without interrupting playback?
I am working with androidx.media3 libraries and developing a service based on MediaSessionService. In my MediaSessionCallback callback, I'm trying to process a request to change the media rating:
override fun onSetRating(
session: MediaSession,
controller: ControllerInfo,
rating: Rating
): ListenableFuture<SessionResult> {
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))
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question