Commit 44a8245a by andrewlewis Committed by Oliver Woodman

Fix ad loading when there is no preroll

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=178234009
parent 439c3022
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
* IMA extension: * IMA extension:
* Skip ads before the ad preceding the player's initial seek position * Skip ads before the ad preceding the player's initial seek position
([#3527](https://github.com/google/ExoPlayer/issues/3527)). ([#3527](https://github.com/google/ExoPlayer/issues/3527)).
* Fix ad loading when there is no preroll.
### 2.6.0 ### ### 2.6.0 ###
......
...@@ -326,9 +326,13 @@ public final class ImaAdsLoader extends Player.DefaultEventListener implements A ...@@ -326,9 +326,13 @@ public final class ImaAdsLoader extends Player.DefaultEventListener implements A
adsRenderingSettings.setMimeTypes(supportedMimeTypes); adsRenderingSettings.setMimeTypes(supportedMimeTypes);
int adGroupIndexForPosition = int adGroupIndexForPosition =
getAdGroupIndexForPosition(adGroupTimesUs, C.msToUs(pendingContentPositionMs)); getAdGroupIndexForPosition(adGroupTimesUs, C.msToUs(pendingContentPositionMs));
if (adGroupIndexForPosition == C.INDEX_UNSET) { if (adGroupIndexForPosition == 0) {
podIndexOffset = 0;
} else if (adGroupIndexForPosition == C.INDEX_UNSET) {
pendingContentPositionMs = C.TIME_UNSET; pendingContentPositionMs = C.TIME_UNSET;
} else if (adGroupIndexForPosition > 0) { // There is no preroll and midroll pod indices start at 1.
podIndexOffset = -1;
} else /* adGroupIndexForPosition > 0 */ {
// Skip ad groups before the one at or immediately before the playback position. // Skip ad groups before the one at or immediately before the playback position.
for (int i = 0; i < adGroupIndexForPosition; i++) { for (int i = 0; i < adGroupIndexForPosition; i++) {
adPlaybackState.playedAdGroup(i); adPlaybackState.playedAdGroup(i);
...@@ -341,8 +345,7 @@ public final class ImaAdsLoader extends Player.DefaultEventListener implements A ...@@ -341,8 +345,7 @@ public final class ImaAdsLoader extends Player.DefaultEventListener implements A
adsRenderingSettings.setPlayAdsAfterTime(midpointTimeUs / C.MICROS_PER_SECOND); adsRenderingSettings.setPlayAdsAfterTime(midpointTimeUs / C.MICROS_PER_SECOND);
// We're removing one or more ads, which means that the earliest ad (if any) will be a // We're removing one or more ads, which means that the earliest ad (if any) will be a
// midroll/postroll. According to the AdPodInfo documentation, midroll pod indices always // midroll/postroll. Midroll pod indices start at 1.
// start at 1, so take this into account when offsetting the pod index for the skipped ads.
podIndexOffset = adGroupIndexForPosition - 1; podIndexOffset = adGroupIndexForPosition - 1;
} }
......
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