Fix EPI.seekTo to balance operation acks when seeking during an ad

This regression was introduced in
b1e9257de1

Issue: #8349

#minor-release

PiperOrigin-RevId: 347802049
This commit is contained in:
ibaker 2020-12-16 13:06:31 +00:00 committed by Christos Tsilopoulos
parent f11a9cdf71
commit abff5168f4
3 changed files with 42 additions and 2 deletions

View File

@ -25,6 +25,8 @@
getters.
* Deprecate `HttpDataSource.Factory.getDefaultRequestProperties` and add
`HttpDataSource.Factory.setDefaultRequestProperties` instead.
* Fix playback issues after seeking during an ad
([#8349](https://github.com/google/ExoPlayer/issues/8349))
* Track selection:
* Add option to specify multiple preferred audio or text languages.
* Forward `Timeline` and `MediaPeriodId` to `TrackSelection.Factory`.

View File

@ -613,8 +613,10 @@ import java.util.concurrent.TimeoutException;
// general because the midroll ad preceding the seek destination must be played before the
// content position can be played, if a different ad is playing at the moment.
Log.w(TAG, "seekTo ignored because an ad is playing");
playbackInfoUpdateListener.onPlaybackInfoUpdate(
new ExoPlayerImplInternal.PlaybackInfoUpdate(playbackInfo));
ExoPlayerImplInternal.PlaybackInfoUpdate playbackInfoUpdate =
new ExoPlayerImplInternal.PlaybackInfoUpdate(this.playbackInfo);
playbackInfoUpdate.incrementPendingOperationAcks(1);
playbackInfoUpdateListener.onPlaybackInfoUpdate(playbackInfoUpdate);
return;
}
@Player.State

View File

@ -4490,6 +4490,42 @@ public final class ExoPlayerTest {
assertThat(totalBufferedDurationMs[1]).isEqualTo(adDurationMs);
}
// https://github.com/google/ExoPlayer/issues/8349
@Test
public void seekTo_whilePlayingAd_doesntBlockFutureUpdates() throws Exception {
long contentDurationMs = 10_000;
long adDurationMs = 4_000;
AdPlaybackState adPlaybackState =
new AdPlaybackState(/* adsId= */ new Object(), /* adGroupTimesUs...= */ 0)
.withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 1)
.withAdUri(/* adGroupIndex= */ 0, /* adIndexInAdGroup= */ 0, Uri.EMPTY);
long[][] durationsUs = new long[1][];
durationsUs[0] = new long[] {C.msToUs(adDurationMs)};
adPlaybackState = adPlaybackState.withAdDurationsUs(durationsUs);
Timeline adTimeline =
new FakeTimeline(
new TimelineWindowDefinition(
/* periodCount= */ 1,
/* id= */ 0,
/* isSeekable= */ true,
/* isDynamic= */ false,
/* durationUs= */ C.msToUs(contentDurationMs),
adPlaybackState));
FakeMediaSource adsMediaSource = new FakeMediaSource(adTimeline);
SimpleExoPlayer player = new TestExoPlayerBuilder(context).build();
player.setMediaSource(adsMediaSource);
player.pause();
player.prepare();
runUntilPlaybackState(player, Player.STATE_READY);
player.seekTo(0, 8000);
player.play();
// This times out if playback info updates after the seek are blocked.
runUntilPlaybackState(player, Player.STATE_ENDED);
}
@Test
public void becomingNoisyIgnoredIfBecomingNoisyHandlingIsDisabled() throws Exception {
CountDownLatch becomingNoisyHandlingDisabled = new CountDownLatch(1);