mirror of
https://github.com/samsonjs/media.git
synced 2026-04-11 12:15:47 +00:00
Fix isLastPeriod to take into account the played ad count
A content period just before a postroll ad group with all ads played was not being marked as the last media period in the timeline period. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=162471919
This commit is contained in:
parent
4658e619b3
commit
9716b03f8f
1 changed files with 15 additions and 8 deletions
|
|
@ -323,16 +323,23 @@ import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId;
|
|||
if (adGroupCount == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int lastAdGroupIndex = adGroupCount - 1;
|
||||
boolean periodHasPostrollAd = period.getAdGroupTimeUs(lastAdGroupIndex) == C.TIME_END_OF_SOURCE;
|
||||
if (!id.isAd()) {
|
||||
return !periodHasPostrollAd && endPositionUs == C.TIME_END_OF_SOURCE;
|
||||
} else if (periodHasPostrollAd && id.adGroupIndex == lastAdGroupIndex) {
|
||||
int adCountInLastAdGroup = period.getAdCountInAdGroup(lastAdGroupIndex);
|
||||
return adCountInLastAdGroup != C.LENGTH_UNSET
|
||||
&& id.adIndexInAdGroup == adCountInLastAdGroup - 1;
|
||||
boolean isAd = id.isAd();
|
||||
if (period.getAdGroupTimeUs(lastAdGroupIndex) != C.TIME_END_OF_SOURCE) {
|
||||
// There's no postroll ad.
|
||||
return !isAd && endPositionUs == C.TIME_END_OF_SOURCE;
|
||||
}
|
||||
return false;
|
||||
|
||||
int postrollAdCount = period.getAdCountInAdGroup(lastAdGroupIndex);
|
||||
if (postrollAdCount == C.LENGTH_UNSET) {
|
||||
// We won't know if this is the last ad until we know how many postroll ads there are.
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean isLastAd = isAd && id.adGroupIndex == lastAdGroupIndex
|
||||
&& id.adIndexInAdGroup == postrollAdCount - 1;
|
||||
return isLastAd || (!isAd && period.getPlayedAdCount(lastAdGroupIndex) == postrollAdCount);
|
||||
}
|
||||
|
||||
private boolean isLastInTimeline(MediaPeriodId id, boolean isLastMediaPeriodInPeriod) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue