use of com.google.android.exoplayer2.source.MediaSource.MediaPeriodId in project ExoPlayer by google.
the class MediaPeriodQueueTest method resolveMediaPeriodIdForAdsAfterPeriodPositionChange_consecutiveContentPeriods_rollForward.
@Test
public void resolveMediaPeriodIdForAdsAfterPeriodPositionChange_consecutiveContentPeriods_rollForward() throws InterruptedException {
Object windowId = new Object();
Timeline timeline = createMultiPeriodServerSideInsertedTimeline(windowId, /* numberOfPlayedAds= */
0, /* isAdPeriodFlags...= */
true, false, false, false);
MediaPeriodId mediaPeriodId = mediaPeriodQueue.resolveMediaPeriodIdForAdsAfterPeriodPositionChange(timeline, new Pair<>(windowId, 3), /* positionUs= */
10_000);
assertThat(mediaPeriodId.periodUid).isEqualTo(new Pair<>(windowId, 0));
assertThat(mediaPeriodId.adGroupIndex).isEqualTo(0);
assertThat(mediaPeriodId.adIndexInAdGroup).isEqualTo(0);
assertThat(mediaPeriodId.nextAdGroupIndex).isEqualTo(-1);
}
use of com.google.android.exoplayer2.source.MediaSource.MediaPeriodId in project ExoPlayer by google.
the class MediaPeriodQueueTest method resolveMediaPeriodIdForAdsAfterPeriodPositionChange_behindAdInMultiPeriodTimeline_rollForward.
@Test
public void resolveMediaPeriodIdForAdsAfterPeriodPositionChange_behindAdInMultiPeriodTimeline_rollForward() throws InterruptedException {
Object windowId = new Object();
Timeline timeline = createMultiPeriodServerSideInsertedTimeline(windowId, /* numberOfPlayedAds= */
0, /* isAdPeriodFlags...= */
true, false, true, true, true, false);
MediaPeriodId mediaPeriodId = mediaPeriodQueue.resolveMediaPeriodIdForAdsAfterPeriodPositionChange(timeline, new Pair<>(windowId, 1), /* positionUs= */
1);
assertThat(mediaPeriodId.periodUid).isEqualTo(new Pair<>(windowId, 0));
assertThat(mediaPeriodId.adGroupIndex).isEqualTo(0);
assertThat(mediaPeriodId.adIndexInAdGroup).isEqualTo(0);
assertThat(mediaPeriodId.nextAdGroupIndex).isEqualTo(-1);
mediaPeriodId = mediaPeriodQueue.resolveMediaPeriodIdForAdsAfterPeriodPositionChange(timeline, new Pair<>(windowId, 5), /* positionUs= */
0);
assertThat(mediaPeriodId.periodUid).isEqualTo(new Pair<>(windowId, 2));
assertThat(mediaPeriodId.adGroupIndex).isEqualTo(0);
assertThat(mediaPeriodId.adIndexInAdGroup).isEqualTo(0);
assertThat(mediaPeriodId.nextAdGroupIndex).isEqualTo(-1);
}
use of com.google.android.exoplayer2.source.MediaSource.MediaPeriodId in project ExoPlayer by google.
the class MediaPeriodQueueTest method resolveMediaPeriodIdForAdsAfterPeriodPositionChange_toStartOfWindowPlayedAdPreroll_skipsPlayedPrerolls.
@Test
public void resolveMediaPeriodIdForAdsAfterPeriodPositionChange_toStartOfWindowPlayedAdPreroll_skipsPlayedPrerolls() throws InterruptedException {
Object windowId = new Object();
Timeline timeline = createMultiPeriodServerSideInsertedTimeline(windowId, /* numberOfPlayedAds= */
2, /* isAdPeriodFlags...= */
true, true, false);
MediaPeriodId mediaPeriodId = mediaPeriodQueue.resolveMediaPeriodIdForAdsAfterPeriodPositionChange(timeline, new Pair<>(windowId, 0), /* positionUs= */
0);
assertThat(mediaPeriodId.adGroupIndex).isEqualTo(-1);
assertThat(mediaPeriodId.adIndexInAdGroup).isEqualTo(-1);
assertThat(mediaPeriodId.nextAdGroupIndex).isEqualTo(-1);
assertThat(mediaPeriodId.periodUid).isEqualTo(new Pair<>(windowId, 2));
}
use of com.google.android.exoplayer2.source.MediaSource.MediaPeriodId in project ExoPlayer by google.
the class MediaPeriodQueueTest method resolveMediaPeriodIdForAdsAfterPeriodPositionChange_toPlayedAdInMultiPeriodTimeline_skipPlayedAd.
@Test
public void resolveMediaPeriodIdForAdsAfterPeriodPositionChange_toPlayedAdInMultiPeriodTimeline_skipPlayedAd() throws InterruptedException {
Object windowId = new Object();
Timeline timeline = createMultiPeriodServerSideInsertedTimeline(windowId, /* numberOfPlayedAds= */
1, /* isAdPeriodFlags...= */
false, true, false);
MediaPeriodId mediaPeriodId = mediaPeriodQueue.resolveMediaPeriodIdForAdsAfterPeriodPositionChange(timeline, new Pair<>(windowId, 1), /* positionUs= */
0);
assertThat(mediaPeriodId.adGroupIndex).isEqualTo(-1);
assertThat(mediaPeriodId.adIndexInAdGroup).isEqualTo(-1);
assertThat(mediaPeriodId.nextAdGroupIndex).isEqualTo(-1);
assertThat(mediaPeriodId.periodUid).isEqualTo(new Pair<>(windowId, 2));
}
use of com.google.android.exoplayer2.source.MediaSource.MediaPeriodId in project ExoPlayer by google.
the class MediaPeriodQueueTest method resolveMediaPeriodIdForAdsAfterPeriodPositionChange_behindAdInMultiPeriodFirstTwoAdsPlayed_rollForward.
@Test
public void resolveMediaPeriodIdForAdsAfterPeriodPositionChange_behindAdInMultiPeriodFirstTwoAdsPlayed_rollForward() throws InterruptedException {
Object windowId = new Object();
Timeline timeline = createMultiPeriodServerSideInsertedTimeline(windowId, /* numberOfPlayedAds= */
2, /* isAdPeriodFlags...= */
true, false, true, true, true, false);
MediaPeriodId mediaPeriodId = mediaPeriodQueue.resolveMediaPeriodIdForAdsAfterPeriodPositionChange(timeline, new Pair<>(windowId, 5), /* positionUs= */
33);
assertThat(mediaPeriodId.adGroupIndex).isEqualTo(0);
assertThat(mediaPeriodId.adIndexInAdGroup).isEqualTo(0);
assertThat(mediaPeriodId.nextAdGroupIndex).isEqualTo(-1);
assertThat(mediaPeriodId.periodUid).isEqualTo(new Pair<>(windowId, 3));
}
Aggregations