Commit de915bd6 by tonihei Committed by Oliver Woodman

Handle potential timeline updates that switch from content to ad.

We currently don't test if an ad needs to be played in case we are already
playing content.

This is to prevent recreating the current content period when
an ad is marked as skipped. We prefer playing until the designated ad group
position and appending another piece of content. This is less likely to cause
visible discontinuities in case the ad group position is at a key frame
boundary.

However, this means we currently miss updates that require us to play an ad
after a timeline update.

PiperOrigin-RevId: 267553459
parent b7768853
......@@ -1326,9 +1326,16 @@ import java.util.concurrent.atomic.AtomicBoolean;
timeline, timeline.getPeriodByUid(newPeriodUid, period).windowIndex, C.TIME_UNSET);
newContentPositionUs = defaultPosition.second;
newPeriodId = queue.resolveMediaPeriodIdForAds(defaultPosition.first, newContentPositionUs);
} else if (newPeriodId.isAd()) {
// Recheck if the current ad still needs to be played.
newPeriodId = queue.resolveMediaPeriodIdForAds(newPeriodId.periodUid, newContentPositionUs);
} else {
// Recheck if the current ad still needs to be played or if we need to start playing an ad.
newPeriodId =
queue.resolveMediaPeriodIdForAds(playbackInfo.periodId.periodUid, newContentPositionUs);
if (!playbackInfo.periodId.isAd() && !newPeriodId.isAd()) {
// Drop update if we keep playing the same content (MediaPeriod.periodUid are identical) and
// only MediaPeriodId.nextAdGroupIndex may have changed. This postpones a potential
// discontinuity until we reach the former next ad group position.
newPeriodId = playbackInfo.periodId;
}
}
if (playbackInfo.periodId.equals(newPeriodId) && oldContentPositionUs == newContentPositionUs) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment