Package com.google.android.exoplayer2.upstream

## Interface Loader.Callback<T extends Loader.Loadable>

- All Known Implementing Classes:
    `ChunkSampleStream`, `DefaultHlsPlaylistTracker`, `SsMediaSource`
  Enclosing class:
    Loader

      public static interface Loader.Callback<T extends Loader.Loadable>

  A callback to be notified of `Loader` events.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `onLoadCanceled​(T loadable, long elapsedRealtimeMs, long loadDurationMs, boolean released)` | Called when a load has been canceled.
    `void` | `onLoadCompleted​(T loadable, long elapsedRealtimeMs, long loadDurationMs)` | Called when a load has completed.
    `Loader.LoadErrorAction` | `onLoadError​(T loadable, long elapsedRealtimeMs, long loadDurationMs, IOException error, int errorCount)` | Called when a load encounters an error.

- - ### Method Detail

    - #### onLoadCompleted

          void onLoadCompleted​(T loadable,
                               long elapsedRealtimeMs,
                               long loadDurationMs)

      Called when a load has completed.

      Note: There is guaranteed to be a memory barrier between `Loader.Loadable.load()` exiting and this callback being called.

      Parameters:
        `loadable` - The loadable whose load has completed.
        `elapsedRealtimeMs` - `SystemClock.elapsedRealtime()` when the load ended.
        `loadDurationMs` - The duration in milliseconds of the load since `Loader.startLoading(T, com.google.android.exoplayer2.upstream.Loader.Callback<T>, int)` was called.

    - #### onLoadCanceled

          void onLoadCanceled​(T loadable,
                              long elapsedRealtimeMs,
                              long loadDurationMs,
                              boolean released)

      Called when a load has been canceled.

      Note: If the `Loader` has not been released then there is guaranteed to be a memory barrier between `Loader.Loadable.load()` exiting and this callback being called. If the `Loader` has been released then this callback may be called before `Loader.Loadable.load()` exits.

      Parameters:
        `loadable` - The loadable whose load has been canceled.
        `elapsedRealtimeMs` - `SystemClock.elapsedRealtime()` when the load was canceled.
        `loadDurationMs` - The duration in milliseconds of the load since `Loader.startLoading(T, com.google.android.exoplayer2.upstream.Loader.Callback<T>, int)` was called up to the point at which it was canceled.
        `released` - True if the load was canceled because the `Loader` was released. False otherwise.

    - #### onLoadError

          Loader.LoadErrorAction onLoadError​(T loadable,
                                             long elapsedRealtimeMs,
                                             long loadDurationMs,
                                             IOException error,
                                             int errorCount)

      Called when a load encounters an error.

      Note: There is guaranteed to be a memory barrier between `Loader.Loadable.load()` exiting and this callback being called.

      Parameters:
        `loadable` - The loadable whose load has encountered an error.
        `elapsedRealtimeMs` - `SystemClock.elapsedRealtime()` when the error occurred.
        `loadDurationMs` - The duration in milliseconds of the load since `Loader.startLoading(T, com.google.android.exoplayer2.upstream.Loader.Callback<T>, int)` was called up to the point at which the error occurred.
        `error` - The load error.
        `errorCount` - The number of errors this load has encountered, including this one.
      Returns:
        The desired error handling action. One of `Loader.RETRY`, `Loader.RETRY_RESET_ERROR_COUNT`, `Loader.DONT_RETRY`, `Loader.DONT_RETRY_FATAL` or a retry action created by `Loader.createRetryAction(boolean, long)`.