Allow configuring asset-list prefetch timing per HLS interstitial
Maintainers usually reply within 4 days
@marcbaechinger is already working on this.
Since Oct 28, 2026.
Assessment
This issue has not been assessed yet.
Description
Use case description
We would like to control when HlsInterstitialsAdsLoader resolves the X-ASSET-LIST for each interstitial, allowing resolution both earlier and later than the current default.
In our implementation, asset-list resolution triggers an ad-decision request. Its timing affects both the time available to cache the returned ads before playback and which assets we request. (We can handle media caching ourselves through existing APIs.)
For live streams, we check whether the content position at which playback should resume after the break is already available:
resumePosition = breakStartPosition + plannedBreakDuration
If the known live edge has not reached that position, we request an additional filler audio asset. Resolving later may avoid requesting that asset while still leaving enough time to prepare the ads before playback reaches the break.
Whether this is possible depends on the listener’s distance behind the live edge, the break duration, and the resolution lead time.
Conversely, other breaks may benefit from earlier resolution to accommodate ad-service latency and allow more time for caching.
Currently, maybeExecuteOrSetNextAssetListResolutionMessage() in HlsInterstitialsAdsLoader.java:1432 calculates resolution timing using a fixed heuristic:
resolutionStartTimeUs =
max(
currentPeriodPositionUs,
resolutionStartTimeUs
- (TARGET_DURATION_MULTIPLIER * nextAssetResolution.targetDurationUs));
TARGET_DURATION_MULTIPLIER is a constant set to 3, so a ten-second playlist target duration causes resolution approximately 30 seconds before the break.
This ties ad-decision timing to segment duration rather than application requirements. Configurable timing would let us balance preparation time against content availability, which can favor either earlier or later resolution. Our manifests provide custom prefetch markers that specify the resolution timing for each break.
The requested capability would concern asset-list resolution timing. Media caching could remain application-managed.
Proposed solution
Would it be possible to expose an API for configuring asset-list resolution timing per interstitial, retaining the existing heuristic when no override is provided?
One possible API would be:
public void setAssetListResolutionLeadTimeMs(
Object adsId,
String interstitialId,
long leadTimeMs);
The lead time would specify how long before the break’s start resolution should become eligible:
// Resolve 60 seconds before this break.
adsLoader.setAssetListResolutionLeadTimeMs(
adsId,
"break-123",
60_000L,
)
// Resolve only 5 seconds before another break.
adsLoader.setAssetListResolutionLeadTimeMs(
adsId,
"break-456",
5_000L,
)
A lead time relative to the break would avoid ambiguity as the live window moves. An application with an explicit prefetch marker could calculate:
val leadTimeMs = breakStartPositionMs - prefetchPositionMs
The configured timing would replace the default for that interstitial, allowing earlier or later resolution while preserving Media3’s handling of seeks and live-window updates. A per-interstitial scheduling callback would also meet our needs.
Alternatives considered
- A global configurable lead time: Allows earlier or later resolution globally, but cannot express different requirements for individual breaks.
- Delaying resolution inside a custom DataSource: Could postpone the ad-decision request, but would keep Media3’s load in flight while waiting and could block other asset-list requests.
- A timing callback: Media3 could ask the application when to resolve each break’s asset list, then schedule the request itself. This would also work for our use case.
- Dominant language
- Java
- Stars
- 3.1k
- Forks
- 998
- Avg merge
- 6d 8h
- Merged PRs (30d)
- 2
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing 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.
More from androidx/media
-
Waive ads when seek/start at the beginningPossibly taken @microkatz claimed this 1 day ago. Openenhancement
androidx/media#3496 · 2 comments · 1 assignee ·
Maintainers usually reply within 4 days
-
Since 1.9.0, skip buttons in SLOT_BACK / SLOT_FORWARD reach legacy controllers as custom actionsPossibly taken @marcbaechinger claimed this today. Openbug
androidx/media#3495 · 1 comment · 1 assignee ·
Maintainers usually reply within 4 days
-
Offloaded audio left paused keeps AudioFlinger's AudioOffload wake lock forever, device never suspendsPossibly taken @microkatz claimed this 1 day ago. Open
androidx/media#3493 · 1 assignee ·
Maintainers usually reply within 4 days
-
Allow opting into frame-index seeking for MP3s without reliable seek metadataPossibly taken @icbaker claimed this today. Open
Difficulty 4/5 3-5 days Newbie friendliness 48/100
androidx/media#3492 · 1 assignee ·
Maintainers usually reply within 4 days
-
MediaSessionService: the platform session keeps every player command and publishes the whole queue until the session is added, e.g. after a sticky restartPossibly taken @marcbaechinger claimed this 3 days ago. Openbug
Difficulty 4/5 3-5 days Newbie friendliness 45/100
androidx/media#3490 · 3 comments · 1 assignee ·
Maintainers usually reply within 4 days
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
quarkiverse/quarkus-google-cloud-services#1188 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
opendataloader-project/opendataloader-pdf#851 ·
Maintainers usually reply within 1 day
-
Component: Frontend Component: Web Component Type: Maintenance
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
it-at-m/refarch-templates#1944 ·
Maintainers usually reply within 2 days
-
3.0.0-M*: every channel stays reachable from its session's KEX listeners, so a long-lived session leaks all closed channelsPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day