use of com.google.android.exoplayer2.testutil.FakeAdaptiveMediaSource in project ExoPlayer by google.
the class ExoPlayerTest method loadControlNeverWantsToLoad_throwsIllegalStateException.
@Test
public void loadControlNeverWantsToLoad_throwsIllegalStateException() {
LoadControl neverLoadingLoadControl = new DefaultLoadControl() {
@Override
public boolean shouldContinueLoading(long playbackPositionUs, long bufferedDurationUs, float playbackSpeed) {
return false;
}
@Override
public boolean shouldStartPlayback(long bufferedDurationUs, float playbackSpeed, boolean rebuffering, long targetLiveOffsetUs) {
return true;
}
};
// Use chunked data to ensure the player actually needs to continue loading and playing.
FakeAdaptiveDataSet.Factory dataSetFactory = new FakeAdaptiveDataSet.Factory(/* chunkDurationUs= */
500_000, /* bitratePercentStdDev= */
10.0, new Random(0));
MediaSource chunkedMediaSource = new FakeAdaptiveMediaSource(new FakeTimeline(), new TrackGroupArray(new TrackGroup(ExoPlayerTestRunner.VIDEO_FORMAT)), new FakeChunkSource.Factory(dataSetFactory, new FakeDataSource.Factory()));
ExoPlaybackException exception = assertThrows(ExoPlaybackException.class, () -> new ExoPlayerTestRunner.Builder(context).setLoadControl(neverLoadingLoadControl).setMediaSources(chunkedMediaSource).build().start().blockUntilEnded(TIMEOUT_MS));
assertThat(exception.type).isEqualTo(ExoPlaybackException.TYPE_UNEXPECTED);
assertThat(exception.getUnexpectedException()).isInstanceOf(IllegalStateException.class);
}
use of com.google.android.exoplayer2.testutil.FakeAdaptiveMediaSource in project ExoPlayer by google.
the class ExoPlayerTest method loadControlNeverWantsToPlay_playbackDoesNotGetStuck.
@Test
public void loadControlNeverWantsToPlay_playbackDoesNotGetStuck() throws Exception {
LoadControl neverLoadingOrPlayingLoadControl = new DefaultLoadControl() {
@Override
public boolean shouldContinueLoading(long playbackPositionUs, long bufferedDurationUs, float playbackSpeed) {
return true;
}
@Override
public boolean shouldStartPlayback(long bufferedDurationUs, float playbackSpeed, boolean rebuffering, long targetLiveOffsetUs) {
return false;
}
};
// Use chunked data to ensure the player actually needs to continue loading and playing.
FakeAdaptiveDataSet.Factory dataSetFactory = new FakeAdaptiveDataSet.Factory(/* chunkDurationUs= */
500_000, /* bitratePercentStdDev= */
10.0, new Random(0));
MediaSource chunkedMediaSource = new FakeAdaptiveMediaSource(new FakeTimeline(), new TrackGroupArray(new TrackGroup(ExoPlayerTestRunner.VIDEO_FORMAT)), new FakeChunkSource.Factory(dataSetFactory, new FakeDataSource.Factory()));
new ExoPlayerTestRunner.Builder(context).setLoadControl(neverLoadingOrPlayingLoadControl).setMediaSources(chunkedMediaSource).build().start().blockUntilEnded(TIMEOUT_MS);
}
Aggregations