Search in sources :

Example 6 with SinglePeriodAdTimeline

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 } })));
}
Also used : Allocator(com.google.android.exoplayer2.upstream.Allocator) MediaPeriodId(com.google.android.exoplayer2.source.MediaSource.MediaPeriodId) Test(org.junit.Test)

Example 7 with SinglePeriodAdTimeline

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);
}
Also used : AdPlaybackState(com.google.android.exoplayer2.source.ads.AdPlaybackState) SinglePeriodAdTimeline(com.google.android.exoplayer2.source.ads.SinglePeriodAdTimeline)

Example 8 with SinglePeriodAdTimeline

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));
        }
    }
}
Also used : Timeline(com.google.android.exoplayer2.Timeline) Nullable(androidx.annotation.Nullable)

Aggregations

SinglePeriodAdTimeline (com.google.android.exoplayer2.source.ads.SinglePeriodAdTimeline)5 Test (org.junit.Test)5 AdPlaybackState (com.google.android.exoplayer2.source.ads.AdPlaybackState)4 MediaPeriodId (com.google.android.exoplayer2.source.MediaSource.MediaPeriodId)2 Allocator (com.google.android.exoplayer2.upstream.Allocator)2 Nullable (androidx.annotation.Nullable)1 Timeline (com.google.android.exoplayer2.Timeline)1