Package com.google.android.exoplayer2.upstream

## Class DefaultLoadErrorHandlingPolicy

- java.lang.Object
- - com.google.android.exoplayer2.upstream.DefaultLoadErrorHandlingPolicy

- All Implemented Interfaces:
    `LoadErrorHandlingPolicy`

      public class DefaultLoadErrorHandlingPolicy
      extends Object
      implements LoadErrorHandlingPolicy

  Default implementation of `LoadErrorHandlingPolicy`.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface com.google.android.exoplayer2.upstream.LoadErrorHandlingPolicy

      `LoadErrorHandlingPolicy.LoadErrorInfo`

  - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static int` | `DEFAULT_MIN_LOADABLE_RETRY_COUNT` | The default minimum number of times to retry loading data prior to propagating the error.
    `static int` | `DEFAULT_MIN_LOADABLE_RETRY_COUNT_PROGRESSIVE_LIVE` | The default minimum number of times to retry loading prior to failing for progressive live streams.
    `static long` | `DEFAULT_TRACK_BLACKLIST_MS` | The default duration for which a track is excluded in milliseconds.

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `DefaultLoadErrorHandlingPolicy()` | Creates an instance with default behavior.
    `DefaultLoadErrorHandlingPolicy​(int minimumLoadableRetryCount)` | Creates an instance with the given value for `getMinimumLoadableRetryCount(int)`.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `long` | `getBlacklistDurationMsFor​(LoadErrorHandlingPolicy.LoadErrorInfo loadErrorInfo)` | Returns the exclusion duration, given by `DEFAULT_TRACK_BLACKLIST_MS`, if the load error was an `HttpDataSource.InvalidResponseCodeException` with response code HTTP 404, 410 or 416, or `C.TIME_UNSET` otherwise.
    `int` | `getMinimumLoadableRetryCount​(int dataType)` | See `DefaultLoadErrorHandlingPolicy()` and `DefaultLoadErrorHandlingPolicy(int)` for documentation about the behavior of this method.
    `long` | `getRetryDelayMsFor​(LoadErrorHandlingPolicy.LoadErrorInfo loadErrorInfo)` | Retries for any exception that is not a subclass of `ParserException`, `FileNotFoundException`, `HttpDataSource.CleartextNotPermittedException` or `Loader.UnexpectedLoaderException`.

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

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

    - ### Methods inherited from interface com.google.android.exoplayer2.upstream.LoadErrorHandlingPolicy

      `getBlacklistDurationMsFor, getRetryDelayMsFor, onLoadTaskConcluded`

- - ### Field Detail

    - #### DEFAULT_MIN_LOADABLE_RETRY_COUNT

          public static final int DEFAULT_MIN_LOADABLE_RETRY_COUNT

      The default minimum number of times to retry loading data prior to propagating the error.
      See Also:
        Constant Field Values

    - #### DEFAULT_MIN_LOADABLE_RETRY_COUNT_PROGRESSIVE_LIVE

          public static final int DEFAULT_MIN_LOADABLE_RETRY_COUNT_PROGRESSIVE_LIVE

      The default minimum number of times to retry loading prior to failing for progressive live streams.
      See Also:
        Constant Field Values

    - #### DEFAULT_TRACK_BLACKLIST_MS

          public static final long DEFAULT_TRACK_BLACKLIST_MS

      The default duration for which a track is excluded in milliseconds.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### DefaultLoadErrorHandlingPolicy

          public DefaultLoadErrorHandlingPolicy()

      Creates an instance with default behavior.

      `getMinimumLoadableRetryCount(int)` will return `DEFAULT_MIN_LOADABLE_RETRY_COUNT_PROGRESSIVE_LIVE` for `dataType` `C.DATA_TYPE_MEDIA_PROGRESSIVE_LIVE`. For other `dataType` values, it will return `DEFAULT_MIN_LOADABLE_RETRY_COUNT`.

    - #### DefaultLoadErrorHandlingPolicy

          public DefaultLoadErrorHandlingPolicy​(int minimumLoadableRetryCount)

      Creates an instance with the given value for `getMinimumLoadableRetryCount(int)`.
      Parameters:
        `minimumLoadableRetryCount` - See `getMinimumLoadableRetryCount(int)`.

  - ### Method Detail

    - #### getBlacklistDurationMsFor

          public long getBlacklistDurationMsFor​(LoadErrorHandlingPolicy.LoadErrorInfo loadErrorInfo)

      Returns the exclusion duration, given by `DEFAULT_TRACK_BLACKLIST_MS`, if the load error was an `HttpDataSource.InvalidResponseCodeException` with response code HTTP 404, 410 or 416, or `C.TIME_UNSET` otherwise.
      Specified by:
        `getBlacklistDurationMsFor` in interface `LoadErrorHandlingPolicy`
      Parameters:
        `loadErrorInfo` - A `LoadErrorHandlingPolicy.LoadErrorInfo` holding information about the load error.
      Returns:
        The exclusion duration in milliseconds, or `C.TIME_UNSET` if the resource should not be excluded.

    - #### getRetryDelayMsFor

          public long getRetryDelayMsFor​(LoadErrorHandlingPolicy.LoadErrorInfo loadErrorInfo)

      Retries for any exception that is not a subclass of `ParserException`, `FileNotFoundException`, `HttpDataSource.CleartextNotPermittedException` or `Loader.UnexpectedLoaderException`. The retry delay is calculated as `Math.min((errorCount - 1) * 1000, 5000)`.
      Specified by:
        `getRetryDelayMsFor` in interface `LoadErrorHandlingPolicy`
      Parameters:
        `loadErrorInfo` - A `LoadErrorHandlingPolicy.LoadErrorInfo` holding information about the load error.
      Returns:
        The number of milliseconds to wait before attempting the load again, or `C.TIME_UNSET` if the error is fatal and should not be retried.

    - #### getMinimumLoadableRetryCount

          public int getMinimumLoadableRetryCount​(int dataType)

      See `DefaultLoadErrorHandlingPolicy()` and `DefaultLoadErrorHandlingPolicy(int)` for documentation about the behavior of this method.
      Specified by:
        `getMinimumLoadableRetryCount` in interface `LoadErrorHandlingPolicy`
      Parameters:
        `dataType` - One of the `C.DATA_TYPE_*` constants indicating the type of data to load.
      Returns:
        The minimum number of times to retry a load in the case of a load error, before propagating the error.
      See Also:
        `Loader.startLoading(Loadable, Callback, int)`