From 97e66ef11bb46d06abc4849d3a2adce04ca45ff9 Mon Sep 17 00:00:00 2001 From: tonihei Date: Mon, 23 Jul 2018 03:12:22 -0700 Subject: [PATCH] Update period index in DashMediaPeriod event dispatcher after manifest update. Issue:#4492 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=205636634 --- .../android/exoplayer2/source/dash/DashMediaPeriod.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaPeriod.java b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaPeriod.java index f500a53e10..1070038500 100644 --- a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaPeriod.java +++ b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaPeriod.java @@ -64,7 +64,6 @@ import java.util.List; private final DashChunkSource.Factory chunkSourceFactory; private final @Nullable TransferListener transferListener; private final int minLoadableRetryCount; - private final EventDispatcher eventDispatcher; private final long elapsedRealtimeOffset; private final LoaderErrorThrower manifestLoaderErrorThrower; private final Allocator allocator; @@ -75,6 +74,7 @@ import java.util.List; private final IdentityHashMap, PlayerTrackEmsgHandler> trackEmsgHandlerBySampleStream; + private EventDispatcher eventDispatcher; private @Nullable Callback callback; private ChunkSampleStream[] sampleStreams; private EventSampleStream[] eventSampleStreams; @@ -131,6 +131,13 @@ import java.util.List; */ public void updateManifest(DashManifest manifest, int periodIndex) { this.manifest = manifest; + if (this.periodIndex != periodIndex) { + eventDispatcher = + eventDispatcher.withParameters( + /* windowIndex= */ 0, + eventDispatcher.mediaPeriodId.copyWithPeriodIndex(periodIndex), + manifest.getPeriod(periodIndex).startMs); + } this.periodIndex = periodIndex; playerEmsgHandler.updateManifest(manifest); if (sampleStreams != null) {