Package com.google.android.exoplayer2.source

## Class MediaSourceEventListener.EventDispatcher

- java.lang.Object
- - com.google.android.exoplayer2.source.MediaSourceEventListener.EventDispatcher

- Enclosing interface:
    MediaSourceEventListener

      public static class MediaSourceEventListener.EventDispatcher
      extends Object

  Dispatches events to `MediaSourceEventListeners`.

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `MediaSource.MediaPeriodId` | `mediaPeriodId` | The `MediaSource.MediaPeriodId` reported with the events.
    `int` | `windowIndex` | The timeline window index reported with the events.

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `EventDispatcher()` | Creates an event dispatcher.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `addEventListener​(Handler handler, MediaSourceEventListener eventListener)` | Adds a listener to the event dispatcher.
    `void` | `downstreamFormatChanged​(int trackType, Format trackFormat, int trackSelectionReason, Object trackSelectionData, long mediaTimeUs)` | Dispatches `MediaSourceEventListener.onDownstreamFormatChanged(int, MediaPeriodId, MediaLoadData)`.
    `void` | `downstreamFormatChanged​(MediaLoadData mediaLoadData)` | Dispatches `MediaSourceEventListener.onDownstreamFormatChanged(int, MediaPeriodId, MediaLoadData)`.
    `void` | `loadCanceled​(LoadEventInfo loadEventInfo, int dataType)` | Dispatches `MediaSourceEventListener.onLoadCanceled(int, MediaPeriodId, LoadEventInfo, MediaLoadData)`.
    `void` | `loadCanceled​(LoadEventInfo loadEventInfo, int dataType, int trackType, Format trackFormat, int trackSelectionReason, Object trackSelectionData, long mediaStartTimeUs, long mediaEndTimeUs)` | Dispatches `MediaSourceEventListener.onLoadCanceled(int, MediaPeriodId, LoadEventInfo, MediaLoadData)`.
    `void` | `loadCanceled​(LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData)` | Dispatches `MediaSourceEventListener.onLoadCanceled(int, MediaPeriodId, LoadEventInfo, MediaLoadData)`.
    `void` | `loadCompleted​(LoadEventInfo loadEventInfo, int dataType)` | Dispatches `MediaSourceEventListener.onLoadCompleted(int, MediaPeriodId, LoadEventInfo, MediaLoadData)`.
    `void` | `loadCompleted​(LoadEventInfo loadEventInfo, int dataType, int trackType, Format trackFormat, int trackSelectionReason, Object trackSelectionData, long mediaStartTimeUs, long mediaEndTimeUs)` | Dispatches `MediaSourceEventListener.onLoadCompleted(int, MediaPeriodId, LoadEventInfo, MediaLoadData)`.
    `void` | `loadCompleted​(LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData)` | Dispatches `MediaSourceEventListener.onLoadCompleted(int, MediaPeriodId, LoadEventInfo, MediaLoadData)`.
    `void` | `loadError​(LoadEventInfo loadEventInfo, int dataType, int trackType, Format trackFormat, int trackSelectionReason, Object trackSelectionData, long mediaStartTimeUs, long mediaEndTimeUs, IOException error, boolean wasCanceled)` | Dispatches `MediaSourceEventListener.onLoadError(int, MediaPeriodId, LoadEventInfo, MediaLoadData, IOException, boolean)`.
    `void` | `loadError​(LoadEventInfo loadEventInfo, int dataType, IOException error, boolean wasCanceled)` | Dispatches `MediaSourceEventListener.onLoadError(int, MediaPeriodId, LoadEventInfo, MediaLoadData, IOException, boolean)`.
    `void` | `loadError​(LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData, IOException error, boolean wasCanceled)` | Dispatches `MediaSourceEventListener.onLoadError(int, MediaPeriodId, LoadEventInfo, MediaLoadData, IOException, boolean)`.
    `void` | `loadStarted​(LoadEventInfo loadEventInfo, int dataType)` | Dispatches `MediaSourceEventListener.onLoadStarted(int, MediaPeriodId, LoadEventInfo, MediaLoadData)`.
    `void` | `loadStarted​(LoadEventInfo loadEventInfo, int dataType, int trackType, Format trackFormat, int trackSelectionReason, Object trackSelectionData, long mediaStartTimeUs, long mediaEndTimeUs)` | Dispatches `MediaSourceEventListener.onLoadStarted(int, MediaPeriodId, LoadEventInfo, MediaLoadData)`.
    `void` | `loadStarted​(LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData)` | Dispatches `MediaSourceEventListener.onLoadStarted(int, MediaPeriodId, LoadEventInfo, MediaLoadData)`.
    `void` | `removeEventListener​(MediaSourceEventListener eventListener)` | Removes a listener from the event dispatcher.
    `void` | `upstreamDiscarded​(int trackType, long mediaStartTimeUs, long mediaEndTimeUs)` | Dispatches `MediaSourceEventListener.onUpstreamDiscarded(int, MediaPeriodId, MediaLoadData)`.
    `void` | `upstreamDiscarded​(MediaLoadData mediaLoadData)` | Dispatches `MediaSourceEventListener.onUpstreamDiscarded(int, MediaPeriodId, MediaLoadData)`.
    `MediaSourceEventListener.EventDispatcher` | `withParameters​(int windowIndex, MediaSource.MediaPeriodId mediaPeriodId, long mediaTimeOffsetMs)` | Creates a view of the event dispatcher with pre-configured window index, media period id, and media time offset.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### windowIndex

          public final int windowIndex

      The timeline window index reported with the events.

    - #### mediaPeriodId

          @Nullable
          public final MediaSource.MediaPeriodId mediaPeriodId

      The `MediaSource.MediaPeriodId` reported with the events.

  - ### Constructor Detail

    - #### EventDispatcher

          public EventDispatcher()

      Creates an event dispatcher.

  - ### Method Detail

    - #### withParameters

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

      Creates a view of the event dispatcher with pre-configured window index, media period id, and media time offset.
      Parameters:
        `windowIndex` - The timeline window index to be reported with the events.
        `mediaPeriodId` - The `MediaSource.MediaPeriodId` to be reported with the events.
        `mediaTimeOffsetMs` - The offset to be added to all media times, in milliseconds.
      Returns:
        A view of the event dispatcher with the pre-configured parameters.

    - #### addEventListener

          public void addEventListener​(Handler handler,
                                       MediaSourceEventListener eventListener)

      Adds a listener to the event dispatcher.
      Parameters:
        `handler` - A handler on the which listener events will be posted.
        `eventListener` - The listener to be added.

    - #### removeEventListener

          public void removeEventListener​(MediaSourceEventListener eventListener)

      Removes a listener from the event dispatcher.
      Parameters:
        `eventListener` - The listener to be removed.

    - #### loadStarted

          public void loadStarted​(LoadEventInfo loadEventInfo,
                                  int dataType)

      Dispatches `MediaSourceEventListener.onLoadStarted(int, MediaPeriodId, LoadEventInfo, MediaLoadData)`.

    - #### loadStarted

          public void loadStarted​(LoadEventInfo loadEventInfo,
                                  int dataType,
                                  int trackType,
                                  @Nullable
                                  Format trackFormat,
                                  int trackSelectionReason,
                                  @Nullable
                                  Object trackSelectionData,
                                  long mediaStartTimeUs,
                                  long mediaEndTimeUs)

      Dispatches `MediaSourceEventListener.onLoadStarted(int, MediaPeriodId, LoadEventInfo, MediaLoadData)`.

    - #### loadStarted

          public void loadStarted​(LoadEventInfo loadEventInfo,
                                  MediaLoadData mediaLoadData)

      Dispatches `MediaSourceEventListener.onLoadStarted(int, MediaPeriodId, LoadEventInfo, MediaLoadData)`.

    - #### loadCompleted

          public void loadCompleted​(LoadEventInfo loadEventInfo,
                                    int dataType)

      Dispatches `MediaSourceEventListener.onLoadCompleted(int, MediaPeriodId, LoadEventInfo, MediaLoadData)`.

    - #### loadCompleted

          public void loadCompleted​(LoadEventInfo loadEventInfo,
                                    int dataType,
                                    int trackType,
                                    @Nullable
                                    Format trackFormat,
                                    int trackSelectionReason,
                                    @Nullable
                                    Object trackSelectionData,
                                    long mediaStartTimeUs,
                                    long mediaEndTimeUs)

      Dispatches `MediaSourceEventListener.onLoadCompleted(int, MediaPeriodId, LoadEventInfo, MediaLoadData)`.

    - #### loadCompleted

          public void loadCompleted​(LoadEventInfo loadEventInfo,
                                    MediaLoadData mediaLoadData)

      Dispatches `MediaSourceEventListener.onLoadCompleted(int, MediaPeriodId, LoadEventInfo, MediaLoadData)`.

    - #### loadCanceled

          public void loadCanceled​(LoadEventInfo loadEventInfo,
                                   int dataType)

      Dispatches `MediaSourceEventListener.onLoadCanceled(int, MediaPeriodId, LoadEventInfo, MediaLoadData)`.

    - #### loadCanceled

          public void loadCanceled​(LoadEventInfo loadEventInfo,
                                   int dataType,
                                   int trackType,
                                   @Nullable
                                   Format trackFormat,
                                   int trackSelectionReason,
                                   @Nullable
                                   Object trackSelectionData,
                                   long mediaStartTimeUs,
                                   long mediaEndTimeUs)

      Dispatches `MediaSourceEventListener.onLoadCanceled(int, MediaPeriodId, LoadEventInfo, MediaLoadData)`.

    - #### loadCanceled

          public void loadCanceled​(LoadEventInfo loadEventInfo,
                                   MediaLoadData mediaLoadData)

      Dispatches `MediaSourceEventListener.onLoadCanceled(int, MediaPeriodId, LoadEventInfo, MediaLoadData)`.

    - #### loadError

          public void loadError​(LoadEventInfo loadEventInfo,
                                int dataType,
                                IOException error,
                                boolean wasCanceled)

      Dispatches `MediaSourceEventListener.onLoadError(int, MediaPeriodId, LoadEventInfo, MediaLoadData, IOException, boolean)`.

    - #### loadError

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

      Dispatches `MediaSourceEventListener.onLoadError(int, MediaPeriodId, LoadEventInfo, MediaLoadData, IOException, boolean)`.

    - #### loadError

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

      Dispatches `MediaSourceEventListener.onLoadError(int, MediaPeriodId, LoadEventInfo, MediaLoadData, IOException, boolean)`.

    - #### upstreamDiscarded

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

      Dispatches `MediaSourceEventListener.onUpstreamDiscarded(int, MediaPeriodId, MediaLoadData)`.

    - #### upstreamDiscarded

          public void upstreamDiscarded​(MediaLoadData mediaLoadData)

      Dispatches `MediaSourceEventListener.onUpstreamDiscarded(int, MediaPeriodId, MediaLoadData)`.

    - #### downstreamFormatChanged

          public void downstreamFormatChanged​(int trackType,
                                              @Nullable
                                              Format trackFormat,
                                              int trackSelectionReason,
                                              @Nullable
                                              Object trackSelectionData,
                                              long mediaTimeUs)

      Dispatches `MediaSourceEventListener.onDownstreamFormatChanged(int, MediaPeriodId, MediaLoadData)`.

    - #### downstreamFormatChanged

          public void downstreamFormatChanged​(MediaLoadData mediaLoadData)

      Dispatches `MediaSourceEventListener.onDownstreamFormatChanged(int, MediaPeriodId, MediaLoadData)`.