androidx / androidx/media

Send timed metadata to controller

Open
#948 2 comments 0 reactions 1 assignee View on GitHub

Nobody has claimed this yet.

needs triage question
Dominant language
Java
Stars
3k
Forks
955
Avg merge
12d 14h
Merged PRs (30d)
2

Description

I have a custom player built on top of SimpleBasePlayer. From this player, I want to send frequent time-accurate metadata to attached controllers (especially the UI controller). It seems like setTimedMetadata would be an appropriate solution. So within the simple base player I update and invalidate the state as follows.

private var state = State.Builder().......build()

private fun sendTimedMetadata(metadataEntry: Metadata.Entry) {
     val time = 1000L
     state = state.buildUpon()
            .setTimedMetadata(Metadata(time, metadataEntry))
            .build()
      invalidateState()
}

where sendTimedMetadata is called, when I want to share the metadata.

When I attach an Player.Listener to the directly to the player, this it receives the metadata on the onMetadata-callback as expected.

However, when I use the regular setup with MediaSession and MediaSessionService and trying to connect a MediaController from an activity, the onMetadata is not called for the controller. Other state changes like isPlaying are working fine.

Am I missing something here or is this not expected to work? Maybe there are alternatives or better ways to send regular events (could be 10 events per second) to an activity? There seems to be broadcastCustomCommand of a MediaSession but currently I did not find a way to listen to such commands by controllers.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.