androidx / androidx/media

ExoPlayer's DownloadManager download priority

Open
#1,364 0 comments 0 reactions 1 assignee View on GitHub

@marcbaechinger is already working on this.

Since May 10, 2024.

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

Description

Use case description

My app allows users to download tracks, one at a time, via a queue backed up by ExoPlayer's DownloadManager. It features a screen with a list of all ongoing downloads. Each entry has a button which the user can click to send the download up the list, making it the active one (no concurrency in this case). To try to make it so DownloadManager re-prioritizes clicked downloads, my plan was to remove all others added prior and then add the clicked one back, and re-add all others back. Unfortunately it seems that this ends up in DownloadManager marking downloads to be removed and then undoing so very quickly, often resulting in wrong behavior.

Proposed solution

A new public method on DownloadManager, setDownloadPriority, taking a request id and an int representing a priority, so that download manager always attempts to be downloading the requests with the highest priority, up to the concurrency limit.

Alternative solutions
  • Using different request ids. This will work, but it will waste progress on de-prioritized items, which is undesirable.
  • Separately manage my own queue for full flexibility and have DownloadManager handle truly only ongoing requests, so that DownloadManager only needs to be made aware of "real changes". This will work too, but it feels counterintuitive to have a class like DownloadManager, with thread safety constructs and APIs to handle multiple items, require this additional work on top.

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.