AdsMediaSource with HLS content fails on progressive (MP4) ads with HlsPlaylistParser$ParserException
@marcbaechinger is already working on this.
Since Aug 6, 2025.
- Dominant language
- Java
- Stars
- 3k
- Forks
- 955
- Avg merge
- 12d 14h
- Merged PRs (30d)
- 2
Description
Version
Media3 main branch
More version details
androidx.media3:media3-exoplayer:1.5.1
Devices that reproduce the issue
- Samsung A54
- Vivo V2434
- Emulator Pixel 7 OS 14
Devices that do not reproduce the issue
No response
Reproducible in the demo app?
Yes
Reproduction steps
- Set up an ExoPlayer instance to play a live or VOD HLS stream.
- Use the ImaAdsLoader for client-side ad insertion.
- Configure a MediaItem with a VMAP ad tag URI using MediaItem.Builder().setAdsConfiguration(...).
- Ensure the VMAP points to a VAST response where at least one of the ad creatives is a progressive MP4 file (not an HLS .m3u8 playlist).
- Prepare and play the MediaItem.
- The player will attempt to load the pre-roll ad, select the MP4 media, and crash with the HlsPlaylistParser exception.
Expected result
The player should seamlessly play the MP4 ad and then return to the HLS content
Actual result
When playing HLS main content and using client-side ad insertion with a VMAP ad tag, the player crashes if an ad creative in the VAST response is a progressive MP4 file instead of an HLS playlist. The crash occurs because the player attempts to parse the MP4 ad media using the HlsPlaylistParser, which was configured for the main content.
This leads to the following fatal exception:
androidx.media3.exoplayer.source.ads.AdsMediaSource$AdLoadException: androidx.media3.common.ParserException: Input does not start with the #EXTM3U header.{contentIsMalformed=true, dataType=4} at androidx.media3.exoplayer.source.ads.AdsMediaSource$AdPrepareListener.onPrepareError(AdsMediaSource.java:459) at androidx.media3.exoplayer.source.MaskingMediaPeriod.maybeThrowPrepareError(MaskingMediaPeriod.java:167) at androidx.media3.exoplayer.source.MaskingMediaPeriod.maybeThrowPrepareError(MaskingMediaPeriod.java:157) at androidx.media3.exoplayer.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:1129) at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:544) at android.os.Handler.dispatchMessage(Handler.java:105) at android.os.Looper.loopOnce(Looper.java:250) at android.os.Looper.loop(Looper.java:340) at android.os.HandlerThread.run(HandlerThread.java:107) Caused by: androidx.media3.common.ParserException: Input does not start with the #EXTM3U header.{contentIsMalformed=true, dataType=4} at androidx.media3.exoplayer.hls.playlist.HlsPlaylistParser.parse(HlsPlaylistParser.java:262) at androidx.media3.exoplayer.hls.playlist.HlsPlaylistParser.parse(HlsPlaylistParser.java:69) at androidx.media3.exoplayer.upstream.ParsingLoadable.load(ParsingLoadable.java:184) at androidx.media3.exoplayer.upstream.Loader$LoadTask.run(Loader.java:421) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644) at java.lang.Thread.run(Thread.java:1012) ]
Media
Bug Report
- You will email the zip file produced by
adb bugreportto android-media-github@google.com after filing this issue.
Contributor 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.
Assessment
This issue has not been assessed yet.