androidx / androidx/media

Avoid rebuffering when modifying TrackSelector parameters

Open
#1,631 5 comments 0 reactions 1 assignee View on GitHub

@tonihei is already working on this.

Since Aug 19, 2024.

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

Description

[REQUIRED] Use case description
This is the exact same request raised time ago in the Exoplayer project (issue #6630).
I have an app using adaptive media, where in certain circumstances I want to reduce the bandwidth consumed by the video/audio.
I do so by setting new filtering criteria in the track selector, as follows:

    DefaultTrackSelector.Parameters currentParameters = ((DefaultTrackSelector) trackSelector).getParameters();
    DefaultTrackSelector.Parameters newParameters = currentParameters
            .buildUpon()
            .setForceLowestBitrate(true)
            .build();
    ((DefaultTrackSelector) trackSelector).setParameters(newParameters);

However this forces a reset in the playback (removal of chunks already available), with rebuff for a while.
The same happens when I remove that limitaton.
Of course rebuffering is more evident if I force the selection of a high bitrate track.
I need instead an uninterrupted playback

Proposed solution
I need something like:

trackSelector.SetParameters(newParameters, booleanWetherResetOrNot);

such that (in case of "don't reset") the playback is not interrupted, and chunks already downloaded or being downloaded are not removed; simply, the new trackSelector parameters would take effect at the next choice of the chunk to be downloaded.

Alternatives considered
In Exoplayer #6630 Tonihei finally showed an application-level solution (at that time I already implemented a more invasive blacklist based solution and didn't revert to Tonihei's suggestion). I'd like to use that solution now, so I tried implementing it. I can inject my custom class, and I can see it being created and invoked. However, I have no mechanism to access the actual instances of that CustomTrackSelection in order to dynamically set the parameters I need. Would someone be able to complete Tonihei's solution by showing also how to actually set a parameter on that class, dynamically?

Thanks in advance

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.