use of com.google.android.exoplayer2.source.MediaSource.MediaPeriodId in project ExoPlayer by google.
the class DefaultAnalyticsCollector method onLoadCompleted.
@Override
public final void onLoadCompleted(int windowIndex, @Nullable MediaPeriodId mediaPeriodId, LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData) {
EventTime eventTime = generateMediaPeriodEventTime(windowIndex, mediaPeriodId);
sendEvent(eventTime, AnalyticsListener.EVENT_LOAD_COMPLETED, listener -> listener.onLoadCompleted(eventTime, loadEventInfo, mediaLoadData));
}
use of com.google.android.exoplayer2.source.MediaSource.MediaPeriodId in project ExoPlayer by google.
the class ConcatenatingMediaSourceTest method removeChildSourceWithActiveMediaPeriod.
@Test
public void removeChildSourceWithActiveMediaPeriod() throws IOException {
FakeMediaSource childSource = createFakeMediaSource();
mediaSource.addMediaSource(childSource);
Timeline timeline = testRunner.prepareSource();
MediaPeriod mediaPeriod = testRunner.createPeriod(new MediaPeriodId(timeline.getUidOfPeriod(/* periodIndex= */
0), /* windowSequenceNumber= */
0));
mediaSource.removeMediaSource(/* index= */
0);
testRunner.assertTimelineChangeBlocking();
testRunner.releasePeriod(mediaPeriod);
childSource.assertReleased();
testRunner.releaseSource();
}
use of com.google.android.exoplayer2.source.MediaSource.MediaPeriodId in project ExoPlayer by google.
the class ConcatenatingMediaSourceTest method duplicateMediaSources.
@Test
public void duplicateMediaSources() throws IOException, InterruptedException {
Timeline childTimeline = new FakeTimeline(/* windowCount= */
2);
FakeMediaSource childSource = new FakeMediaSource(childTimeline);
mediaSource.addMediaSource(childSource);
mediaSource.addMediaSource(childSource);
testRunner.prepareSource();
mediaSource.addMediaSources(Arrays.asList(childSource, childSource));
Timeline timeline = testRunner.assertTimelineChangeBlocking();
TimelineAsserts.assertPeriodCounts(timeline, 1, 1, 1, 1, 1, 1, 1, 1);
testRunner.assertPrepareAndReleaseAllPeriods();
Object childPeriodUid0 = childTimeline.getUidOfPeriod(/* periodIndex= */
0);
Object childPeriodUid1 = childTimeline.getUidOfPeriod(/* periodIndex= */
1);
assertThat(childSource.getCreatedMediaPeriods()).containsAtLeast(new MediaPeriodId(childPeriodUid0, /* windowSequenceNumber= */
0), new MediaPeriodId(childPeriodUid0, /* windowSequenceNumber= */
2), new MediaPeriodId(childPeriodUid0, /* windowSequenceNumber= */
4), new MediaPeriodId(childPeriodUid0, /* windowSequenceNumber= */
6), new MediaPeriodId(childPeriodUid1, /* windowSequenceNumber= */
1), new MediaPeriodId(childPeriodUid1, /* windowSequenceNumber= */
3), new MediaPeriodId(childPeriodUid1, /* windowSequenceNumber= */
5), new MediaPeriodId(childPeriodUid1, /* windowSequenceNumber= */
7));
// Assert that only one manifest load is reported because the source is reused.
testRunner.assertCompletedManifestLoads(/* windowIndices=... */
0);
assertCompletedAllMediaPeriodLoads(timeline);
testRunner.releaseSource();
childSource.assertReleased();
}
use of com.google.android.exoplayer2.source.MediaSource.MediaPeriodId in project ExoPlayer by google.
the class ConcatenatingMediaSourceTest method childTimelineChangeWithActiveMediaPeriod.
@Test
public void childTimelineChangeWithActiveMediaPeriod() throws IOException {
FakeMediaSource[] nestedChildSources = createMediaSources(/* count= */
2);
ConcatenatingMediaSource childSource = new ConcatenatingMediaSource(nestedChildSources);
mediaSource.addMediaSource(childSource);
Timeline timeline = testRunner.prepareSource();
MediaPeriod mediaPeriod = testRunner.createPeriod(new MediaPeriodId(timeline.getUidOfPeriod(/* periodIndex= */
1), /* windowSequenceNumber= */
0));
childSource.moveMediaSource(/* currentIndex= */
0, /* newIndex= */
1);
timeline = testRunner.assertTimelineChangeBlocking();
testRunner.preparePeriod(mediaPeriod, /* positionUs= */
0);
testRunner.assertCompletedMediaPeriodLoads(new MediaPeriodId(timeline.getUidOfPeriod(/* periodIndex= */
0), /* windowSequenceNumber= */
0));
}
use of com.google.android.exoplayer2.source.MediaSource.MediaPeriodId in project ExoPlayer by google.
the class AdsMediaSourceTest method createPeriod_createsChildPrerollAdMediaPeriod.
@Test
public void createPeriod_createsChildPrerollAdMediaPeriod() {
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();
prerollAdMediaSource.assertMediaPeriodCreated(new MediaPeriodId(PREROLL_AD_PERIOD_UID, /* windowSequenceNumber= */
0));
}
Aggregations