Skip to content

Unimplemented getCurrentTracks() in MediaController #102

Open

Description

@nplasterer

I recently transitioned my app over to media3 and I've noticed that the closed captions button is always disabled. All of my videos are HLS and on exoplayer2 it was loading all of the tracks correctly. I went to debug this through the media3 code and found that I kept hitting a TODO(b/178486745) line here: https://github.com/androidx/media/blob/release/libraries/session/src/main/java/androidx/media3/session/MediaController.java#L1674-L1677 Is this why subtitles are not enabled for media3? Is there a way I can get subtitles working correctly? Is there a timeline when this TODO will be addressed? Thanks!

Activity

  1. marcbaechinger commented on Jul 1, 2022

    @marcbaechinger
    Contributor

    Subtitles should still work as before in terms of ExoPlayer. But if I understand correctly and for the reasons you found, the PlayerControlView thinks there are no text tracks when you set a MediaController to playerView.setPlayer(player), so the view does not display them for selection.

    Can you confirm that with the closed captions button is always disabled you mean that the PlayerControleView does not show the buttons to enable/disable subtitles?

    That TODO needs to be addressed latest until we release the stable version of media3-1.0.0. I'd actually say we should see that we have this done asap and land it with the next release. We will update this issue when we have pushed the fix to the main branch and then again when it goes to the release branch.

  2. nplasterer commented on Jul 1, 2022

    @nplasterer
    Author

    Thanks @marcbaechinger what I mean by the closed captions button is always disabled is that the button is always shown but greyed out like its disabled. So I put some break points in and traced the code that enables and disables it. It led me to this updateTracksList() which calls initTrackSelectionAdapter() which calls the getCurrentTracks() method that always returns empty (the TODO one). Since it always returns empty the code will always hit updateButton and set enabled to false.

    I looked at the blame and saw that this TODO has been in the code for awhile so I'm not sure if my issue is directly related to my transition to media3. Previously when subtitles were working for me I was just using an ExoPlayer (exoplayer2) for everything and hand constructing a foreground service to play it in the background. I made the jump to media3 because it seemed like the easiest move to get a MediaController to fix a bluetooth headset bug. And I now use a MediaService for running the notification. Since a MediaController is a Player and am ExoPlayer is also a Player it feels like some of the calls previously are getting confused. I can only set the MediaItem on the MediaController now which is why I think subtitles are broken is because the MediaController version of getCurrentTrack that differs from the ExoPlayer version which was working. I've tried a couple different ways of trying to set the media item on the exoplayer instead of the media controller but it doesn't seem to work. Any thoughts on how I can get this working again? Really appreciate you taking the time!

  3. added a commit that references this issue on Mar 21, 2023
  4. fknives commented on Mar 25, 2023

    @fknives

    @nplasterer @christosts
    Hello,
    1.0.0 has been released 3 days ago. 🥳
    I tried to use MediaController.getCurrentTracks() and to me it looks like it works as intended now. I think this issue can be closed.

  5. added a commit that references this issue on Jun 22, 2023
  6. added a commit that references this issue on Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions