Improve robustness of ImaAdsLoader

Remove an assertion that there was a call to pause content between two
content -> ad transitions.

Also, only use the player position for resuming an ad on reattaching if the
player is currently playing an ad, in case IMA pauses content before the player
actually transitions to an ad.

Issue: #3430

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=176365842
This commit is contained in:
andrewlewis 2017-11-20 08:42:34 -08:00 committed by Oliver Woodman
parent 1439b4a3ef
commit 60555e2c4b
2 changed files with 4 additions and 2 deletions

View file

@ -53,6 +53,9 @@
([#3303](https://github.com/google/ExoPlayer/issues/3303)).
* Ignore seeks if an ad is playing
([#3309](https://github.com/google/ExoPlayer/issues/3309)).
* Improve robustness of `ImaAdsLoader` in case content is not paused between
content to ad transitions
([#3430](https://github.com/google/ExoPlayer/issues/3430)).
* UI:
* Allow specifying a `Drawable` for the `TimeBar` scrubber
([#3337](https://github.com/google/ExoPlayer/issues/3337)).

View file

@ -260,7 +260,7 @@ public final class ImaAdsLoader extends Player.DefaultEventListener implements A
@Override
public void detachPlayer() {
if (adsManager != null && imaPausedContent) {
adPlaybackState.setAdResumePositionUs(C.msToUs(player.getCurrentPosition()));
adPlaybackState.setAdResumePositionUs(playingAd ? C.msToUs(player.getCurrentPosition()) : 0);
adsManager.pause();
}
lastAdProgress = getAdProgress();
@ -628,7 +628,6 @@ public final class ImaAdsLoader extends Player.DefaultEventListener implements A
if (!wasPlayingAd && playingAd) {
int adGroupIndex = player.getCurrentAdGroupIndex();
// IMA hasn't sent CONTENT_PAUSE_REQUESTED yet, so fake the content position.
Assertions.checkState(fakeContentProgressElapsedRealtimeMs == C.TIME_UNSET);
fakeContentProgressElapsedRealtimeMs = SystemClock.elapsedRealtime();
fakeContentProgressOffsetMs = C.usToMs(adPlaybackState.adGroupTimesUs[adGroupIndex]);
if (fakeContentProgressOffsetMs == C.TIME_END_OF_SOURCE) {