diff --git a/library/common/src/main/java/com/google/android/exoplayer2/Timeline.java b/library/common/src/main/java/com/google/android/exoplayer2/Timeline.java index 93d57119a1..79d21ab048 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/Timeline.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/Timeline.java @@ -613,7 +613,14 @@ public abstract class Timeline implements Bundleable { int windowIndex, long durationUs, long positionInWindowUs) { - return set(id, uid, windowIndex, durationUs, positionInWindowUs, AdPlaybackState.NONE); + return set( + id, + uid, + windowIndex, + durationUs, + positionInWindowUs, + AdPlaybackState.NONE, + /* isPlaceholder= */ false); } /** @@ -631,6 +638,8 @@ public abstract class Timeline implements Bundleable { * period is not within the window. * @param adPlaybackState The state of the period's ads, or {@link AdPlaybackState#NONE} if * there are no ads. + * @param isPlaceholder Whether this period contains placeholder information because the real + * information has yet to be loaded. * @return This period, for convenience. */ public Period set( @@ -639,14 +648,15 @@ public abstract class Timeline implements Bundleable { int windowIndex, long durationUs, long positionInWindowUs, - AdPlaybackState adPlaybackState) { + AdPlaybackState adPlaybackState, + boolean isPlaceholder) { this.id = id; this.uid = uid; this.windowIndex = windowIndex; this.durationUs = durationUs; this.positionInWindowUs = positionInWindowUs; this.adPlaybackState = adPlaybackState; - this.isPlaceholder = false; + this.isPlaceholder = isPlaceholder; return this; } @@ -890,8 +900,8 @@ public abstract class Timeline implements Bundleable { windowIndex, durationUs, positionInWindowUs, - adPlaybackState); - period.isPlaceholder = isPlaceholder; + adPlaybackState, + isPlaceholder); return period; } @@ -1469,8 +1479,14 @@ public abstract class Timeline implements Bundleable { @Override public Period getPeriod(int periodIndex, Period period, boolean ignoredSetIds) { Period p = periods.get(periodIndex); - period.set(p.id, p.uid, p.windowIndex, p.durationUs, p.positionInWindowUs, p.adPlaybackState); - period.isPlaceholder = p.isPlaceholder; + period.set( + p.id, + p.uid, + p.windowIndex, + p.durationUs, + p.positionInWindowUs, + p.adPlaybackState, + p.isPlaceholder); return period; } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/MaskingMediaSource.java b/library/core/src/main/java/com/google/android/exoplayer2/source/MaskingMediaSource.java index 0f55b39cb6..e7c27ba95e 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/MaskingMediaSource.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/MaskingMediaSource.java @@ -24,6 +24,7 @@ import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.MediaItem; import com.google.android.exoplayer2.Timeline; import com.google.android.exoplayer2.Timeline.Window; +import com.google.android.exoplayer2.source.ads.AdPlaybackState; import com.google.android.exoplayer2.upstream.Allocator; import com.google.android.exoplayer2.upstream.TransferListener; import com.google.android.exoplayer2.util.Assertions; @@ -400,8 +401,9 @@ public final class MaskingMediaSource extends CompositeMediaSource { /* uid= */ setIds ? MaskingTimeline.MASKING_EXTERNAL_PERIOD_UID : null, /* windowIndex= */ 0, /* durationUs = */ C.TIME_UNSET, - /* positionInWindowUs= */ 0); - period.isPlaceholder = true; + /* positionInWindowUs= */ 0, + /* adPlaybackState= */ AdPlaybackState.NONE, + /* isPlaceholder= */ true); return period; } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/ads/SinglePeriodAdTimeline.java b/library/core/src/main/java/com/google/android/exoplayer2/source/ads/SinglePeriodAdTimeline.java index 9c3dd042b4..a114bd92d9 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/ads/SinglePeriodAdTimeline.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/ads/SinglePeriodAdTimeline.java @@ -52,7 +52,8 @@ public final class SinglePeriodAdTimeline extends ForwardingTimeline { period.windowIndex, durationUs, period.getPositionInWindowUs(), - adPlaybackState); + adPlaybackState, + period.isPlaceholder); return period; } } diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeTimeline.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeTimeline.java index dc192e9f41..6bd498e199 100644 --- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeTimeline.java +++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeTimeline.java @@ -414,8 +414,8 @@ public final class FakeTimeline extends Timeline { windowIndex, periodDurationUs, positionInWindowUs, - windowDefinition.adPlaybackState); - period.isPlaceholder = windowDefinition.isPlaceholder; + windowDefinition.adPlaybackState, + windowDefinition.isPlaceholder); return period; }