Search in sources :

Example 11 with Timeline

use of com.google.android.exoplayer2.Timeline in project ExoPlayer by google.

the class ExoPlayerTest method testPlayEmptyTimeline.

/**
   * Tests playback of a source that exposes an empty timeline. Playback is expected to end without
   * error.
   */
public void testPlayEmptyTimeline() throws Exception {
    PlayerWrapper playerWrapper = new PlayerWrapper();
    Timeline timeline = Timeline.EMPTY;
    MediaSource mediaSource = new FakeMediaSource(timeline, null);
    FakeRenderer renderer = new FakeRenderer(null);
    playerWrapper.setup(mediaSource, renderer);
    playerWrapper.blockUntilEnded(TIMEOUT_MS);
    assertEquals(0, playerWrapper.positionDiscontinuityCount);
    assertEquals(0, renderer.formatReadCount);
    assertEquals(0, renderer.bufferReadCount);
    assertFalse(renderer.isEnded);
    assertEquals(timeline, playerWrapper.timeline);
    assertNull(playerWrapper.manifest);
}
Also used : MediaSource(com.google.android.exoplayer2.source.MediaSource)

Example 12 with Timeline

use of com.google.android.exoplayer2.Timeline in project ExoPlayer by google.

the class ClippingMediaSourceTest method testClippingUnseekableWindowThrows.

public void testClippingUnseekableWindowThrows() {
    Timeline timeline = new SinglePeriodTimeline(C.msToUs(TEST_PERIOD_DURATION_US), false);
    // If the unseekable window isn't clipped, clipping succeeds.
    getClippedTimeline(timeline, 0, TEST_PERIOD_DURATION_US);
    try {
        // If the unseekable window is clipped, clipping fails.
        getClippedTimeline(timeline, 1, TEST_PERIOD_DURATION_US);
        fail("Expected clipping to fail.");
    } catch (IllegalArgumentException e) {
    // Expected.
    }
}
Also used : Timeline(com.google.android.exoplayer2.Timeline)

Example 13 with Timeline

use of com.google.android.exoplayer2.Timeline in project ExoPlayer by google.

the class ClippingMediaSourceTest method testNoClipping.

public void testNoClipping() {
    Timeline timeline = new SinglePeriodTimeline(C.msToUs(TEST_PERIOD_DURATION_US), true);
    Timeline clippedTimeline = getClippedTimeline(timeline, 0, TEST_PERIOD_DURATION_US);
    assertEquals(1, clippedTimeline.getWindowCount());
    assertEquals(1, clippedTimeline.getPeriodCount());
    assertEquals(TEST_PERIOD_DURATION_US, clippedTimeline.getWindow(0, window).getDurationUs());
    assertEquals(TEST_PERIOD_DURATION_US, clippedTimeline.getPeriod(0, period).getDurationUs());
}
Also used : Timeline(com.google.android.exoplayer2.Timeline)

Example 14 with Timeline

use of com.google.android.exoplayer2.Timeline in project ExoPlayer by google.

the class ClippingMediaSourceTest method testClippingStart.

public void testClippingStart() {
    Timeline timeline = new SinglePeriodTimeline(C.msToUs(TEST_PERIOD_DURATION_US), true);
    Timeline clippedTimeline = getClippedTimeline(timeline, TEST_CLIP_AMOUNT_US, TEST_PERIOD_DURATION_US);
    assertEquals(TEST_PERIOD_DURATION_US - TEST_CLIP_AMOUNT_US, clippedTimeline.getWindow(0, window).getDurationUs());
    assertEquals(TEST_PERIOD_DURATION_US - TEST_CLIP_AMOUNT_US, clippedTimeline.getPeriod(0, period).getDurationUs());
}
Also used : Timeline(com.google.android.exoplayer2.Timeline)

Example 15 with Timeline

use of com.google.android.exoplayer2.Timeline in project ExoPlayer by google.

the class ClippingMediaSourceTest method getClippedTimeline.

/**
   * Wraps the specified timeline in a {@link ClippingMediaSource} and returns the clipped timeline.
   */
private Timeline getClippedTimeline(Timeline timeline, long startMs, long endMs) {
    mockMediaSourceSourceWithTimeline(timeline);
    new ClippingMediaSource(mockMediaSource, startMs, endMs).prepareSource(null, true, new Listener() {

        @Override
        public void onSourceInfoRefreshed(Timeline timeline, Object manifest) {
            clippedTimeline = timeline;
        }
    });
    return clippedTimeline;
}
Also used : Timeline(com.google.android.exoplayer2.Timeline) Listener(com.google.android.exoplayer2.source.MediaSource.Listener)

Aggregations

Timeline (com.google.android.exoplayer2.Timeline)12 MediaSource (com.google.android.exoplayer2.source.MediaSource)4 SinglePeriodTimeline (com.google.android.exoplayer2.source.SinglePeriodTimeline)2 Listener (com.google.android.exoplayer2.source.MediaSource.Listener)1 SampleStream (com.google.android.exoplayer2.source.SampleStream)1 TrackGroup (com.google.android.exoplayer2.source.TrackGroup)1 TrackGroupArray (com.google.android.exoplayer2.source.TrackGroupArray)1 StreamElement (com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest.StreamElement)1 TrackSelection (com.google.android.exoplayer2.trackselection.TrackSelection)1 TrackSelectorResult (com.google.android.exoplayer2.trackselection.TrackSelectorResult)1