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
Explicit signals from ExoPlayer when transitioning between content and break #2859
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.
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.
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]
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.
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:
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.
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?
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.
Activity
marcbaechinger commentedon Oct 21, 2025
Thanks for your report!
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.
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 aonAdStarted()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.
marcbaechinger commentedon Oct 21, 2025
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.
work-keith commentedon Oct 21, 2025
Thanks for the quick reply. You are right,
onPositionDiscontinuity()does work on postroll. HoweveronAdCompleted()was not called at the end of a postroll. So it would be nice to have consistent behavingonAdStarted()andonAdCompleted()for interstitial breaks to indicate its start and end.marcbaechinger commentedon Oct 22, 2025
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 thepositionDiscontinuityand given this works, theonAdCompletedcallback is called for me as expected: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.
work-keith commentedon Oct 29, 2025
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 -- causingonAdCompleted()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?
marcbaechinger commentedon Oct 29, 2025
Cool, thanks for confirming.
That's fine. I have two CLs in review. I've added
onAdStarted. To make sure that there is always a call matchingonAdStartedI also addedonAdSkipped. This way, an app can be sure to get a callback call for each call toonAdStarted. This will land soon in main and will be part of the next release 1.9.Add onAdStarted to report ads that started playing