-
Notifications
You must be signed in to change notification settings - Fork 765
Closed
Labels
Description
Im using the MediaController and MediaLibraryService to play live stream music from a stream. The media notification should show the currently playing song info and I implemented the updating of the notification like this:
viewModel.updateNotification?.collect { audioSource ->
mediaController?.setMediaItem(audioSource.toMediaItem())
}
private fun AudioSource.toMediaItem() = MediaItem.Builder()
.setMediaMetadata(toMetadata())
.setUri(contentUrl)
.build()
private fun AudioSource.toMetadata() =
MediaMetadata.Builder()
.setTitle(albumName)
.setArtist(artistName)
.setArtworkUri(image)
.build()
But each time I change the media item like this when the song updates there is a short break in playback even though the URL of the stream stayed the same.
Is there an option to update just the metadata? So that the texts and images are changed but the stream remains intact something like:
viewModel.updateNotification?.collect { audioSource ->
mediaController?.updateMetadata(audioSource.toMetadata())
}
Reactions are currently unavailable