use of com.google.android.exoplayer2.source.MediaSourceEventListener in project ExoPlayer by google.
the class DefaultAnalyticsCollector method onLoadStarted.
// MediaSourceEventListener implementation.
@Override
public final void onLoadStarted(int windowIndex, @Nullable MediaPeriodId mediaPeriodId, LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData) {
EventTime eventTime = generateMediaPeriodEventTime(windowIndex, mediaPeriodId);
sendEvent(eventTime, AnalyticsListener.EVENT_LOAD_STARTED, listener -> listener.onLoadStarted(eventTime, loadEventInfo, mediaLoadData));
}
use of com.google.android.exoplayer2.source.MediaSourceEventListener in project ExoPlayer by google.
the class MediaSourceTestRunner method assertCompletedMediaPeriodLoads.
/**
* Asserts that the media source reported completed loads via {@link
* MediaSourceEventListener#onLoadCompleted(int, MediaPeriodId, LoadEventInfo, MediaLoadData)} for
* each specified media period id, and asserts that the associated window index matches the one in
* the last known timeline returned from {@link #prepareSource()}, {@link #assertTimelineChange()}
* or {@link #assertTimelineChangeBlocking()}.
*/
public void assertCompletedMediaPeriodLoads(MediaPeriodId... mediaPeriodIds) {
Timeline.Period period = new Timeline.Period();
HashSet<MediaPeriodId> expectedLoads = new HashSet<>(Arrays.asList(mediaPeriodIds));
for (Pair<Integer, MediaPeriodId> windowIndexAndMediaPeriodId : completedLoads) {
int windowIndex = windowIndexAndMediaPeriodId.first;
MediaPeriodId mediaPeriodId = windowIndexAndMediaPeriodId.second;
if (expectedLoads.remove(mediaPeriodId)) {
int periodIndex = timeline.getIndexOfPeriod(mediaPeriodId.periodUid);
assertThat(windowIndex).isEqualTo(timeline.getPeriod(periodIndex, period).windowIndex);
}
}
assertWithMessage("Not all expected media source loads have been completed.").that(expectedLoads).isEmpty();
}
Aggregations