Commit 60555e2c by andrewlewis Committed by Oliver Woodman

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
parent 1439b4a3
...@@ -53,6 +53,9 @@ ...@@ -53,6 +53,9 @@
([#3303](https://github.com/google/ExoPlayer/issues/3303)). ([#3303](https://github.com/google/ExoPlayer/issues/3303)).
* Ignore seeks if an ad is playing * Ignore seeks if an ad is playing
([#3309](https://github.com/google/ExoPlayer/issues/3309)). ([#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: * UI:
* Allow specifying a `Drawable` for the `TimeBar` scrubber * Allow specifying a `Drawable` for the `TimeBar` scrubber
([#3337](https://github.com/google/ExoPlayer/issues/3337)). ([#3337](https://github.com/google/ExoPlayer/issues/3337)).
......
...@@ -260,7 +260,7 @@ public final class ImaAdsLoader extends Player.DefaultEventListener implements A ...@@ -260,7 +260,7 @@ public final class ImaAdsLoader extends Player.DefaultEventListener implements A
@Override @Override
public void detachPlayer() { public void detachPlayer() {
if (adsManager != null && imaPausedContent) { if (adsManager != null && imaPausedContent) {
adPlaybackState.setAdResumePositionUs(C.msToUs(player.getCurrentPosition())); adPlaybackState.setAdResumePositionUs(playingAd ? C.msToUs(player.getCurrentPosition()) : 0);
adsManager.pause(); adsManager.pause();
} }
lastAdProgress = getAdProgress(); lastAdProgress = getAdProgress();
...@@ -628,7 +628,6 @@ public final class ImaAdsLoader extends Player.DefaultEventListener implements A ...@@ -628,7 +628,6 @@ public final class ImaAdsLoader extends Player.DefaultEventListener implements A
if (!wasPlayingAd && playingAd) { if (!wasPlayingAd && playingAd) {
int adGroupIndex = player.getCurrentAdGroupIndex(); int adGroupIndex = player.getCurrentAdGroupIndex();
// IMA hasn't sent CONTENT_PAUSE_REQUESTED yet, so fake the content position. // IMA hasn't sent CONTENT_PAUSE_REQUESTED yet, so fake the content position.
Assertions.checkState(fakeContentProgressElapsedRealtimeMs == C.TIME_UNSET);
fakeContentProgressElapsedRealtimeMs = SystemClock.elapsedRealtime(); fakeContentProgressElapsedRealtimeMs = SystemClock.elapsedRealtime();
fakeContentProgressOffsetMs = C.usToMs(adPlaybackState.adGroupTimesUs[adGroupIndex]); fakeContentProgressOffsetMs = C.usToMs(adPlaybackState.adGroupTimesUs[adGroupIndex]);
if (fakeContentProgressOffsetMs == C.TIME_END_OF_SOURCE) { if (fakeContentProgressOffsetMs == C.TIME_END_OF_SOURCE) {
......
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