use of androidx.media3.exoplayer.source.MediaSource.MediaPeriodId in project media by androidx.
the class MediaPeriodQueueTest method resolveMediaPeriodIdForAdsAfterPeriodPositionChange_behindAdInMultiPeriodAllAdsPlayed_seekNotAdjusted.
@Test
public void resolveMediaPeriodIdForAdsAfterPeriodPositionChange_behindAdInMultiPeriodAllAdsPlayed_seekNotAdjusted() throws InterruptedException {
Object windowId = new Object();
Timeline timeline = createMultiPeriodServerSideInsertedTimeline(windowId, /* numberOfPlayedAds= */
4, /* isAdPeriodFlags...= */
true, false, true, true, true, false);
MediaPeriodId mediaPeriodId = mediaPeriodQueue.resolveMediaPeriodIdForAdsAfterPeriodPositionChange(timeline, new Pair<>(windowId, 1), /* positionUs= */
11);
assertThat(mediaPeriodId.adGroupIndex).isEqualTo(-1);
assertThat(mediaPeriodId.adIndexInAdGroup).isEqualTo(-1);
assertThat(mediaPeriodId.nextAdGroupIndex).isEqualTo(-1);
assertThat(mediaPeriodId.periodUid).isEqualTo(new Pair<>(windowId, 1));
mediaPeriodId = mediaPeriodQueue.resolveMediaPeriodIdForAdsAfterPeriodPositionChange(timeline, new Pair<>(windowId, 5), /* positionUs= */
33);
assertThat(mediaPeriodId.adGroupIndex).isEqualTo(-1);
assertThat(mediaPeriodId.adIndexInAdGroup).isEqualTo(-1);
assertThat(mediaPeriodId.nextAdGroupIndex).isEqualTo(-1);
assertThat(mediaPeriodId.periodUid).isEqualTo(new Pair<>(windowId, 5));
}
use of androidx.media3.exoplayer.source.MediaSource.MediaPeriodId in project media by androidx.
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 androidx.media3.exoplayer.source.MediaSource.MediaPeriodId in project media by androidx.
the class MediaPeriodQueueTest method resolveMediaPeriodIdForAdsAfterPeriodPositionChange_toUnplayedAdInMultiPeriodTimeline_resolvedAsAd.
@Test
public void resolveMediaPeriodIdForAdsAfterPeriodPositionChange_toUnplayedAdInMultiPeriodTimeline_resolvedAsAd() throws InterruptedException {
Object windowId = new Object();
Timeline timeline = createMultiPeriodServerSideInsertedTimeline(windowId, /* numberOfPlayedAds= */
0, /* isAdPeriodFlags...= */
false, true, false);
MediaPeriodId mediaPeriodId = mediaPeriodQueue.resolveMediaPeriodIdForAdsAfterPeriodPositionChange(timeline, new Pair<>(windowId, 1), /* positionUs= */
0);
assertThat(mediaPeriodId.adGroupIndex).isEqualTo(0);
assertThat(mediaPeriodId.adIndexInAdGroup).isEqualTo(0);
assertThat(mediaPeriodId.nextAdGroupIndex).isEqualTo(-1);
assertThat(mediaPeriodId.periodUid).isEqualTo(new Pair<>(windowId, 1));
}
use of androidx.media3.exoplayer.source.MediaSource.MediaPeriodId in project media by androidx.
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 androidx.media3.exoplayer.source.MediaSource.MediaPeriodId in project media by androidx.
the class MediaPeriodQueueTest method resolveMediaPeriodIdForAdsAfterPeriodPositionChange_onlyConsecutiveContentPeriods_seekNotAdjusted.
@Test
public void resolveMediaPeriodIdForAdsAfterPeriodPositionChange_onlyConsecutiveContentPeriods_seekNotAdjusted() throws InterruptedException {
Object windowId = new Object();
Timeline timeline = createMultiPeriodServerSideInsertedTimeline(windowId, /* numberOfPlayedAds= */
0, /* isAdPeriodFlags...= */
false, false, false, false);
MediaPeriodId mediaPeriodId = mediaPeriodQueue.resolveMediaPeriodIdForAdsAfterPeriodPositionChange(timeline, new Pair<>(windowId, 3), /* positionUs= */
10_000);
assertThat(mediaPeriodId.periodUid).isEqualTo(new Pair<>(windowId, 3));
assertThat(mediaPeriodId.adGroupIndex).isEqualTo(-1);
}
Aggregations