ConcatenatingMediaSource extends CompositeMediaSource<MediaSourceHolder> { public synchronized void clear() { removeMediaSourceRange(0, getSize()); } ConcatenatingMediaSource(MediaSource... mediaSources);  ConcatenatingMediaSource(boolean isAtomic, MediaSource... mediaSources);  ConcatenatingMediaSource(
      boolean isAtomic, ShuffleOrder shuffleOrder, MediaSource... mediaSources); @SuppressWarnings("initialization")  ConcatenatingMediaSource(
      boolean isAtomic,
      boolean useLazyPreparation,
      ShuffleOrder shuffleOrder,
      MediaSource... mediaSources); synchronized void addMediaSource(MediaSource mediaSource); synchronized void addMediaSource(
      MediaSource mediaSource, Handler handler, Runnable onCompletionAction); synchronized void addMediaSource(int index, MediaSource mediaSource); synchronized void addMediaSource(
      int index, MediaSource mediaSource, Handler handler, Runnable onCompletionAction); synchronized void addMediaSources(Collection<MediaSource> mediaSources); synchronized void addMediaSources(
      Collection<MediaSource> mediaSources, Handler handler, Runnable onCompletionAction); synchronized void addMediaSources(int index, Collection<MediaSource> mediaSources); synchronized void addMediaSources(
      int index,
      Collection<MediaSource> mediaSources,
      Handler handler,
      Runnable onCompletionAction); synchronized MediaSource removeMediaSource(int index); synchronized MediaSource removeMediaSource(
      int index, Handler handler, Runnable onCompletionAction); synchronized void removeMediaSourceRange(int fromIndex, int toIndex); synchronized void removeMediaSourceRange(
      int fromIndex, int toIndex, Handler handler, Runnable onCompletionAction); synchronized void moveMediaSource(int currentIndex, int newIndex); synchronized void moveMediaSource(
      int currentIndex, int newIndex, Handler handler, Runnable onCompletionAction); synchronized void clear(); synchronized void clear(Handler handler, Runnable onCompletionAction); synchronized int getSize(); synchronized MediaSource getMediaSource(int index); synchronized void setShuffleOrder(ShuffleOrder shuffleOrder); synchronized void setShuffleOrder(
      ShuffleOrder shuffleOrder, Handler handler, Runnable onCompletionAction); @Override @Nullable Object getTag(); @Override MediaPeriod createPeriod(MediaPeriodId id, Allocator allocator, long startPositionUs); @Override void releasePeriod(MediaPeriod mediaPeriod);  }
@Test public void testClear() throws Exception { DummyMainThread dummyMainThread = new DummyMainThread(); final FakeMediaSource preparedChildSource = createFakeMediaSource(); final FakeMediaSource unpreparedChildSource = new FakeMediaSource( null); dummyMainThread.runOnMainThread( () -> { mediaSource.addMediaSource(preparedChildSource); mediaSource.addMediaSource(unpreparedChildSource); }); testRunner.prepareSource(); final TimelineGrabber timelineGrabber = new TimelineGrabber(testRunner); dummyMainThread.runOnMainThread(() -> mediaSource.clear(new Handler(), timelineGrabber)); Timeline timeline = timelineGrabber.assertTimelineChangeBlocking(); assertThat(timeline.isEmpty()).isTrue(); preparedChildSource.assertReleased(); unpreparedChildSource.assertReleased(); }