use of com.google.android.exoplayer2.ExoPlayer in project ExoPlayer by google.
the class ExoPlayerTest method setMediaSources_whenPrepared_correctMaskingPlaybackState.
@Test
public void setMediaSources_whenPrepared_correctMaskingPlaybackState() throws Exception {
Timeline firstTimeline = new FakeTimeline(/* windowCount= */
1, 1L);
MediaSource firstMediaSource = new FakeMediaSource(firstTimeline);
Timeline secondTimeline = new FakeTimeline(/* windowCount= */
1, 2L);
MediaSource secondMediaSource = new FakeMediaSource(secondTimeline);
final int[] maskingPlaybackStates = new int[4];
Arrays.fill(maskingPlaybackStates, C.INDEX_UNSET);
ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG).pause().waitForPlaybackState(Player.STATE_READY).executeRunnable(new PlayerRunnable() {
@Override
public void run(ExoPlayer player) {
// Set empty media item with an implicit seek to current position.
player.setMediaSource(new ConcatenatingMediaSource(), /* resetPosition= */
false);
// Expect masking state is ended,
maskingPlaybackStates[0] = player.getPlaybackState();
}
}).waitForPlaybackState(Player.STATE_ENDED).setMediaSources(/* mediaItemIndex= */
0, /* positionMs= */
C.TIME_UNSET, firstMediaSource).waitForPlaybackState(Player.STATE_READY).executeRunnable(new PlayerRunnable() {
@Override
public void run(ExoPlayer player) {
// Set empty media item with an explicit seek.
player.setMediaSource(new ConcatenatingMediaSource(), /* startPositionMs= */
C.TIME_UNSET);
// Expect masking state is ended,
maskingPlaybackStates[1] = player.getPlaybackState();
}
}).waitForPlaybackState(Player.STATE_ENDED).setMediaSources(/* mediaItemIndex= */
0, /* positionMs= */
C.TIME_UNSET, firstMediaSource).waitForPlaybackState(Player.STATE_READY).executeRunnable(new PlayerRunnable() {
@Override
public void run(ExoPlayer player) {
// Set media item with an explicit seek.
player.setMediaSource(secondMediaSource, /* startPositionMs= */
C.TIME_UNSET);
// Expect masking state is buffering,
maskingPlaybackStates[2] = player.getPlaybackState();
}
}).waitForPlaybackState(Player.STATE_READY).setMediaSources(/* mediaItemIndex= */
0, /* positionMs= */
C.TIME_UNSET, firstMediaSource).waitForPlaybackState(Player.STATE_READY).executeRunnable(new PlayerRunnable() {
@Override
public void run(ExoPlayer player) {
// Set media item with an implicit seek to the current position.
player.setMediaSource(secondMediaSource, /* resetPosition= */
false);
// Expect masking state is buffering,
maskingPlaybackStates[3] = player.getPlaybackState();
}
}).play().waitForPlaybackState(Player.STATE_READY).build();
ExoPlayerTestRunner exoPlayerTestRunner = new ExoPlayerTestRunner.Builder(context).setExpectedPlayerEndedCount(/* expectedPlayerEndedCount= */
3).setMediaSources(firstMediaSource).setActionSchedule(actionSchedule).build().start().blockUntilActionScheduleFinished(TIMEOUT_MS).blockUntilEnded(TIMEOUT_MS);
// Expect reset of masking to first media item.
exoPlayerTestRunner.assertPlaybackStatesEqual(Player.STATE_BUFFERING, // Ready after initial prepare.
Player.STATE_READY, // Ended after setting empty source without seek.
Player.STATE_ENDED, Player.STATE_BUFFERING, // Ready again after re-setting source.
Player.STATE_READY, // Ended after setting empty source with seek.
Player.STATE_ENDED, Player.STATE_BUFFERING, // Ready again after re-setting source.
Player.STATE_READY, Player.STATE_BUFFERING, // Ready after setting media item with seek.
Player.STATE_READY, Player.STATE_BUFFERING, // Ready again after re-setting source.
Player.STATE_READY, // Play.
Player.STATE_BUFFERING, // Ready after setting media item without seek.
Player.STATE_READY, Player.STATE_ENDED);
assertArrayEquals(new int[] { Player.STATE_ENDED, Player.STATE_ENDED, Player.STATE_BUFFERING, Player.STATE_BUFFERING }, maskingPlaybackStates);
exoPlayerTestRunner.assertTimelineChangeReasonsEqual(Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED, // Initial source.
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE, // Empty source.
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED, Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED, // Reset source.
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE, // Empty source.
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED, Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED, // Reset source.
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE, Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED, // Set source with seek.
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE, Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED, // Reset source.
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE, Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED, // Set source without seek.
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE);
}
use of com.google.android.exoplayer2.ExoPlayer in project ExoPlayer by google.
the class ExoPlayerTest method seekForward_pastDuration_seeksToDuration.
@Test
public void seekForward_pastDuration_seeksToDuration() throws Exception {
ExoPlayer player = new TestExoPlayerBuilder(context).build();
Timeline fakeTimeline = new FakeTimeline(new TimelineWindowDefinition(/* isSeekable= */
true, /* isDynamic= */
true, /* durationUs= */
Util.msToUs(C.DEFAULT_SEEK_FORWARD_INCREMENT_MS / 2)));
player.setMediaSource(new FakeMediaSource(fakeTimeline));
player.prepare();
TestPlayerRunHelper.runUntilPlaybackState(player, Player.STATE_READY);
player.seekForward();
assertThat(player.getCurrentPosition()).isEqualTo(C.DEFAULT_SEEK_FORWARD_INCREMENT_MS / 2 - 1);
player.release();
}
use of com.google.android.exoplayer2.ExoPlayer in project ExoPlayer by google.
the class DefaultAnalyticsCollectorTest method adPlayback.
@Test
public void adPlayback() throws Exception {
long contentDurationsUs = 11 * C.MICROS_PER_SECOND;
long windowOffsetInFirstPeriodUs = TimelineWindowDefinition.DEFAULT_WINDOW_OFFSET_IN_FIRST_PERIOD_US;
AtomicReference<AdPlaybackState> adPlaybackState = new AtomicReference<>(FakeTimeline.createAdPlaybackState(/* adsPerAdGroup= */
1, /* adGroupTimesUs...= */
windowOffsetInFirstPeriodUs, windowOffsetInFirstPeriodUs + 5 * C.MICROS_PER_SECOND, C.TIME_END_OF_SOURCE));
AtomicInteger playedAdCount = new AtomicInteger(0);
Timeline adTimeline = new FakeTimeline(new TimelineWindowDefinition(/* periodCount= */
1, /* id= */
0, /* isSeekable= */
true, /* isDynamic= */
false, contentDurationsUs, adPlaybackState.get()));
FakeMediaSource fakeMediaSource = new FakeMediaSource(adTimeline, DrmSessionManager.DRM_UNSUPPORTED, (unusedFormat, mediaPeriodId) -> {
if (mediaPeriodId.isAd()) {
return ImmutableList.of(oneByteSample(/* timeUs= */
0, C.BUFFER_FLAG_KEY_FRAME), END_OF_STREAM_ITEM);
} else {
// postroll.
return ImmutableList.of(oneByteSample(windowOffsetInFirstPeriodUs + C.MICROS_PER_SECOND, C.BUFFER_FLAG_KEY_FRAME), oneByteSample(windowOffsetInFirstPeriodUs + 6 * C.MICROS_PER_SECOND, C.BUFFER_FLAG_KEY_FRAME), oneByteSample(windowOffsetInFirstPeriodUs + contentDurationsUs, C.BUFFER_FLAG_KEY_FRAME), END_OF_STREAM_ITEM);
}
}, ExoPlayerTestRunner.VIDEO_FORMAT);
ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG).executeRunnable(new PlayerRunnable() {
@Override
public void run(ExoPlayer player) {
player.addListener(new Player.Listener() {
@Override
public void onPositionDiscontinuity(Player.PositionInfo oldPosition, Player.PositionInfo newPosition, @Player.DiscontinuityReason int reason) {
if (!player.isPlayingAd() && reason == Player.DISCONTINUITY_REASON_AUTO_TRANSITION) {
// Finished playing ad. Marked as played.
adPlaybackState.set(adPlaybackState.get().withPlayedAd(/* adGroupIndex= */
playedAdCount.getAndIncrement(), /* adIndexInAdGroup= */
0));
fakeMediaSource.setNewSourceInfo(new FakeTimeline(new TimelineWindowDefinition(/* periodCount= */
1, /* id= */
0, /* isSeekable= */
true, /* isDynamic= */
false, contentDurationsUs, adPlaybackState.get())), /* sendManifestLoadEvents= */
false);
}
}
});
}
}).pause().waitForIsLoading(true).waitForIsLoading(false).waitForPlaybackState(Player.STATE_READY).playUntilPosition(/* mediaItemIndex= */
0, /* positionMs= */
3_000).waitForPendingPlayerCommands().playUntilPosition(/* mediaItemIndex= */
0, /* positionMs= */
8_000).waitForPendingPlayerCommands().play().waitForPlaybackState(Player.STATE_ENDED).waitForTimelineChanged().build();
TestAnalyticsListener listener = runAnalyticsTest(fakeMediaSource, actionSchedule);
Object periodUid = listener.lastReportedTimeline.getUidOfPeriod(/* periodIndex= */
0);
EventWindowAndPeriodId prerollAd = new EventWindowAndPeriodId(/* windowIndex= */
0, new MediaPeriodId(periodUid, /* adGroupIndex= */
0, /* adIndexInAdGroup= */
0, /* windowSequenceNumber= */
0));
EventWindowAndPeriodId midrollAd = new EventWindowAndPeriodId(/* windowIndex= */
0, new MediaPeriodId(periodUid, /* adGroupIndex= */
1, /* adIndexInAdGroup= */
0, /* windowSequenceNumber= */
0));
EventWindowAndPeriodId postrollAd = new EventWindowAndPeriodId(/* windowIndex= */
0, new MediaPeriodId(periodUid, /* adGroupIndex= */
2, /* adIndexInAdGroup= */
0, /* windowSequenceNumber= */
0));
EventWindowAndPeriodId contentAfterPreroll = new EventWindowAndPeriodId(/* windowIndex= */
0, new MediaPeriodId(periodUid, /* windowSequenceNumber= */
0, /* nextAdGroupIndex= */
1));
EventWindowAndPeriodId contentAfterMidroll = new EventWindowAndPeriodId(/* windowIndex= */
0, new MediaPeriodId(periodUid, /* windowSequenceNumber= */
0, /* nextAdGroupIndex= */
2));
EventWindowAndPeriodId contentAfterPostroll = new EventWindowAndPeriodId(/* windowIndex= */
0, new MediaPeriodId(periodUid, /* windowSequenceNumber= */
0, /* nextAdGroupIndex= */
C.INDEX_UNSET));
assertThat(listener.getEvents(EVENT_PLAYER_STATE_CHANGED)).containsExactly(WINDOW_0, /* setPlayWhenReady=true */
WINDOW_0, /* setPlayWhenReady=false */
WINDOW_0, /* BUFFERING */
prerollAd, /* READY */
prerollAd, /* setPlayWhenReady=true */
contentAfterPreroll, /* setPlayWhenReady=false */
contentAfterPreroll, /* setPlayWhenReady=true */
contentAfterMidroll, /* setPlayWhenReady=false */
contentAfterMidroll, /* setPlayWhenReady=true */
contentAfterPostroll).inOrder();
assertThat(listener.getEvents(EVENT_TIMELINE_CHANGED)).containsExactly(WINDOW_0, /* PLAYLIST_CHANGED */
prerollAd, /* SOURCE_UPDATE (initial) */
contentAfterPreroll, /* SOURCE_UPDATE (played preroll) */
contentAfterMidroll, /* SOURCE_UPDATE (played midroll) */
contentAfterPostroll).inOrder();
assertThat(listener.getEvents(EVENT_POSITION_DISCONTINUITY)).containsExactly(contentAfterPreroll, midrollAd, contentAfterMidroll, postrollAd, contentAfterPostroll).inOrder();
assertThat(listener.getEvents(EVENT_IS_LOADING_CHANGED)).containsExactly(prerollAd, prerollAd).inOrder();
assertThat(listener.getEvents(EVENT_TRACKS_CHANGED)).containsExactly(prerollAd, contentAfterPreroll, midrollAd, contentAfterMidroll, postrollAd, contentAfterPostroll).inOrder();
assertThat(listener.getEvents(EVENT_LOAD_STARTED)).containsExactly(WINDOW_0, /* content manifest */
prerollAd, contentAfterPreroll, midrollAd, contentAfterMidroll, postrollAd, contentAfterPostroll).inOrder();
assertThat(listener.getEvents(EVENT_LOAD_COMPLETED)).containsExactly(WINDOW_0, /* content manifest */
prerollAd, contentAfterPreroll, midrollAd, contentAfterMidroll, postrollAd, contentAfterPostroll).inOrder();
assertThat(listener.getEvents(EVENT_DOWNSTREAM_FORMAT_CHANGED)).containsExactly(prerollAd, contentAfterPreroll, midrollAd, contentAfterMidroll, postrollAd, contentAfterPostroll).inOrder();
assertThat(listener.getEvents(EVENT_DECODER_ENABLED)).containsExactly(prerollAd);
assertThat(listener.getEvents(EVENT_DECODER_INIT)).containsExactly(prerollAd, contentAfterPreroll, midrollAd, contentAfterMidroll, postrollAd, contentAfterPostroll).inOrder();
assertThat(listener.getEvents(EVENT_DECODER_FORMAT_CHANGED)).containsExactly(prerollAd, contentAfterPreroll, midrollAd, contentAfterMidroll, postrollAd, contentAfterPostroll).inOrder();
assertThat(listener.getEvents(EVENT_VIDEO_ENABLED)).containsExactly(prerollAd);
assertThat(listener.getEvents(EVENT_VIDEO_DECODER_INITIALIZED)).containsExactly(prerollAd, contentAfterPreroll, midrollAd, contentAfterMidroll, postrollAd, contentAfterPostroll).inOrder();
assertThat(listener.getEvents(EVENT_VIDEO_INPUT_FORMAT_CHANGED)).containsExactly(prerollAd, contentAfterPreroll, midrollAd, contentAfterMidroll, postrollAd, contentAfterPostroll).inOrder();
assertThat(listener.getEvents(EVENT_DROPPED_VIDEO_FRAMES)).containsExactly(contentAfterPreroll, contentAfterMidroll, contentAfterPostroll).inOrder();
assertThat(listener.getEvents(EVENT_VIDEO_SIZE_CHANGED)).containsExactly(prerollAd, contentAfterPreroll, midrollAd, contentAfterMidroll, postrollAd, contentAfterPostroll).inOrder();
assertThat(listener.getEvents(EVENT_RENDERED_FIRST_FRAME)).containsExactly(prerollAd, contentAfterPreroll, midrollAd, contentAfterMidroll, postrollAd, contentAfterPostroll).inOrder();
assertThat(listener.getEvents(EVENT_VIDEO_FRAME_PROCESSING_OFFSET)).containsExactly(contentAfterPreroll, contentAfterMidroll, contentAfterPostroll).inOrder();
listener.assertNoMoreEvents();
}
use of com.google.android.exoplayer2.ExoPlayer in project ExoPlayer by google.
the class DefaultAnalyticsCollectorTest method release_withCallbacksArrivingAfterRelease_onPlayerReleasedForwardedLast.
@Test
public void release_withCallbacksArrivingAfterRelease_onPlayerReleasedForwardedLast() throws Exception {
FakeClock fakeClock = new FakeClock(/* initialTimeMs= */
0, /* isAutoAdvancing= */
true);
ExoPlayer exoPlayer = new TestExoPlayerBuilder(ApplicationProvider.getApplicationContext()).setClock(fakeClock).build();
AnalyticsListener analyticsListener = spy(new AnalyticsListener() {
@Override
public void onVideoDisabled(EventTime eventTime, DecoderCounters decoderCounters) {
// Add delay in callback to test whether event timestamp and release timestamp are
// in the correct order.
fakeClock.advanceTime(1);
}
});
exoPlayer.addAnalyticsListener(analyticsListener);
// Prepare with media to ensure video renderer is enabled.
exoPlayer.setMediaSource(new FakeMediaSource(new FakeTimeline(), ExoPlayerTestRunner.VIDEO_FORMAT));
exoPlayer.prepare();
TestPlayerRunHelper.runUntilPlaybackState(exoPlayer, Player.STATE_READY);
// Release and add delay on releasing thread to verify timestamps of events.
exoPlayer.release();
long releaseTimeMs = fakeClock.currentTimeMillis();
fakeClock.advanceTime(1);
ShadowLooper.idleMainLooper();
// Verify video disable events and release events arrived in order.
ArgumentCaptor<AnalyticsListener.EventTime> videoDisabledEventTime = ArgumentCaptor.forClass(AnalyticsListener.EventTime.class);
ArgumentCaptor<AnalyticsListener.EventTime> releasedEventTime = ArgumentCaptor.forClass(AnalyticsListener.EventTime.class);
InOrder inOrder = inOrder(analyticsListener);
inOrder.verify(analyticsListener).onVideoDisabled(videoDisabledEventTime.capture(), any());
inOrder.verify(analyticsListener).onEvents(same(exoPlayer), argThat(events -> events.contains(EVENT_VIDEO_DISABLED)));
inOrder.verify(analyticsListener).onPlayerReleased(releasedEventTime.capture());
inOrder.verify(analyticsListener).onEvents(same(exoPlayer), argThat(events -> events.contains(EVENT_PLAYER_RELEASED)));
// Verify order of timestamps of these events.
// This verification is needed as a regression test against [internal ref: b/195396384]. The
// root cause of the regression was an onPlayerReleased timestamp that was less than the
// previously reported timestamps for other events triggered as part of the release.
long videoDisableTimeMs = videoDisabledEventTime.getValue().realtimeMs;
assertThat(videoDisableTimeMs).isGreaterThan(releaseTimeMs);
assertThat(releasedEventTime.getValue().realtimeMs).isGreaterThan(videoDisableTimeMs);
}
use of com.google.android.exoplayer2.ExoPlayer in project ExoPlayer by google.
the class ExoPlayerTest method play_withPreMidAndPostRollAd_callsOnDiscontinuityCorrectly.
@Test
public void play_withPreMidAndPostRollAd_callsOnDiscontinuityCorrectly() throws Exception {
ExoPlayer player = new TestExoPlayerBuilder(context).build();
Player.Listener listener = mock(Player.Listener.class);
player.addListener(listener);
AdPlaybackState adPlaybackState = FakeTimeline.createAdPlaybackState(/* adsPerAdGroup= */
2, /* adGroupTimesUs...= */
0, 7 * C.MICROS_PER_SECOND, C.TIME_END_OF_SOURCE);
TimelineWindowDefinition adTimeline = new TimelineWindowDefinition(/* periodCount= */
1, /* id= */
0, /* isSeekable= */
true, /* isDynamic= */
false, /* isLive= */
false, /* isPlaceholder= */
false, /* durationUs= */
10 * C.MICROS_PER_SECOND, /* defaultPositionUs= */
0, /* windowOffsetInFirstPeriodUs= */
0, adPlaybackState);
player.setMediaSource(new FakeMediaSource(new FakeTimeline(adTimeline)));
player.prepare();
player.play();
TestPlayerRunHelper.runUntilPlaybackState(player, Player.STATE_ENDED);
ArgumentCaptor<Player.PositionInfo> oldPosition = ArgumentCaptor.forClass(Player.PositionInfo.class);
ArgumentCaptor<Player.PositionInfo> newPosition = ArgumentCaptor.forClass(Player.PositionInfo.class);
verify(listener, never()).onPositionDiscontinuity(any(), any(), not(eq(Player.DISCONTINUITY_REASON_AUTO_TRANSITION)));
verify(listener, times(8)).onPositionDiscontinuity(oldPosition.capture(), newPosition.capture(), eq(Player.DISCONTINUITY_REASON_AUTO_TRANSITION));
// first ad group (pre-roll)
// starts with ad to ad transition
List<Player.PositionInfo> oldPositions = oldPosition.getAllValues();
List<Player.PositionInfo> newPositions = newPosition.getAllValues();
assertThat(oldPositions.get(0).mediaItemIndex).isEqualTo(0);
assertThat(oldPositions.get(0).positionMs).isEqualTo(5000);
assertThat(oldPositions.get(0).contentPositionMs).isEqualTo(0);
assertThat(oldPositions.get(0).adGroupIndex).isEqualTo(0);
assertThat(oldPositions.get(0).adIndexInAdGroup).isEqualTo(0);
assertThat(newPositions.get(0).mediaItemIndex).isEqualTo(0);
assertThat(newPositions.get(0).positionMs).isEqualTo(0);
assertThat(newPositions.get(0).contentPositionMs).isEqualTo(0);
assertThat(newPositions.get(0).adGroupIndex).isEqualTo(0);
assertThat(newPositions.get(0).adIndexInAdGroup).isEqualTo(1);
// ad to content transition
assertThat(oldPositions.get(1).mediaItemIndex).isEqualTo(0);
assertThat(oldPositions.get(1).positionMs).isEqualTo(5000);
assertThat(oldPositions.get(1).contentPositionMs).isEqualTo(0);
assertThat(oldPositions.get(1).adGroupIndex).isEqualTo(0);
assertThat(oldPositions.get(1).adIndexInAdGroup).isEqualTo(1);
assertThat(newPositions.get(1).mediaItemIndex).isEqualTo(0);
assertThat(newPositions.get(1).positionMs).isEqualTo(0);
assertThat(newPositions.get(1).contentPositionMs).isEqualTo(0);
assertThat(newPositions.get(1).adGroupIndex).isEqualTo(-1);
assertThat(newPositions.get(1).adIndexInAdGroup).isEqualTo(-1);
// second add group (mid-roll)
assertThat(oldPositions.get(2).mediaItemIndex).isEqualTo(0);
assertThat(oldPositions.get(2).positionMs).isEqualTo(7000);
assertThat(oldPositions.get(2).contentPositionMs).isEqualTo(7000);
assertThat(oldPositions.get(2).adGroupIndex).isEqualTo(-1);
assertThat(oldPositions.get(2).adIndexInAdGroup).isEqualTo(-1);
assertThat(newPositions.get(2).mediaItemIndex).isEqualTo(0);
assertThat(newPositions.get(2).positionMs).isEqualTo(0);
assertThat(newPositions.get(2).contentPositionMs).isEqualTo(7000);
assertThat(newPositions.get(2).adGroupIndex).isEqualTo(1);
assertThat(newPositions.get(2).adIndexInAdGroup).isEqualTo(0);
// ad to ad transition
assertThat(oldPositions.get(3).mediaItemIndex).isEqualTo(0);
assertThat(oldPositions.get(3).positionMs).isEqualTo(5000);
assertThat(oldPositions.get(3).contentPositionMs).isEqualTo(7000);
assertThat(oldPositions.get(3).adGroupIndex).isEqualTo(1);
assertThat(oldPositions.get(3).adIndexInAdGroup).isEqualTo(0);
assertThat(newPositions.get(3).mediaItemIndex).isEqualTo(0);
assertThat(newPositions.get(3).positionMs).isEqualTo(0);
assertThat(newPositions.get(3).contentPositionMs).isEqualTo(7000);
assertThat(newPositions.get(3).adGroupIndex).isEqualTo(1);
assertThat(newPositions.get(3).adIndexInAdGroup).isEqualTo(1);
// ad to content transition
assertThat(oldPositions.get(4).mediaItemIndex).isEqualTo(0);
assertThat(oldPositions.get(4).positionMs).isEqualTo(5000);
assertThat(oldPositions.get(4).contentPositionMs).isEqualTo(7000);
assertThat(oldPositions.get(4).adGroupIndex).isEqualTo(1);
assertThat(oldPositions.get(4).adIndexInAdGroup).isEqualTo(1);
assertThat(newPositions.get(4).mediaItemIndex).isEqualTo(0);
assertThat(newPositions.get(4).positionMs).isEqualTo(7000);
assertThat(newPositions.get(4).contentPositionMs).isEqualTo(7000);
assertThat(newPositions.get(4).adGroupIndex).isEqualTo(-1);
assertThat(newPositions.get(4).adIndexInAdGroup).isEqualTo(-1);
// third add group (post-roll)
assertThat(oldPositions.get(5).mediaItemIndex).isEqualTo(0);
assertThat(oldPositions.get(5).positionMs).isEqualTo(10000);
assertThat(oldPositions.get(5).contentPositionMs).isEqualTo(10000);
assertThat(oldPositions.get(5).adGroupIndex).isEqualTo(-1);
assertThat(oldPositions.get(5).adIndexInAdGroup).isEqualTo(-1);
assertThat(newPositions.get(5).mediaItemIndex).isEqualTo(0);
assertThat(newPositions.get(5).positionMs).isEqualTo(0);
assertThat(newPositions.get(5).contentPositionMs).isEqualTo(10000);
assertThat(newPositions.get(5).adGroupIndex).isEqualTo(2);
assertThat(newPositions.get(5).adIndexInAdGroup).isEqualTo(0);
// ad to ad transition
assertThat(oldPositions.get(6).mediaItemIndex).isEqualTo(0);
assertThat(oldPositions.get(6).positionMs).isEqualTo(5000);
assertThat(oldPositions.get(6).contentPositionMs).isEqualTo(10000);
assertThat(oldPositions.get(6).adGroupIndex).isEqualTo(2);
assertThat(oldPositions.get(6).adIndexInAdGroup).isEqualTo(0);
assertThat(newPositions.get(6).mediaItemIndex).isEqualTo(0);
assertThat(newPositions.get(6).positionMs).isEqualTo(0);
assertThat(newPositions.get(6).contentPositionMs).isEqualTo(10000);
assertThat(newPositions.get(6).adGroupIndex).isEqualTo(2);
assertThat(newPositions.get(6).adIndexInAdGroup).isEqualTo(1);
// post roll ad to end of content transition
assertThat(oldPositions.get(7).mediaItemIndex).isEqualTo(0);
assertThat(oldPositions.get(7).positionMs).isEqualTo(5000);
assertThat(oldPositions.get(7).contentPositionMs).isEqualTo(10000);
assertThat(oldPositions.get(7).adGroupIndex).isEqualTo(2);
assertThat(oldPositions.get(7).adIndexInAdGroup).isEqualTo(1);
assertThat(newPositions.get(7).mediaItemIndex).isEqualTo(0);
assertThat(newPositions.get(7).positionMs).isEqualTo(9999);
assertThat(newPositions.get(7).contentPositionMs).isEqualTo(9999);
assertThat(newPositions.get(7).adGroupIndex).isEqualTo(-1);
assertThat(newPositions.get(7).adIndexInAdGroup).isEqualTo(-1);
player.release();
}
Aggregations