Skip to content

Explicit signals from ExoPlayer when transitioning between content and break #2859

Closed

Description

@work-keith

Use case description
Playing VOD interstitial streams with postroll. To detect the start and the end of an interstitial break, one way is to inspect the Player.PositionInfo objects from Player.Listener.onPositionDiscontinuity() by comparing the oldPosition and the newPosition. A break would have an adGroupIndex in the Player.PositionInfo object. This works for midrolls where there is a transition between content and break. However, in the case of postroll, the break ended together with the whole playback without going back the content. So the end of an interstitial postroll break could not be detected by onPositionDiscontinuity(). Also, onAdCompleted() was not called.

The same case would probably happen for preroll breaks, as playback starts directly from the break without first transitioned from content.

Proposed solution
Add two new methods onInterstitialAdStart() and onInterstitialAdEnd() to HlsInterstitialsAdsLoader.Listener. They will be called at the beginning and the end of interstitial breaks.

Activity

  1. marcbaechinger commented on Oct 21, 2025

    @marcbaechinger
    Contributor

    Thanks for your report!

    the break ended together with the whole playback without going back the content

    If this is the case this is a bug in ExoPlayer. After a post roll, there should be a disonctinuity to the end of the content. So Playback should end at the content and such a discontinuity should occur.

    But you are right for the preroll where playback starts immediately on the preroll period and hence there isn't such a discontinuity.

    onInterstitialAdStart() and onInterstitialAdEnd()

    I think this is a valid request and it would remove the burden of the implementation from developers when the library is doing so.

    You mentioned onAdCompleted. I think I keep that wording and we would have a onAdStarted() to achieve what you suggest. The reason is mostly than in case we have a similar Listener for other formats once, we can use the same naming and we don't have to rely on the HLS specific `interstitial' term.

    I'll verify the behavior before ending and will provide the additional callback method.

  2. marcbaechinger commented on Oct 21, 2025

    @marcbaechinger
    Contributor

    the break ended together with the whole playback without going back the content

    I just tried to repro this and I see that the position discontinuity at the end goes from the post roll to the end of the content (position: durationUs - 1 = 71999):

    If you keep seeing this, mind providing some of your stream to me so I can test? That would be super useful in general as I haven't seen a large variety of stream yet.

    If you're unable to share bug reports or test content publicly, please send them to android-media-github@google.com using a subject in the format "Issue #2859". Please also update this issue to indicate you’ve done this.

    // to the post roll
    2025-10-21 15:50:23.013 D  positionDiscontinuity [eventTime=25.24, mediaPos=0.07, window=0, period=0, adGroup=2, ad=0, reason=AUTO_TRANSITION, PositionInfo:old [mediaItem=0, period=0, pos=72000], PositionInfo:new [mediaItem=0, period=0, pos=0, contentPos=72000, adGroup=2, ad=0]]
    // from post roll to end of content
    2025-10-21 15:50:53.189 D  positionDiscontinuity [eventTime=55.41, mediaPos=72.02, window=0, period=0, reason=AUTO_TRANSITION, PositionInfo:old [mediaItem=0, period=0, pos=29997, contentPos=72000, adGroup=2, ad=0], PositionInfo:new [mediaItem=0, period=0, pos=71999]]
    // state ENDED
    2025-10-21 15:50:53.198 D  state [eventTime=55.42, mediaPos=72.02, window=0, period=0, ENDED]
    
  3. work-keith commented on Oct 21, 2025

    @work-keith
    Author

    Thanks for the quick reply. You are right, onPositionDiscontinuity() does work on postroll. However onAdCompleted() was not called at the end of a postroll. So it would be nice to have consistent behaving onAdStarted() and onAdCompleted() for interstitial breaks to indicate its start and end.

  4. marcbaechinger commented on Oct 22, 2025

    @marcbaechinger
    Contributor

    I have tested this with the VOD streams that I have available and I can not reproduce that onAdCompleted() is not called after a postroll. The complete ad event is trackked by looking at the positionDiscontinuity and given this works, the onAdCompleted callback is called for me as expected:

    2025-10-22 13:15:12.519 31121-31121 EventLogger             androidx.media3.demo.main            D  positionDiscontinuity [eventTime=52.63, mediaPos=72.01, window=0, period=0, reason=AUTO_TRANSITION, PositionInfo:old [mediaItem=0, period=0, pos=29997, contentPos=72000, adGroup=2, ad=0], PositionInfo:new [mediaItem=0, period=0, pos=71999]]
    2025-10-22 13:15:12.521 31121-31121 AdEventLogger           androidx.media3.demo.main            D  onAdCompleted: [mediaId=, adsId=/vod-ads-id-asset-uri, adGroupIndex=2, adIndexInAdGroup=0]
    2025-10-22 13:15:12.575 31121-31121 EventLogger             androidx.media3.demo.main            D  state [eventTime=52.68, mediaPos=72.07, window=0, period=0, ENDED]
    

    If you can repro this with your VOD stream, would it be possible to send us this stream for testing? Or are you havijng a specific ad config with which you see this? If this is the case that would be helpful to know as well.

    If you're unable to share bug reports or test content publicly, please send them to android-media-github@google.com using a subject in the format "Issue #2859". Please also update this issue to indicate you’ve done this.

  5. work-keith commented on Oct 29, 2025

    @work-keith
    Author

    Thanks for verifying this. I also retested the onAdCompleted() part. I think that was a stream problem, having an extra segment at the end causing an exception -- causing onAdCompleted() not being called. I have rectified the stream and the callbacks were working as expected. So there's not a bug in the callbacks.

    For the feature request on explicit callbacks for start and end of interstitial breaks, do you think I need to post a new ticket or keep it on this ticket?

  6. marcbaechinger commented on Oct 29, 2025

    @marcbaechinger
    Contributor

    Cool, thanks for confirming.

    For the feature request on explicit callbacks for start and end of interstitial breaks,
    do you think I need to post a new ticket or keep it on this ticket?

    That's fine. I have two CLs in review. I've added onAdStarted. To make sure that there is always a call matching onAdStarted I also added onAdSkipped. This way, an app can be sure to get a callback call for each call to onAdStarted. This will land soon in main and will be part of the next release 1.9.

  7. locked and limited conversation to collaborators on Jan 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions