Skip to content

Commit

Permalink
Improve handling of consecutive empty ad groups
Browse files Browse the repository at this point in the history
Issue: #4030
Issue: #4280

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=208055792
  • Loading branch information
andrewlewis authored and ojw28 committed Aug 13, 2018
1 parent 4d6d790 commit 5a8af74
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 3 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@
([#4583](https://github.com/google/ExoPlayer/issues/4583)).
* Add `DataSpec.httpMethod` and update `HttpDataSource` implementations to
support HTTP HEAD method. Previously, only GET and POST were supported.
* IMA: Improve handling of consecutive empty ad groups
([#4030](https://github.com/google/ExoPlayer/issues/4030)),
([#4280](https://github.com/google/ExoPlayer/issues/4280)).

### 2.8.3 ###

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -631,8 +631,11 @@ public VideoProgressUpdate getContentProgress() {
} else if (fakeContentProgressElapsedRealtimeMs != C.TIME_UNSET) {
long elapsedSinceEndMs = SystemClock.elapsedRealtime() - fakeContentProgressElapsedRealtimeMs;
contentPositionMs = fakeContentProgressOffsetMs + elapsedSinceEndMs;
expectedAdGroupIndex =
int adGroupIndexForPosition =
adPlaybackState.getAdGroupIndexForPositionUs(C.msToUs(contentPositionMs));
if (adGroupIndexForPosition != C.INDEX_UNSET) {
expectedAdGroupIndex = adGroupIndexForPosition;
}
} else if (imaAdState == IMA_AD_STATE_NONE && !playingAd && hasContentDuration) {
contentPositionMs = player.getCurrentPosition();
// Update the expected ad group index for the current content position. The update is delayed
Expand Down Expand Up @@ -1124,6 +1127,16 @@ private void handleAdGroupLoadError(Exception error) {
if (pendingAdLoadError == null) {
pendingAdLoadError = AdLoadException.createForAdGroup(error, adGroupIndex);
}
// Discard the ad break, which makes sure we don't receive duplicate load error events.
adsManager.discardAdBreak();
// Set the next expected ad group index so we can handle multiple load errors in a row.
adGroupIndex++;
if (adGroupIndex < adPlaybackState.adGroupCount) {
expectedAdGroupIndex = adGroupIndex;
} else {
expectedAdGroupIndex = C.INDEX_UNSET;
}
pendingContentPositionMs = C.TIME_UNSET;
}

private void handleAdPrepareError(int adGroupIndex, int adIndexInAdGroup, Exception exception) {
Expand Down

0 comments on commit 5a8af74

Please sign in to comment.