Using PlaybackState to update the current playback state
@marcbaechinger is already working on this.
Since Nov 7, 2023.
- Dominant language
- Java
- Stars
- 3k
- Forks
- 955
- Avg merge
- 12d 14h
- Merged PRs (30d)
- 2
Description
Hello,
I have a project that uses androidx.media library, and I'm going to upgrade the project and use the androidx.media3 library.
In the project, I use a separate service to get information about the tracks being played. So when music is playing, I receive some callback from my service. In this callback I have all the track information I need to display. Every time I get the callback, I update the music playing on the device with the following code:
mediaSession.setMetadata(
MediaMetadataCompat.Builder()
.putString(METADATA_KEY_TITLE, title)
.putString(METADATA_KEY_DISPLAY_TITLE, title)
.putLong(METADATA_KEY_DURATION, duration)
.build()
)
Documentation of media3 library says "The Media3 library automatically updates the media session using the player's state. As such, you don't need to manually handle the mapping from player to session". As I understand, in media3 library I can't update the tracks being played in my own way, I can only provide URI for the track and the library itself will decide how to play the music . But I don't have any URI or path to music and all the information which I need to display, I get using callbacks from my service. Please let me know, how I can provide playable information about tracks in my situation?
Thank you in advance
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.