use of com.google.android.exoplayer2.source.ads.SinglePeriodAdTimeline in project ExoPlayer by google.
the class AdsMediaSourceTest method createPeriod_preparesChildAdMediaSourceAndRefreshesSourceInfoWithAdMediaSourceInfo.
@Test
public void createPeriod_preparesChildAdMediaSourceAndRefreshesSourceInfoWithAdMediaSourceInfo() {
contentMediaSource.setNewSourceInfo(CONTENT_TIMELINE);
adsMediaSource.createPeriod(new MediaPeriodId(CONTENT_PERIOD_UID, /* adGroupIndex= */
0, /* adIndexInAdGroup= */
0, /* windowSequenceNumber= */
0), mock(Allocator.class), /* startPositionUs= */
0);
prerollAdMediaSource.setNewSourceInfo(PREROLL_AD_TIMELINE);
shadowOf(Looper.getMainLooper()).idle();
verify(mockMediaSourceCaller).onSourceInfoRefreshed(adsMediaSource, new SinglePeriodAdTimeline(CONTENT_TIMELINE, AD_PLAYBACK_STATE.withAdDurationsUs(new long[][] { { PREROLL_AD_DURATION_US } })));
}
use of com.google.android.exoplayer2.source.ads.SinglePeriodAdTimeline in project ExoPlayer by google.
the class MediaPeriodQueueTest method setupAdTimeline.
private void setupAdTimeline(long... adGroupTimesUs) {
adPlaybackState = new AdPlaybackState(/* adsId= */
new Object(), adGroupTimesUs).withContentDurationUs(CONTENT_DURATION_US);
SinglePeriodAdTimeline adTimeline = new SinglePeriodAdTimeline(CONTENT_TIMELINE, adPlaybackState);
setupTimeline(adTimeline);
}
use of com.google.android.exoplayer2.source.ads.SinglePeriodAdTimeline in project ExoPlayer by google.
the class AdsMediaSource method maybeUpdateSourceInfo.
private void maybeUpdateSourceInfo() {
@Nullable Timeline contentTimeline = this.contentTimeline;
if (adPlaybackState != null && contentTimeline != null) {
if (adPlaybackState.adGroupCount == 0) {
refreshSourceInfo(contentTimeline);
} else {
adPlaybackState = adPlaybackState.withAdDurationsUs(getAdDurationsUs());
refreshSourceInfo(new SinglePeriodAdTimeline(contentTimeline, adPlaybackState));
}
}
}
Aggregations