MediaSourceEventListener.EventDispatcher


public class MediaSourceEventListener.EventDispatcher


Dispatches events to MediaSourceEventListeners.

Summary

Public fields

final @Nullable MediaSource.MediaPeriodId

The MediaPeriodId reported with the events.

final int

The timeline window index reported with the events.

Public constructors

Creates an event dispatcher.

Public methods

void
addEventListener(
    Handler handler,
    MediaSourceEventListener eventListener
)

Adds a listener to the event dispatcher.

void

Dispatches to a function that supplies a MediaSourceEventListener.

void

Dispatches onDownstreamFormatChanged.

void
downstreamFormatChanged(
    @C.TrackType int trackType,
    @Nullable Format trackFormat,
    @C.SelectionReason int trackSelectionReason,
    @Nullable Object trackSelectionData,
    long mediaTimeUs
)

Dispatches onDownstreamFormatChanged.

void
loadCanceled(LoadEventInfo loadEventInfo, @C.DataType int dataType)

Dispatches onLoadCanceled.

void
loadCanceled(LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData)

Dispatches onLoadCanceled.

void
loadCanceled(
    LoadEventInfo loadEventInfo,
    @C.DataType int dataType,
    @C.TrackType int trackType,
    @Nullable Format trackFormat,
    @C.SelectionReason int trackSelectionReason,
    @Nullable Object trackSelectionData,
    long mediaStartTimeUs,
    long mediaEndTimeUs
)

Dispatches onLoadCanceled.

void
loadCompleted(LoadEventInfo loadEventInfo, @C.DataType int dataType)

Dispatches onLoadCompleted.

void
loadCompleted(LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData)

Dispatches onLoadCompleted.

void
loadCompleted(
    LoadEventInfo loadEventInfo,
    @C.DataType int dataType,
    @C.TrackType int trackType,
    @Nullable Format trackFormat,
    @C.SelectionReason int trackSelectionReason,
    @Nullable Object trackSelectionData,
    long mediaStartTimeUs,
    long mediaEndTimeUs
)

Dispatches onLoadCompleted.

void
loadError(
    LoadEventInfo loadEventInfo,
    @C.DataType int dataType,
    IOException error,
    boolean wasCanceled
)

Dispatches onLoadError.

void
loadError(
    LoadEventInfo loadEventInfo,
    MediaLoadData mediaLoadData,
    IOException error,
    boolean wasCanceled
)

Dispatches onLoadError.

void
loadError(
    LoadEventInfo loadEventInfo,
    @C.DataType int dataType,
    @C.TrackType int trackType,
    @Nullable Format trackFormat,
    @C.SelectionReason int trackSelectionReason,
    @Nullable Object trackSelectionData,
    long mediaStartTimeUs,
    long mediaEndTimeUs,
    IOException error,
    boolean wasCanceled
)

Dispatches onLoadError.

void
loadStarted(LoadEventInfo loadEventInfo, @C.DataType int dataType)

Dispatches onLoadStarted.

void
loadStarted(LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData)

Dispatches onLoadStarted.

void
loadStarted(
    LoadEventInfo loadEventInfo,
    @C.DataType int dataType,
    @C.TrackType int trackType,
    @Nullable Format trackFormat,
    @C.SelectionReason int trackSelectionReason,
    @Nullable Object trackSelectionData,
    long mediaStartTimeUs,
    long mediaEndTimeUs
)

Dispatches onLoadStarted.

void

Removes a listener from the event dispatcher.

void

Dispatches onUpstreamDiscarded.

void
upstreamDiscarded(
    int trackType,
    long mediaStartTimeUs,
    long mediaEndTimeUs
)

Dispatches onUpstreamDiscarded.

MediaSourceEventListener.EventDispatcher
withParameters(
    int windowIndex,
    @Nullable MediaSource.MediaPeriodId mediaPeriodId
)

Creates a view of the event dispatcher with pre-configured window index, media period id, and media time offset.

MediaSourceEventListener.EventDispatcher
withParameters(
    int windowIndex,
    @Nullable MediaSource.MediaPeriodId mediaPeriodId,
    long mediaTimeOffsetMs
)

This method is deprecated.

Use withParameters instead.

Public fields

mediaPeriodId

public final @Nullable MediaSource.MediaPeriodId mediaPeriodId

The MediaPeriodId reported with the events.

windowIndex

public final int windowIndex

The timeline window index reported with the events.

Public constructors

EventDispatcher

public EventDispatcher()

Creates an event dispatcher.

Public methods

addEventListener

public void addEventListener(
    Handler handler,
    MediaSourceEventListener eventListener
)

Adds a listener to the event dispatcher.

Parameters
Handler handler

A handler on the which listener events will be posted.

MediaSourceEventListener eventListener

The listener to be added.

dispatchEvent

public void dispatchEvent(Consumer<MediaSourceEventListener> event)

Dispatches to a function that supplies a MediaSourceEventListener.

downstreamFormatChanged

public void downstreamFormatChanged(MediaLoadData mediaLoadData)

Dispatches onDownstreamFormatChanged.

downstreamFormatChanged

public void downstreamFormatChanged(
    @C.TrackType int trackType,
    @Nullable Format trackFormat,
    @C.SelectionReason int trackSelectionReason,
    @Nullable Object trackSelectionData,
    long mediaTimeUs
)

Dispatches onDownstreamFormatChanged.

loadCanceled

public void loadCanceled(LoadEventInfo loadEventInfo, @C.DataType int dataType)

Dispatches onLoadCanceled.

loadCanceled

public void loadCanceled(LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData)

Dispatches onLoadCanceled.

loadCanceled

public void loadCanceled(
    LoadEventInfo loadEventInfo,
    @C.DataType int dataType,
    @C.TrackType int trackType,
    @Nullable Format trackFormat,
    @C.SelectionReason int trackSelectionReason,
    @Nullable Object trackSelectionData,
    long mediaStartTimeUs,
    long mediaEndTimeUs
)

Dispatches onLoadCanceled.

loadCompleted

public void loadCompleted(LoadEventInfo loadEventInfo, @C.DataType int dataType)

Dispatches onLoadCompleted.

loadCompleted

public void loadCompleted(LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData)

Dispatches onLoadCompleted.

loadCompleted

public void loadCompleted(
    LoadEventInfo loadEventInfo,
    @C.DataType int dataType,
    @C.TrackType int trackType,
    @Nullable Format trackFormat,
    @C.SelectionReason int trackSelectionReason,
    @Nullable Object trackSelectionData,
    long mediaStartTimeUs,
    long mediaEndTimeUs
)

Dispatches onLoadCompleted.

loadError

public void loadError(
    LoadEventInfo loadEventInfo,
    @C.DataType int dataType,
    IOException error,
    boolean wasCanceled
)

Dispatches onLoadError.

loadError

public void loadError(
    LoadEventInfo loadEventInfo,
    MediaLoadData mediaLoadData,
    IOException error,
    boolean wasCanceled
)

Dispatches onLoadError.

loadError

public void loadError(
    LoadEventInfo loadEventInfo,
    @C.DataType int dataType,
    @C.TrackType int trackType,
    @Nullable Format trackFormat,
    @C.SelectionReason int trackSelectionReason,
    @Nullable Object trackSelectionData,
    long mediaStartTimeUs,
    long mediaEndTimeUs,
    IOException error,
    boolean wasCanceled
)

Dispatches onLoadError.

loadStarted

public void loadStarted(LoadEventInfo loadEventInfo, @C.DataType int dataType)

Dispatches onLoadStarted.

loadStarted

public void loadStarted(LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData)

Dispatches onLoadStarted.

loadStarted

public void loadStarted(
    LoadEventInfo loadEventInfo,
    @C.DataType int dataType,
    @C.TrackType int trackType,
    @Nullable Format trackFormat,
    @C.SelectionReason int trackSelectionReason,
    @Nullable Object trackSelectionData,
    long mediaStartTimeUs,
    long mediaEndTimeUs
)

Dispatches onLoadStarted.

removeEventListener

public void removeEventListener(MediaSourceEventListener eventListener)

Removes a listener from the event dispatcher.

Parameters
MediaSourceEventListener eventListener

The listener to be removed.

upstreamDiscarded

public void upstreamDiscarded(MediaLoadData mediaLoadData)

Dispatches onUpstreamDiscarded.

upstreamDiscarded

public void upstreamDiscarded(
    int trackType,
    long mediaStartTimeUs,
    long mediaEndTimeUs
)

Dispatches onUpstreamDiscarded.

withParameters

public MediaSourceEventListener.EventDispatcher withParameters(
    int windowIndex,
    @Nullable MediaSource.MediaPeriodId mediaPeriodId
)

Creates a view of the event dispatcher with pre-configured window index, media period id, and media time offset.

Parameters
int windowIndex

The timeline window index to be reported with the events.

@Nullable MediaSource.MediaPeriodId mediaPeriodId

The MediaPeriodId to be reported with the events.

Returns
MediaSourceEventListener.EventDispatcher

A view of the event dispatcher with the pre-configured parameters.

withParameters

public MediaSourceEventListener.EventDispatcher withParameters(
    int windowIndex,
    @Nullable MediaSource.MediaPeriodId mediaPeriodId,
    long mediaTimeOffsetMs
)

Note: The mediaTimeOffsetMs passed to this method is ignored and not added to media times in any way.