use of com.google.android.exoplayer2.source.MergingMediaSource.IllegalMergeException in project ExoPlayer by google.
the class MergingMediaSourceTest method prepare_differentPeriodCounts_fails.
@Test
public void prepare_differentPeriodCounts_fails() throws IOException {
FakeTimeline firstTimeline = new FakeTimeline(new TimelineWindowDefinition(/* periodCount= */
1, /* id= */
1));
FakeTimeline secondTimeline = new FakeTimeline(new TimelineWindowDefinition(/* periodCount= */
2, /* id= */
2));
IllegalMergeException exception = assertThrows(IllegalMergeException.class, () -> prepareMergingMediaSource(/* clipDurations= */
false, firstTimeline, secondTimeline));
assertThat(exception.reason).isEqualTo(IllegalMergeException.REASON_PERIOD_COUNT_MISMATCH);
}
use of com.google.android.exoplayer2.source.MergingMediaSource.IllegalMergeException in project ExoPlayer by google.
the class MergingMediaSource method onChildSourceInfoRefreshed.
@Override
protected void onChildSourceInfoRefreshed(Integer id, MediaSource mediaSource, Timeline timeline) {
if (mergeError != null) {
return;
}
if (periodCount == PERIOD_COUNT_UNSET) {
periodCount = timeline.getPeriodCount();
} else if (timeline.getPeriodCount() != periodCount) {
mergeError = new IllegalMergeException(IllegalMergeException.REASON_PERIOD_COUNT_MISMATCH);
return;
}
if (periodTimeOffsetsUs.length == 0) {
periodTimeOffsetsUs = new long[periodCount][timelines.length];
}
pendingTimelineSources.remove(mediaSource);
timelines[id] = timeline;
if (pendingTimelineSources.isEmpty()) {
if (adjustPeriodTimeOffsets) {
computePeriodTimeOffsets();
}
Timeline mergedTimeline = timelines[0];
if (clipDurations) {
updateClippedDuration();
mergedTimeline = new ClippedTimeline(mergedTimeline, clippedDurationsUs);
}
refreshSourceInfo(mergedTimeline);
}
}
Aggregations