Skip to content

Playing pre-roll from the middle of the content (continue watching) #3091

@kotucz

Description

@kotucz
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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions