@Test public void getNextMediaPeriodInfo_withMidrollAds_returnsCorrectMediaPeriodInfos() { setupTimeline( 0, FIRST_AD_START_TIME_US, SECOND_AD_START_TIME_US); assertGetNextMediaPeriodInfoReturnsContentMediaPeriod( 0, FIRST_AD_START_TIME_US, FIRST_AD_START_TIME_US, false, 0); advance(); assertNull(getNextMediaPeriodInfo()); setAdGroupLoaded( 0); assertNextMediaPeriodInfoIsAd( 0, FIRST_AD_START_TIME_US); advance(); assertGetNextMediaPeriodInfoReturnsContentMediaPeriod( FIRST_AD_START_TIME_US, SECOND_AD_START_TIME_US, SECOND_AD_START_TIME_US, false, 1); advance(); setAdGroupLoaded( 1); assertNextMediaPeriodInfoIsAd( 1, SECOND_AD_START_TIME_US); advance(); assertGetNextMediaPeriodInfoReturnsContentMediaPeriod( SECOND_AD_START_TIME_US, C.TIME_UNSET, CONTENT_DURATION_US, true, C.INDEX_UNSET); }
public @Nullable MediaPeriodInfo getNextMediaPeriodInfo( long rendererPositionUs, PlaybackInfo playbackInfo) { return loading == null ? getFirstMediaPeriodInfo(playbackInfo) : getFollowingMediaPeriodInfo(loading, rendererPositionUs); }
MediaPeriodQueue { public @Nullable MediaPeriodInfo getNextMediaPeriodInfo( long rendererPositionUs, PlaybackInfo playbackInfo) { return loading == null ? getFirstMediaPeriodInfo(playbackInfo) : getFollowingMediaPeriodInfo(loading, rendererPositionUs); } }
MediaPeriodQueue { public @Nullable MediaPeriodInfo getNextMediaPeriodInfo( long rendererPositionUs, PlaybackInfo playbackInfo) { return loading == null ? getFirstMediaPeriodInfo(playbackInfo) : getFollowingMediaPeriodInfo(loading, rendererPositionUs); } MediaPeriodQueue(); }
MediaPeriodQueue { public @Nullable MediaPeriodInfo getNextMediaPeriodInfo( long rendererPositionUs, PlaybackInfo playbackInfo) { return loading == null ? getFirstMediaPeriodInfo(playbackInfo) : getFollowingMediaPeriodInfo(loading, rendererPositionUs); } MediaPeriodQueue(); void setTimeline(Timeline timeline); boolean updateRepeatMode(@RepeatMode int repeatMode); boolean updateShuffleModeEnabled(boolean shuffleModeEnabled); boolean isLoading(MediaPeriod mediaPeriod); void reevaluateBuffer(long rendererPositionUs); boolean shouldLoadNextMediaPeriod(); @Nullable MediaPeriodInfo getNextMediaPeriodInfo(
      long rendererPositionUs, PlaybackInfo playbackInfo); MediaPeriod enqueueNextMediaPeriod(
      RendererCapabilities[] rendererCapabilities,
      TrackSelector trackSelector,
      Allocator allocator,
      MediaSource mediaSource,
      MediaPeriodInfo info); MediaPeriodHolder getLoadingPeriod(); MediaPeriodHolder getPlayingPeriod(); MediaPeriodHolder getReadingPeriod(); MediaPeriodHolder getFrontPeriod(); boolean hasPlayingPeriod(); MediaPeriodHolder advanceReadingPeriod(); MediaPeriodHolder advancePlayingPeriod(); boolean removeAfter(MediaPeriodHolder mediaPeriodHolder); void clear(boolean keepFrontPeriodUid); boolean updateQueuedPeriods(long rendererPositionUs, long maxRendererReadPositionUs); MediaPeriodInfo getUpdatedMediaPeriodInfo(MediaPeriodInfo info); MediaPeriodId resolveMediaPeriodIdForAds(Object periodUid, long positionUs); }
MediaPeriodQueue { public @Nullable MediaPeriodInfo getNextMediaPeriodInfo( long rendererPositionUs, PlaybackInfo playbackInfo) { return loading == null ? getFirstMediaPeriodInfo(playbackInfo) : getFollowingMediaPeriodInfo(loading, rendererPositionUs); } MediaPeriodQueue(); void setTimeline(Timeline timeline); boolean updateRepeatMode(@RepeatMode int repeatMode); boolean updateShuffleModeEnabled(boolean shuffleModeEnabled); boolean isLoading(MediaPeriod mediaPeriod); void reevaluateBuffer(long rendererPositionUs); boolean shouldLoadNextMediaPeriod(); @Nullable MediaPeriodInfo getNextMediaPeriodInfo(
      long rendererPositionUs, PlaybackInfo playbackInfo); MediaPeriod enqueueNextMediaPeriod(
      RendererCapabilities[] rendererCapabilities,
      TrackSelector trackSelector,
      Allocator allocator,
      MediaSource mediaSource,
      MediaPeriodInfo info); MediaPeriodHolder getLoadingPeriod(); MediaPeriodHolder getPlayingPeriod(); MediaPeriodHolder getReadingPeriod(); MediaPeriodHolder getFrontPeriod(); boolean hasPlayingPeriod(); MediaPeriodHolder advanceReadingPeriod(); MediaPeriodHolder advancePlayingPeriod(); boolean removeAfter(MediaPeriodHolder mediaPeriodHolder); void clear(boolean keepFrontPeriodUid); boolean updateQueuedPeriods(long rendererPositionUs, long maxRendererReadPositionUs); MediaPeriodInfo getUpdatedMediaPeriodInfo(MediaPeriodInfo info); MediaPeriodId resolveMediaPeriodIdForAds(Object periodUid, long positionUs);  }