MediaSourceEventListener


@UnstableApi
interface MediaSourceEventListener

Known direct subclasses
AnalyticsCollector

Interface for data collectors that forward analytics events to AnalyticsListeners.

ServerSideAdInsertionMediaSource

A MediaSource for server-side inserted ad breaks.

Known indirect subclasses
DefaultAnalyticsCollector

Data collector that forwards analytics events to AnalyticsListeners.


Interface for callbacks to be notified of MediaSource events.

Summary

Nested types

Dispatches events to MediaSourceEventListeners.

Public functions

Unit
onDownstreamFormatChanged(
    windowIndex: Int,
    mediaPeriodId: MediaSource.MediaPeriodId?,
    mediaLoadData: MediaLoadData!
)

Called when a downstream format change occurs (i.e. when the format of the media being read from one or more SampleStreams provided by the source changes).

Unit
onLoadCanceled(
    windowIndex: Int,
    mediaPeriodId: MediaSource.MediaPeriodId?,
    loadEventInfo: LoadEventInfo!,
    mediaLoadData: MediaLoadData!
)

Called when a load is canceled.

Unit
onLoadCompleted(
    windowIndex: Int,
    mediaPeriodId: MediaSource.MediaPeriodId?,
    loadEventInfo: LoadEventInfo!,
    mediaLoadData: MediaLoadData!
)

Called when a load ends.

Unit
onLoadError(
    windowIndex: Int,
    mediaPeriodId: MediaSource.MediaPeriodId?,
    loadEventInfo: LoadEventInfo!,
    mediaLoadData: MediaLoadData!,
    error: IOException!,
    wasCanceled: Boolean
)

Called when a load error occurs.

Unit
onLoadStarted(
    windowIndex: Int,
    mediaPeriodId: MediaSource.MediaPeriodId?,
    loadEventInfo: LoadEventInfo!,
    mediaLoadData: MediaLoadData!
)

Called when a load begins.

Unit
onUpstreamDiscarded(
    windowIndex: Int,
    mediaPeriodId: MediaSource.MediaPeriodId!,
    mediaLoadData: MediaLoadData!
)

Called when data is removed from the back of a media buffer, typically so that it can be re-buffered in a different format.

Public functions

onDownstreamFormatChanged

fun onDownstreamFormatChanged(
    windowIndex: Int,
    mediaPeriodId: MediaSource.MediaPeriodId?,
    mediaLoadData: MediaLoadData!
): Unit

Called when a downstream format change occurs (i.e. when the format of the media being read from one or more SampleStreams provided by the source changes).

Parameters
windowIndex: Int

The window index in the timeline of the media source this load belongs to.

mediaPeriodId: MediaSource.MediaPeriodId?

The MediaPeriodId the media belongs to.

mediaLoadData: MediaLoadData!

The MediaLoadData defining the newly selected downstream data.

onLoadCanceled

fun onLoadCanceled(
    windowIndex: Int,
    mediaPeriodId: MediaSource.MediaPeriodId?,
    loadEventInfo: LoadEventInfo!,
    mediaLoadData: MediaLoadData!
): Unit

Called when a load is canceled.

Parameters
windowIndex: Int

The window index in the timeline of the media source this load belongs to.

mediaPeriodId: MediaSource.MediaPeriodId?

The MediaPeriodId this load belongs to. Null if the load does not belong to a specific media period.

loadEventInfo: LoadEventInfo!

The LoadEventInfo corresponding to the event. The values of elapsedRealtimeMs and bytesLoaded are relative to the corresponding onLoadStarted event.

mediaLoadData: MediaLoadData!

The MediaLoadData defining the data being loaded.

onLoadCompleted

fun onLoadCompleted(
    windowIndex: Int,
    mediaPeriodId: MediaSource.MediaPeriodId?,
    loadEventInfo: LoadEventInfo!,
    mediaLoadData: MediaLoadData!
): Unit

Called when a load ends.

Parameters
windowIndex: Int

The window index in the timeline of the media source this load belongs to.

mediaPeriodId: MediaSource.MediaPeriodId?

The MediaPeriodId this load belongs to. Null if the load does not belong to a specific media period.

loadEventInfo: LoadEventInfo!

The LoadEventInfo corresponding to the event. The values of elapsedRealtimeMs and bytesLoaded are relative to the corresponding onLoadStarted event.

mediaLoadData: MediaLoadData!

The MediaLoadData defining the data being loaded.

onLoadError

fun onLoadError(
    windowIndex: Int,
    mediaPeriodId: MediaSource.MediaPeriodId?,
    loadEventInfo: LoadEventInfo!,
    mediaLoadData: MediaLoadData!,
    error: IOException!,
    wasCanceled: Boolean
): Unit

Called when a load error occurs.

The error may or may not have resulted in the load being canceled, as indicated by the wasCanceled parameter. If the load was canceled, onLoadCanceled will not be called in addition to this method.

This method being called does not indicate that playback has failed, or that it will fail. The player may be able to recover from the error. Hence applications should not implement this method to display a user visible error or initiate an application level retry. onPlayerError is the appropriate place to implement such behavior. This method is called to provide the application with an opportunity to log the error if it wishes to do so.

Parameters
windowIndex: Int

The window index in the timeline of the media source this load belongs to.

mediaPeriodId: MediaSource.MediaPeriodId?

The MediaPeriodId this load belongs to. Null if the load does not belong to a specific media period.

loadEventInfo: LoadEventInfo!

The LoadEventInfo corresponding to the event. The values of elapsedRealtimeMs and bytesLoaded are relative to the corresponding onLoadStarted event.

mediaLoadData: MediaLoadData!

The MediaLoadData defining the data being loaded.

error: IOException!

The load error.

wasCanceled: Boolean

Whether the load was canceled as a result of the error.

onLoadStarted

fun onLoadStarted(
    windowIndex: Int,
    mediaPeriodId: MediaSource.MediaPeriodId?,
    loadEventInfo: LoadEventInfo!,
    mediaLoadData: MediaLoadData!
): Unit

Called when a load begins.

Parameters
windowIndex: Int

The window index in the timeline of the media source this load belongs to.

mediaPeriodId: MediaSource.MediaPeriodId?

The MediaPeriodId this load belongs to. Null if the load does not belong to a specific media period.

loadEventInfo: LoadEventInfo!

The LoadEventInfo corresponding to the event. The value of uri won't reflect potential redirection yet and responseHeaders will be empty.

mediaLoadData: MediaLoadData!

The MediaLoadData defining the data being loaded.

onUpstreamDiscarded

fun onUpstreamDiscarded(
    windowIndex: Int,
    mediaPeriodId: MediaSource.MediaPeriodId!,
    mediaLoadData: MediaLoadData!
): Unit

Called when data is removed from the back of a media buffer, typically so that it can be re-buffered in a different format.

Parameters
windowIndex: Int

The window index in the timeline of the media source this load belongs to.

mediaPeriodId: MediaSource.MediaPeriodId!

The MediaPeriodId the media belongs to.

mediaLoadData: MediaLoadData!

The MediaLoadData defining the media being discarded.