Search in sources :

Example 6 with DefaultShuffleOrder

use of com.google.android.exoplayer2.source.ShuffleOrder.DefaultShuffleOrder in project ExoPlayer by google.

the class ShuffleOrderTest method defaultShuffleOrderSideloaded.

@Test
public void defaultShuffleOrderSideloaded() {
    int[] shuffledIndices = new int[] { 2, 1, 0, 4, 3 };
    ShuffleOrder shuffleOrder = new DefaultShuffleOrder(shuffledIndices, RANDOM_SEED);
    assertThat(shuffleOrder.getFirstIndex()).isEqualTo(2);
    assertThat(shuffleOrder.getLastIndex()).isEqualTo(3);
    for (int i = 0; i < 4; i++) {
        assertThat(shuffleOrder.getNextIndex(shuffledIndices[i])).isEqualTo(shuffledIndices[i + 1]);
    }
    assertThat(shuffleOrder.getNextIndex(3)).isEqualTo(C.INDEX_UNSET);
    for (int i = 4; i > 0; i--) {
        assertThat(shuffleOrder.getPreviousIndex(shuffledIndices[i])).isEqualTo(shuffledIndices[i - 1]);
    }
    assertThat(shuffleOrder.getPreviousIndex(2)).isEqualTo(C.INDEX_UNSET);
}
Also used : DefaultShuffleOrder(com.google.android.exoplayer2.source.ShuffleOrder.DefaultShuffleOrder) UnshuffledShuffleOrder(com.google.android.exoplayer2.source.ShuffleOrder.UnshuffledShuffleOrder) DefaultShuffleOrder(com.google.android.exoplayer2.source.ShuffleOrder.DefaultShuffleOrder) Test(org.junit.Test)

Aggregations

DefaultShuffleOrder (com.google.android.exoplayer2.source.ShuffleOrder.DefaultShuffleOrder)6 Test (org.junit.Test)6 FakeMediaSource (com.google.android.exoplayer2.testutil.FakeMediaSource)4 MediaSourceTestRunner (com.google.android.exoplayer2.testutil.MediaSourceTestRunner)4 Timeline (com.google.android.exoplayer2.Timeline)2 MediaPeriodId (com.google.android.exoplayer2.source.MediaSource.MediaPeriodId)2 FakeTimeline (com.google.android.exoplayer2.testutil.FakeTimeline)2 UnshuffledShuffleOrder (com.google.android.exoplayer2.source.ShuffleOrder.UnshuffledShuffleOrder)1