Search in sources :

Example 1 with IllegalClippingException

use of androidx.media3.exoplayer.source.ClippingMediaSource.IllegalClippingException in project media by androidx.

the class ClippingMediaSourceTest method clippingUnseekableWindowThrows.

@Test
public void clippingUnseekableWindowThrows() throws IOException {
    Timeline timeline = new SinglePeriodTimeline(TEST_PERIOD_DURATION_US, /* isSeekable= */
    false, /* isDynamic= */
    false, /* useLiveConfiguration= */
    false, /* manifest= */
    null, MediaItem.fromUri(Uri.EMPTY));
    // 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 (IllegalClippingException e) {
        assertThat(e.reason).isEqualTo(IllegalClippingException.REASON_NOT_SEEKABLE_TO_START);
    }
}
Also used : FakeTimeline(androidx.media3.test.utils.FakeTimeline) PlaceholderTimeline(androidx.media3.exoplayer.source.MaskingMediaSource.PlaceholderTimeline) Timeline(androidx.media3.common.Timeline) IllegalClippingException(androidx.media3.exoplayer.source.ClippingMediaSource.IllegalClippingException) Test(org.junit.Test)

Example 2 with IllegalClippingException

use of androidx.media3.exoplayer.source.ClippingMediaSource.IllegalClippingException in project media by androidx.

the class ClippingMediaSourceTest method clippingUnseekableWindowWithUnknownDurationThrows.

@Test
public void clippingUnseekableWindowWithUnknownDurationThrows() throws IOException {
    Timeline timeline = new SinglePeriodTimeline(/* durationUs= */
    C.TIME_UNSET, /* isSeekable= */
    false, /* isDynamic= */
    false, /* useLiveConfiguration= */
    false, /* manifest= */
    null, MediaItem.fromUri(Uri.EMPTY));
    // If the unseekable window isn't clipped, clipping succeeds.
    getClippedTimeline(timeline, /* startUs= */
    0, TEST_PERIOD_DURATION_US);
    try {
        // If the unseekable window is clipped, clipping fails.
        getClippedTimeline(timeline, /* startUs= */
        1, TEST_PERIOD_DURATION_US);
        fail("Expected clipping to fail.");
    } catch (IllegalClippingException e) {
        assertThat(e.reason).isEqualTo(IllegalClippingException.REASON_NOT_SEEKABLE_TO_START);
    }
}
Also used : FakeTimeline(androidx.media3.test.utils.FakeTimeline) PlaceholderTimeline(androidx.media3.exoplayer.source.MaskingMediaSource.PlaceholderTimeline) Timeline(androidx.media3.common.Timeline) IllegalClippingException(androidx.media3.exoplayer.source.ClippingMediaSource.IllegalClippingException) Test(org.junit.Test)

Aggregations

Timeline (androidx.media3.common.Timeline)2 IllegalClippingException (androidx.media3.exoplayer.source.ClippingMediaSource.IllegalClippingException)2 PlaceholderTimeline (androidx.media3.exoplayer.source.MaskingMediaSource.PlaceholderTimeline)2 FakeTimeline (androidx.media3.test.utils.FakeTimeline)2 Test (org.junit.Test)2