Migrate usages of Timeline#getPeriodPosition to getPeriodPositionUs

#minor-release

PiperOrigin-RevId: 414671861
This commit is contained in:
ibaker 2021-12-07 11:23:22 +00:00 committed by Ian Baker
parent 97294f0693
commit 0b09ac5bb0
7 changed files with 124 additions and 95 deletions

View File

@ -1201,13 +1201,13 @@ public abstract class Timeline implements Bundleable {
}
/**
* Calls {@link #getPeriodPosition(Window, Period, int, long, long)} with a zero default position
* Calls {@link #getPeriodPositionUs(Window, Period, int, long)} with a zero default position
* projection.
*/
public final Pair<Object, Long> getPeriodPositionUs(
Window window, Period period, int windowIndex, long windowPositionUs) {
return Assertions.checkNotNull(
getPeriodPosition(
getPeriodPositionUs(
window, period, windowIndex, windowPositionUs, /* defaultPositionProjectionUs= */ 0));
}

View File

@ -510,7 +510,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
maskTimelineAndPosition(
playbackInfo,
newTimeline,
getPeriodPositionAfterTimelineChanged(oldTimeline, newTimeline));
getPeriodPositionUsAfterTimelineChanged(oldTimeline, newTimeline));
internalPlayer.addMediaSources(index, holders, shuffleOrder);
updatePlaybackInfo(
newPlaybackInfo,
@ -554,7 +554,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
maskTimelineAndPosition(
playbackInfo,
newTimeline,
getPeriodPositionAfterTimelineChanged(oldTimeline, newTimeline));
getPeriodPositionUsAfterTimelineChanged(oldTimeline, newTimeline));
internalPlayer.moveMediaSources(fromIndex, toIndex, newFromIndex, shuffleOrder);
updatePlaybackInfo(
newPlaybackInfo,
@ -573,7 +573,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
maskTimelineAndPosition(
playbackInfo,
timeline,
getPeriodPositionOrMaskWindowPosition(
maskWindowPositionMsOrGetPeriodPositionUs(
timeline, getCurrentMediaItemIndex(), getCurrentPosition()));
pendingOperationAcks++;
this.shuffleOrder = shuffleOrder;
@ -691,7 +691,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
maskTimelineAndPosition(
newPlaybackInfo,
timeline,
getPeriodPositionOrMaskWindowPosition(timeline, mediaItemIndex, positionMs));
maskWindowPositionMsOrGetPeriodPositionUs(timeline, mediaItemIndex, positionMs));
internalPlayer.seekTo(timeline, mediaItemIndex, Util.msToUs(positionMs));
updatePlaybackInfo(
newPlaybackInfo,
@ -1452,7 +1452,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
maskTimelineAndPosition(
playbackInfo,
timeline,
getPeriodPositionOrMaskWindowPosition(timeline, startWindowIndex, startPositionMs));
maskWindowPositionMsOrGetPeriodPositionUs(timeline, startWindowIndex, startPositionMs));
// Mask the playback state.
int maskingPlaybackState = newPlaybackInfo.playbackState;
if (startWindowIndex != C.INDEX_UNSET && newPlaybackInfo.playbackState != STATE_IDLE) {
@ -1510,7 +1510,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
maskTimelineAndPosition(
playbackInfo,
newTimeline,
getPeriodPositionAfterTimelineChanged(oldTimeline, newTimeline));
getPeriodPositionUsAfterTimelineChanged(oldTimeline, newTimeline));
// Player transitions to STATE_ENDED if the current index is part of the removed tail.
final boolean transitionsToEnded =
newPlaybackInfo.playbackState != STATE_IDLE
@ -1537,8 +1537,8 @@ import java.util.concurrent.CopyOnWriteArraySet;
}
private PlaybackInfo maskTimelineAndPosition(
PlaybackInfo playbackInfo, Timeline timeline, @Nullable Pair<Object, Long> periodPosition) {
Assertions.checkArgument(timeline.isEmpty() || periodPosition != null);
PlaybackInfo playbackInfo, Timeline timeline, @Nullable Pair<Object, Long> periodPositionUs) {
Assertions.checkArgument(timeline.isEmpty() || periodPositionUs != null);
Timeline oldTimeline = playbackInfo.timeline;
// Mask the timeline.
playbackInfo = playbackInfo.copyWithTimeline(timeline);
@ -1563,10 +1563,10 @@ import java.util.concurrent.CopyOnWriteArraySet;
}
Object oldPeriodUid = playbackInfo.periodId.periodUid;
boolean playingPeriodChanged = !oldPeriodUid.equals(castNonNull(periodPosition).first);
boolean playingPeriodChanged = !oldPeriodUid.equals(castNonNull(periodPositionUs).first);
MediaPeriodId newPeriodId =
playingPeriodChanged ? new MediaPeriodId(periodPosition.first) : playbackInfo.periodId;
long newContentPositionUs = periodPosition.second;
playingPeriodChanged ? new MediaPeriodId(periodPositionUs.first) : playbackInfo.periodId;
long newContentPositionUs = periodPositionUs.second;
long oldContentPositionUs = Util.msToUs(getContentPosition());
if (!oldTimeline.isEmpty()) {
oldContentPositionUs -=
@ -1642,25 +1642,25 @@ import java.util.concurrent.CopyOnWriteArraySet;
}
@Nullable
private Pair<Object, Long> getPeriodPositionAfterTimelineChanged(
private Pair<Object, Long> getPeriodPositionUsAfterTimelineChanged(
Timeline oldTimeline, Timeline newTimeline) {
long currentPositionMs = getContentPosition();
if (oldTimeline.isEmpty() || newTimeline.isEmpty()) {
boolean isCleared = !oldTimeline.isEmpty() && newTimeline.isEmpty();
return getPeriodPositionOrMaskWindowPosition(
return maskWindowPositionMsOrGetPeriodPositionUs(
newTimeline,
isCleared ? C.INDEX_UNSET : getCurrentWindowIndexInternal(),
isCleared ? C.TIME_UNSET : currentPositionMs);
}
int currentMediaItemIndex = getCurrentMediaItemIndex();
@Nullable
Pair<Object, Long> oldPeriodPosition =
oldTimeline.getPeriodPosition(
Pair<Object, Long> oldPeriodPositionUs =
oldTimeline.getPeriodPositionUs(
window, period, currentMediaItemIndex, Util.msToUs(currentPositionMs));
Object periodUid = castNonNull(oldPeriodPosition).first;
Object periodUid = castNonNull(oldPeriodPositionUs).first;
if (newTimeline.getIndexOfPeriod(periodUid) != C.INDEX_UNSET) {
// The old period position is still available in the new timeline.
return oldPeriodPosition;
return oldPeriodPositionUs;
}
// Period uid not found in new timeline. Try to get subsequent period.
@Nullable
@ -1670,19 +1670,19 @@ import java.util.concurrent.CopyOnWriteArraySet;
if (nextPeriodUid != null) {
// Reset position to the default position of the window of the subsequent period.
newTimeline.getPeriodByUid(nextPeriodUid, period);
return getPeriodPositionOrMaskWindowPosition(
return maskWindowPositionMsOrGetPeriodPositionUs(
newTimeline,
period.windowIndex,
newTimeline.getWindow(period.windowIndex, window).getDefaultPositionMs());
} else {
// No subsequent period found and the new timeline is not empty. Use the default position.
return getPeriodPositionOrMaskWindowPosition(
return maskWindowPositionMsOrGetPeriodPositionUs(
newTimeline, /* windowIndex= */ C.INDEX_UNSET, /* windowPositionMs= */ C.TIME_UNSET);
}
}
@Nullable
private Pair<Object, Long> getPeriodPositionOrMaskWindowPosition(
private Pair<Object, Long> maskWindowPositionMsOrGetPeriodPositionUs(
Timeline timeline, int windowIndex, long windowPositionMs) {
if (timeline.isEmpty()) {
// If empty we store the initial seek in the masking variables.
@ -1697,7 +1697,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
windowIndex = timeline.getFirstWindowIndex(shuffleModeEnabled);
windowPositionMs = timeline.getWindow(windowIndex, window).getDefaultPositionMs();
}
return timeline.getPeriodPosition(window, period, windowIndex, Util.msToUs(windowPositionMs));
return timeline.getPeriodPositionUs(window, period, windowIndex, Util.msToUs(windowPositionMs));
}
private long periodPositionUsToWindowPositionUs(

View File

@ -1131,7 +1131,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
boolean seekPositionAdjusted;
@Nullable
Pair<Object, Long> resolvedSeekPosition =
resolveSeekPosition(
resolveSeekPositionUs(
playbackInfo.timeline,
seekPosition,
/* trySubsequentPeriods= */ true,
@ -1142,10 +1142,10 @@ import java.util.concurrent.atomic.AtomicBoolean;
if (resolvedSeekPosition == null) {
// The seek position was valid for the timeline that it was performed into, but the
// timeline has changed or is not ready and a suitable seek position could not be resolved.
Pair<MediaPeriodId, Long> firstPeriodAndPosition =
getPlaceholderFirstMediaPeriodPosition(playbackInfo.timeline);
periodId = firstPeriodAndPosition.first;
periodPositionUs = firstPeriodAndPosition.second;
Pair<MediaPeriodId, Long> firstPeriodAndPositionUs =
getPlaceholderFirstMediaPeriodPositionUs(playbackInfo.timeline);
periodId = firstPeriodAndPositionUs.first;
periodPositionUs = firstPeriodAndPositionUs.second;
requestedContentPositionUs = C.TIME_UNSET;
seekPositionAdjusted = !playbackInfo.timeline.isEmpty();
} else {
@ -1420,10 +1420,10 @@ import java.util.concurrent.atomic.AtomicBoolean;
boolean resetTrackInfo = false;
if (resetPosition) {
pendingInitialSeekPosition = null;
Pair<MediaPeriodId, Long> firstPeriodAndPosition =
getPlaceholderFirstMediaPeriodPosition(playbackInfo.timeline);
mediaPeriodId = firstPeriodAndPosition.first;
startPositionUs = firstPeriodAndPosition.second;
Pair<MediaPeriodId, Long> firstPeriodAndPositionUs =
getPlaceholderFirstMediaPeriodPositionUs(playbackInfo.timeline);
mediaPeriodId = firstPeriodAndPositionUs.first;
startPositionUs = firstPeriodAndPositionUs.second;
requestedContentPositionUs = C.TIME_UNSET;
if (!mediaPeriodId.equals(playbackInfo.periodId)) {
resetTrackInfo = true;
@ -1459,19 +1459,19 @@ import java.util.concurrent.atomic.AtomicBoolean;
}
}
private Pair<MediaPeriodId, Long> getPlaceholderFirstMediaPeriodPosition(Timeline timeline) {
private Pair<MediaPeriodId, Long> getPlaceholderFirstMediaPeriodPositionUs(Timeline timeline) {
if (timeline.isEmpty()) {
return Pair.create(PlaybackInfo.getDummyPeriodForEmptyTimeline(), 0L);
}
int firstWindowIndex = timeline.getFirstWindowIndex(shuffleModeEnabled);
Pair<Object, Long> firstPeriodAndPosition =
timeline.getPeriodPosition(
Pair<Object, Long> firstPeriodAndPositionUs =
timeline.getPeriodPositionUs(
window, period, firstWindowIndex, /* windowPositionUs= */ C.TIME_UNSET);
// Add ad metadata if any and propagate the window sequence number to new period id.
MediaPeriodId firstPeriodId =
queue.resolveMediaPeriodIdForAds(
timeline, firstPeriodAndPosition.first, /* positionUs= */ 0);
long positionUs = firstPeriodAndPosition.second;
timeline, firstPeriodAndPositionUs.first, /* positionUs= */ 0);
long positionUs = firstPeriodAndPositionUs.second;
if (firstPeriodId.isAd()) {
timeline.getPeriodByUid(firstPeriodId.periodUid, period);
positionUs =
@ -2551,7 +2551,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
// Resolve initial seek position.
@Nullable
Pair<Object, Long> periodPosition =
resolveSeekPosition(
resolveSeekPositionUs(
timeline,
pendingInitialSeekPosition,
/* trySubsequentPeriods= */ true,
@ -2616,10 +2616,10 @@ import java.util.concurrent.atomic.AtomicBoolean;
// at position 0 and don't need to be resolved.
long windowPositionUs = oldContentPositionUs + period.getPositionInWindowUs();
int windowIndex = timeline.getPeriodByUid(newPeriodUid, period).windowIndex;
Pair<Object, Long> periodPosition =
timeline.getPeriodPosition(window, period, windowIndex, windowPositionUs);
newPeriodUid = periodPosition.first;
newContentPositionUs = periodPosition.second;
Pair<Object, Long> periodPositionUs =
timeline.getPeriodPositionUs(window, period, windowIndex, windowPositionUs);
newPeriodUid = periodPositionUs.first;
newContentPositionUs = periodPositionUs.second;
}
// Use an explicitly requested content position as new target live offset.
setTargetLiveOffset = true;
@ -2628,14 +2628,14 @@ import java.util.concurrent.atomic.AtomicBoolean;
// Set period uid for default positions and resolve position for ad resolution.
long contentPositionForAdResolutionUs = newContentPositionUs;
if (startAtDefaultPositionWindowIndex != C.INDEX_UNSET) {
Pair<Object, Long> defaultPosition =
timeline.getPeriodPosition(
Pair<Object, Long> defaultPositionUs =
timeline.getPeriodPositionUs(
window,
period,
startAtDefaultPositionWindowIndex,
/* windowPositionUs= */ C.TIME_UNSET);
newPeriodUid = defaultPosition.first;
contentPositionForAdResolutionUs = defaultPosition.second;
newPeriodUid = defaultPositionUs.first;
contentPositionForAdResolutionUs = defaultPositionUs.second;
newContentPositionUs = C.TIME_UNSET;
}
@ -2749,7 +2749,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
: Util.msToUs(pendingMessageInfo.message.getPositionMs());
@Nullable
Pair<Object, Long> periodPosition =
resolveSeekPosition(
resolveSeekPositionUs(
newTimeline,
new SeekPosition(
pendingMessageInfo.message.getTimeline(),
@ -2794,12 +2794,12 @@ import java.util.concurrent.atomic.AtomicBoolean;
pendingMessageInfo.resolvedPeriodTimeUs + period.getPositionInWindowUs();
int windowIndex =
newTimeline.getPeriodByUid(pendingMessageInfo.resolvedPeriodUid, period).windowIndex;
Pair<Object, Long> periodPosition =
newTimeline.getPeriodPosition(window, period, windowIndex, windowPositionUs);
Pair<Object, Long> periodPositionUs =
newTimeline.getPeriodPositionUs(window, period, windowIndex, windowPositionUs);
pendingMessageInfo.setResolvedPosition(
/* periodIndex= */ newTimeline.getIndexOfPeriod(periodPosition.first),
/* periodTimeUs= */ periodPosition.second,
/* periodUid= */ periodPosition.first);
/* periodIndex= */ newTimeline.getIndexOfPeriod(periodPositionUs.first),
/* periodTimeUs= */ periodPositionUs.second,
/* periodUid= */ periodPositionUs.first);
}
return true;
}
@ -2828,7 +2828,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
* bounds of the timeline.
*/
@Nullable
private static Pair<Object, Long> resolveSeekPosition(
private static Pair<Object, Long> resolveSeekPositionUs(
Timeline timeline,
SeekPosition seekPosition,
boolean trySubsequentPeriods,
@ -2847,10 +2847,10 @@ import java.util.concurrent.atomic.AtomicBoolean;
seekTimeline = timeline;
}
// Map the SeekPosition to a position in the corresponding timeline.
Pair<Object, Long> periodPosition;
Pair<Object, Long> periodPositionUs;
try {
periodPosition =
seekTimeline.getPeriodPosition(
periodPositionUs =
seekTimeline.getPeriodPositionUs(
window, period, seekPosition.windowIndex, seekPosition.windowPositionUs);
} catch (IndexOutOfBoundsException e) {
// The window index of the seek position was outside the bounds of the timeline.
@ -2858,24 +2858,24 @@ import java.util.concurrent.atomic.AtomicBoolean;
}
if (timeline.equals(seekTimeline)) {
// Our internal timeline is the seek timeline, so the mapped position is correct.
return periodPosition;
return periodPositionUs;
}
// Attempt to find the mapped period in the internal timeline.
int periodIndex = timeline.getIndexOfPeriod(periodPosition.first);
int periodIndex = timeline.getIndexOfPeriod(periodPositionUs.first);
if (periodIndex != C.INDEX_UNSET) {
// We successfully located the period in the internal timeline.
if (seekTimeline.getPeriodByUid(periodPosition.first, period).isPlaceholder
if (seekTimeline.getPeriodByUid(periodPositionUs.first, period).isPlaceholder
&& seekTimeline.getWindow(period.windowIndex, window).firstPeriodIndex
== seekTimeline.getIndexOfPeriod(periodPosition.first)) {
== seekTimeline.getIndexOfPeriod(periodPositionUs.first)) {
// The seek timeline was using a placeholder, so we need to re-resolve using the updated
// timeline in case the resolved position changed. Only resolve the first period in a window
// because subsequent periods must start at position 0 and don't need to be resolved.
int newWindowIndex = timeline.getPeriodByUid(periodPosition.first, period).windowIndex;
periodPosition =
timeline.getPeriodPosition(
int newWindowIndex = timeline.getPeriodByUid(periodPositionUs.first, period).windowIndex;
periodPositionUs =
timeline.getPeriodPositionUs(
window, period, newWindowIndex, seekPosition.windowPositionUs);
}
return periodPosition;
return periodPositionUs;
}
if (trySubsequentPeriods) {
// Try and find a subsequent period from the seek timeline in the internal timeline.
@ -2886,12 +2886,12 @@ import java.util.concurrent.atomic.AtomicBoolean;
period,
repeatMode,
shuffleModeEnabled,
periodPosition.first,
periodPositionUs.first,
seekTimeline,
timeline);
if (periodUid != null) {
// We found one. Use the default position of the corresponding window.
return timeline.getPeriodPosition(
return timeline.getPeriodPositionUs(
window,
period,
timeline.getPeriodByUid(periodUid, period).windowIndex,

View File

@ -663,18 +663,18 @@ import com.google.common.collect.ImmutableList;
// forward by the duration of the buffer, and start buffering from this point.
contentPositionUs = C.TIME_UNSET;
@Nullable
Pair<Object, Long> defaultPosition =
timeline.getPeriodPosition(
Pair<Object, Long> defaultPositionUs =
timeline.getPeriodPositionUs(
window,
period,
nextWindowIndex,
/* windowPositionUs= */ C.TIME_UNSET,
/* defaultPositionProjectionUs= */ max(0, bufferedDurationUs));
if (defaultPosition == null) {
if (defaultPositionUs == null) {
return null;
}
nextPeriodUid = defaultPosition.first;
startPositionUs = defaultPosition.second;
nextPeriodUid = defaultPositionUs.first;
startPositionUs = defaultPositionUs.second;
MediaPeriodHolder nextMediaPeriodHolder = mediaPeriodHolder.getNext();
if (nextMediaPeriodHolder != null && nextMediaPeriodHolder.uid.equals(nextPeriodUid)) {
windowSequenceNumber = nextMediaPeriodHolder.info.id.windowSequenceNumber;
@ -718,17 +718,17 @@ import com.google.common.collect.ImmutableList;
// If we're transitioning from an ad group to content starting from its default position,
// project the start position forward as if this were a transition to a new window.
@Nullable
Pair<Object, Long> defaultPosition =
timeline.getPeriodPosition(
Pair<Object, Long> defaultPositionUs =
timeline.getPeriodPositionUs(
window,
period,
period.windowIndex,
/* windowPositionUs= */ C.TIME_UNSET,
/* defaultPositionProjectionUs= */ max(0, bufferedDurationUs));
if (defaultPosition == null) {
if (defaultPositionUs == null) {
return null;
}
startPositionUs = defaultPosition.second;
startPositionUs = defaultPositionUs.second;
}
long minStartPositionUs =
getMinStartPositionAfterAdGroupUs(

View File

@ -181,11 +181,11 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> {
windowStartPositionUs = windowPreparePositionUs;
}
}
Pair<Object, Long> periodPosition =
newTimeline.getPeriodPosition(
Pair<Object, Long> periodUidAndPositionUs =
newTimeline.getPeriodPositionUs(
window, period, /* windowIndex= */ 0, windowStartPositionUs);
Object periodUid = periodPosition.first;
long periodPositionUs = periodPosition.second;
Object periodUid = periodUidAndPositionUs.first;
long periodPositionUs = periodUidAndPositionUs.second;
timeline =
hasRealTimeline
? timeline.cloneWithUpdatedTimeline(newTimeline)

View File

@ -45,19 +45,31 @@ public final class SinglePeriodTimelineTest {
public void getPeriodPositionDynamicWindowUnknownDuration() {
SinglePeriodTimeline timeline =
new SinglePeriodTimeline(
C.TIME_UNSET,
/* durationUs= */ C.TIME_UNSET,
/* isSeekable= */ false,
/* isDynamic= */ true,
/* isLive= */ true,
/* manifest= */ null,
MediaItem.fromUri(Uri.EMPTY));
// Should return null with any positive position projection.
Pair<Object, Long> position = timeline.getPeriodPosition(window, period, 0, C.TIME_UNSET, 1);
assertThat(position).isNull();
Pair<Object, Long> positionUs =
timeline.getPeriodPositionUs(
window,
period,
/* windowIndex= */ 0,
/* windowPositionUs= */ C.TIME_UNSET,
/* defaultPositionProjectionUs= */ 1);
assertThat(positionUs).isNull();
// Should return (0, 0) without a position projection.
position = timeline.getPeriodPosition(window, period, 0, C.TIME_UNSET, 0);
assertThat(position.first).isEqualTo(timeline.getUidOfPeriod(0));
assertThat(position.second).isEqualTo(0);
positionUs =
timeline.getPeriodPositionUs(
window,
period,
/* windowIndex= */ 0,
/* windowPositionUs= */ C.TIME_UNSET,
/* defaultPositionProjectionUs= */ 0);
assertThat(positionUs.first).isEqualTo(timeline.getUidOfPeriod(0));
assertThat(positionUs.second).isEqualTo(0);
}
@Test
@ -75,17 +87,34 @@ public final class SinglePeriodTimelineTest {
/* manifest= */ null,
MediaItem.fromUri(Uri.EMPTY));
// Should return null with a positive position projection beyond window duration.
Pair<Object, Long> position =
timeline.getPeriodPosition(window, period, 0, C.TIME_UNSET, windowDurationUs + 1);
assertThat(position).isNull();
Pair<Object, Long> positionUs =
timeline.getPeriodPositionUs(
window,
period,
/* windowIndex= */ 0,
/* windowPositionUs= */ C.TIME_UNSET,
/* defaultPositionProjectionUs= */ windowDurationUs + 1);
assertThat(positionUs).isNull();
// Should return (0, duration) with a projection equal to window duration.
position = timeline.getPeriodPosition(window, period, 0, C.TIME_UNSET, windowDurationUs - 1);
assertThat(position.first).isEqualTo(timeline.getUidOfPeriod(0));
assertThat(position.second).isEqualTo(windowDurationUs - 1);
positionUs =
timeline.getPeriodPositionUs(
window,
period,
/* windowIndex= */ 0,
/* windowPositionUs= */ C.TIME_UNSET,
/* defaultPositionProjectionUs= */ windowDurationUs - 1);
assertThat(positionUs.first).isEqualTo(timeline.getUidOfPeriod(0));
assertThat(positionUs.second).isEqualTo(windowDurationUs - 1);
// Should return (0, 0) without a position projection.
position = timeline.getPeriodPosition(window, period, 0, C.TIME_UNSET, 0);
assertThat(position.first).isEqualTo(timeline.getUidOfPeriod(0));
assertThat(position.second).isEqualTo(0);
positionUs =
timeline.getPeriodPositionUs(
window,
period,
/* windowIndex= */ 0,
/* windowPositionUs= */ C.TIME_UNSET,
/* defaultPositionProjectionUs= */ 0);
assertThat(positionUs.first).isEqualTo(timeline.getUidOfPeriod(0));
assertThat(positionUs.second).isEqualTo(0);
}
@Test

View File

@ -702,7 +702,7 @@ public final class ImaAdsLoader implements Player.Listener, AdsLoader {
return;
}
long periodPositionUs =
timeline.getPeriodPosition(
timeline.getPeriodPositionUs(
window, period, period.windowIndex, /* windowPositionUs= */ C.TIME_UNSET)
.second;
nextAdTagLoader.maybePreloadAds(Util.usToMs(periodPositionUs), Util.usToMs(period.durationUs));