Search in sources :

Example 16 with FakeShuffleOrder

use of androidx.media3.test.utils.FakeShuffleOrder in project media by androidx.

the class MediaSourceListTest method setMediaSources_expectTimelineUsesCustomShuffleOrder.

@Test
public void setMediaSources_expectTimelineUsesCustomShuffleOrder() {
    Timeline timeline = mediaSourceList.setMediaSources(createFakeHolders(), new FakeShuffleOrder(/* length=*/
    4));
    assertTimelineUsesFakeShuffleOrder(timeline);
}
Also used : Timeline(androidx.media3.common.Timeline) FakeShuffleOrder(androidx.media3.test.utils.FakeShuffleOrder) Test(org.junit.Test)

Example 17 with FakeShuffleOrder

use of androidx.media3.test.utils.FakeShuffleOrder in project media by androidx.

the class ExoPlayerTest method setShuffleOrder_keepsCurrentPosition.

@Test
public void setShuffleOrder_keepsCurrentPosition() throws Exception {
    AtomicLong positionAfterSetShuffleOrder = new AtomicLong(C.TIME_UNSET);
    ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG).playUntilPosition(0, 5000).setShuffleOrder(new FakeShuffleOrder(/* length= */
    1)).executeRunnable(new PlayerRunnable() {

        @Override
        public void run(ExoPlayer player) {
            positionAfterSetShuffleOrder.set(player.getCurrentPosition());
        }
    }).play().build();
    new ExoPlayerTestRunner.Builder(context).setActionSchedule(actionSchedule).build().start().blockUntilEnded(TIMEOUT_MS);
    assertThat(positionAfterSetShuffleOrder.get()).isAtLeast(5000);
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) ActionSchedule(androidx.media3.test.utils.ActionSchedule) PlayerRunnable(androidx.media3.test.utils.ActionSchedule.PlayerRunnable) TestExoPlayerBuilder(androidx.media3.test.utils.TestExoPlayerBuilder) FakeShuffleOrder(androidx.media3.test.utils.FakeShuffleOrder) Test(org.junit.Test)

Example 18 with FakeShuffleOrder

use of androidx.media3.test.utils.FakeShuffleOrder in project media by androidx.

the class MediaPeriodQueueTest method setupTimeline.

private void setupTimeline(Timeline timeline) {
    fakeMediaSource = new FakeMediaSource(timeline);
    MediaSourceList.MediaSourceHolder mediaSourceHolder = new MediaSourceList.MediaSourceHolder(fakeMediaSource, /* useLazyPreparation= */
    false);
    mediaSourceList.setMediaSources(ImmutableList.of(mediaSourceHolder), new FakeShuffleOrder(/* length= */
    1));
    mediaSourceHolder.mediaSource.prepareSource(mock(MediaSourceCaller.class), /* mediaTransferListener */
    null, PlayerId.UNSET);
    Timeline playlistTimeline = mediaSourceList.createTimeline();
    firstPeriodUid = playlistTimeline.getUidOfPeriod(/* periodIndex= */
    0);
    playbackInfo = new PlaybackInfo(playlistTimeline, mediaPeriodQueue.resolveMediaPeriodIdForAds(playlistTimeline, firstPeriodUid, /* positionUs= */
    0), /* requestedContentPositionUs= */
    C.TIME_UNSET, /* discontinuityStartPositionUs= */
    0, Player.STATE_READY, /* playbackError= */
    null, /* isLoading= */
    false, /* trackGroups= */
    null, /* trackSelectorResult= */
    null, /* staticMetadata= */
    ImmutableList.of(), /* loadingMediaPeriodId= */
    null, /* playWhenReady= */
    false, Player.PLAYBACK_SUPPRESSION_REASON_NONE, /* playbackParameters= */
    PlaybackParameters.DEFAULT, /* bufferedPositionUs= */
    0, /* totalBufferedDurationUs= */
    0, /* positionUs= */
    0, /* offloadSchedulingEnabled= */
    false, /* sleepingForOffload= */
    false);
}
Also used : MediaSourceCaller(androidx.media3.exoplayer.source.MediaSource.MediaSourceCaller) FakeTimeline(androidx.media3.test.utils.FakeTimeline) SinglePeriodTimeline(androidx.media3.exoplayer.source.SinglePeriodTimeline) SinglePeriodAdTimeline(androidx.media3.exoplayer.source.ads.SinglePeriodAdTimeline) Timeline(androidx.media3.common.Timeline) FakeMediaSource(androidx.media3.test.utils.FakeMediaSource) FakeShuffleOrder(androidx.media3.test.utils.FakeShuffleOrder)

Aggregations

Test (org.junit.Test)16 FakeShuffleOrder (androidx.media3.test.utils.FakeShuffleOrder)15 Timeline (androidx.media3.common.Timeline)14 FakeTimeline (androidx.media3.test.utils.FakeTimeline)9 FakeMediaSource (androidx.media3.test.utils.FakeMediaSource)7 ConcatenatingMediaSource (androidx.media3.exoplayer.source.ConcatenatingMediaSource)5 ActionSchedule (androidx.media3.test.utils.ActionSchedule)5 TestExoPlayerBuilder (androidx.media3.test.utils.TestExoPlayerBuilder)5 SinglePeriodTimeline (androidx.media3.exoplayer.source.SinglePeriodTimeline)4 ClippingMediaSource (androidx.media3.exoplayer.source.ClippingMediaSource)3 CompositeMediaSource (androidx.media3.exoplayer.source.CompositeMediaSource)3 MaskingMediaSource (androidx.media3.exoplayer.source.MaskingMediaSource)3 MediaSource (androidx.media3.exoplayer.source.MediaSource)3 ShuffleOrder (androidx.media3.exoplayer.source.ShuffleOrder)3 ServerSideAdInsertionMediaSource (androidx.media3.exoplayer.source.ads.ServerSideAdInsertionMediaSource)3 ExoPlayerTestRunner (androidx.media3.test.utils.ExoPlayerTestRunner)3 FakeAdaptiveMediaSource (androidx.media3.test.utils.FakeAdaptiveMediaSource)3 NoUidTimeline (androidx.media3.test.utils.NoUidTimeline)3 PlayerRunnable (androidx.media3.test.utils.ActionSchedule.PlayerRunnable)2 MediaSourceTestRunner (androidx.media3.test.utils.MediaSourceTestRunner)2