You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
HLS download fails when EXT-X-DEFINE variables from multivariant playlist are used in media playlist segment URLs #3258
Host these files on any HTTP server (or use FakeDataSource in a test)
Create a DownloadRequest for master.m3u8 and add it to DownloadManager
Observe that segment requests go to the literal URL {$cdnPrefix}segment001.ts instead of https://cdn.example.com/segment001.ts
Note
Playback works correctly because HlsPlaylistTracker passes the multivariant playlist to the parser. The download path (HlsDownloader → SegmentDownloader) uses a single HlsPlaylistParser() that never
stores the parsed multivariant playlist, so variable definitions are unavailable when media playlists are parsed.
Expected result
Variables defined in the multivariant playlist should resolve in media playlist segment URLs during download, matching the playback behavior.
Actual result
HlsDownloader uses a single HlsPlaylistParser() instance (constructed with HlsMultivariantPlaylist.EMPTY). After parsing the multivariant playlist, the result
is not stored back into the parser. When media playlists are subsequently parsed by the same instance, multivariantPlaylist is still EMPTY, so variableDefinitions is unavailable and {$variable} references pass through unsubstituted.
This causes:
Download failures (HTTP 404/400 on malformed URLs)
IndexOutOfBoundsException in HlsMediaPeriod.getStreamKeys() when DownloadHelper.getDownloadRequest() is called
Stack trace:
java.lang.IndexOutOfBoundsException: index (0) must be less than size (0)
at com.google.common.base.Preconditions.checkElementIndex(Preconditions.java:1372)
at com.google.common.collect.RegularImmutableList.get(RegularImmutableList.java:84)
at androidx.media3.exoplayer.hls.HlsMediaPeriod.getStreamKeys(HlsMediaPeriod.java:289)
at androidx.media3.exoplayer.offline.DownloadHelper.getDownloadRequestBuilder(DownloadHelper.java:939)
at androidx.media3.exoplayer.offline.DownloadHelper.getDownloadRequest(DownloadHelper.java:891)
Analysis
Playback works because HlsPlaylistTracker creates HlsPlaylistParser(multivariantPlaylist, ...) with the real multivariant playlist.
Download fails because HlsDownloader (via SegmentDownloader) uses the same parser instance for both master and media playlists, but the parser never stores
the parsed multivariant playlist for reuse.
The fix is to make HlsPlaylistParser store the multivariant playlist after parsing it in parse(), so subsequent media playlist parses on the same instance
inherit the variable definitions.
Hi @marcbaechinger, just checking in — is there any update on this issue? We have a use case that depends on this and would appreciate any timeline, Thanks!
The commit above resolves the variables in media playlists. Sorry for the wait. I was OOO the last two weeks. I'll try to include this in the next release.
Activity
marcbaechinger commentedon Jun 16, 2026
Thanks for the report and the pull. Please see my reply in the PR.
prashant9934 commentedon Jun 17, 2026
@marcbaechinger Thanks for the quick response! I've replied on the PR — please go ahead with your change.
prashant9934 commentedon Jun 22, 2026
Hi @marcbaechinger, just checking in — is there any update on this issue? We have a use case that depends on this and would appreciate any timeline, Thanks!
Resolve variables in HLS downloader child playlists
marcbaechinger commentedon Jul 8, 2026
The commit above resolves the variables in media playlists. Sorry for the wait. I was OOO the last two weeks. I'll try to include this in the next release.
Resolve variables in HLS downloader child playlists
Resolve variables in HLS downloader child playlists
Resolve variables in HLS downloader child playlists
Resolve variables in HLS downloader child playlists