Playing pre-roll from the middle of the content (continue watching)
@marcbaechinger is already working on this.
Since Feb 27, 2026.
- Dominant language
- Java
- Stars
- 3k
- Forks
- 955
- Avg merge
- 12d 14h
- Merged PRs (30d)
- 2
Description
0 --------- 1 ---------2 ---- CW --- 3 ---- 4 ----
Imagine in the timeline above, user reopens the content and continues watching (CW) from the somewhere in the middle.
We want to play preroll upon opening the content. When user seeks to the beginning and plays or seeks through ad groups 1 and 2, we want the ad groups play.
What is the recommended approach for doing this?
We are using custom AdsLoader implementation.
From our attempts so far we found this:
When the ad groups are initialized as in the scheme above, player will pick ad group 2 to be played instead of preroll group 0. As per AdPlaybackState.getAdGroupIndexForPositionUs
ExoPlayer 2.16.1
Number of ad groups may not change, but ad group times can change. So we can move groups 1 and 2 to some different position and restore when seeking back.
In later media3 versions
Ad groups may not change time:
AdPlaybackState.checkValidAdPlaybackStateUpdate
checkState(oldAdGroup.timeUs == newAdGroup.timeUs);
Midroll ad groups may be added later (after playing preroll) but this causes position discontinuity and buffering
I am thinking of rearranging the ad groups and inserting preroll ad group at CW position instead of 0, but this seems quite error-prone
Is there some other way to implement this, that I am missing? Thanks
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.