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.FallbackOptions, LoadErrorHandlingPolicy.FallbackSelection, LoadErrorHandlingPolicy.FallbackType, LoadErrorHandlingPolicy.LoadErrorInfo`

  - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static long` | `DEFAULT_LOCATION_EXCLUSION_MS` | The default duration for which a location is excluded in milliseconds.
    `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` | Deprecated. Use `DEFAULT_TRACK_EXCLUSION_MS` instead.
    `static long` | `DEFAULT_TRACK_EXCLUSION_MS` | The default duration for which a track is excluded in milliseconds.

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

      `FALLBACK_TYPE_LOCATION, FALLBACK_TYPE_TRACK`

  - ### 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
    --- | --- | ---
    `LoadErrorHandlingPolicy.FallbackSelection` | `getFallbackSelectionFor​(LoadErrorHandlingPolicy.FallbackOptions fallbackOptions, LoadErrorHandlingPolicy.LoadErrorInfo loadErrorInfo)` | Returns whether a loader should fall back to using another resource on encountering an error, and if so the duration for which the failing resource should be excluded.
    `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`.
    `protected boolean` | `isEligibleForFallback​(IOException exception)` | Returns whether an error should trigger a fallback if possible.

    - ### 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

      `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_EXCLUSION_MS

          public static final long DEFAULT_TRACK_EXCLUSION_MS

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

    - #### DEFAULT_TRACK_BLACKLIST_MS

          @Deprecated
          public static final long DEFAULT_TRACK_BLACKLIST_MS

      Deprecated.
      Use `DEFAULT_TRACK_EXCLUSION_MS` instead.
      See Also:
        Constant Field Values

    - #### DEFAULT_LOCATION_EXCLUSION_MS

          public static final long DEFAULT_LOCATION_EXCLUSION_MS

      The default duration for which a location 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

    - #### getFallbackSelectionFor

          @Nullable
          public LoadErrorHandlingPolicy.FallbackSelection getFallbackSelectionFor​(LoadErrorHandlingPolicy.FallbackOptions fallbackOptions,
                                                                                   LoadErrorHandlingPolicy.LoadErrorInfo loadErrorInfo)

      Returns whether a loader should fall back to using another resource on encountering an error, and if so the duration for which the failing resource should be excluded.
      - This policy will only specify a fallback if `isEligibleForFallback(java.io.IOException)` returns `true` for the error.
      - This policy will always specify a location fallback rather than a track fallback if both `are available`.
      - When a fallback is specified, the duration for which the failing resource will be excluded is `DEFAULT_LOCATION_EXCLUSION_MS` or `DEFAULT_TRACK_EXCLUSION_MS`, depending on the fallback type.
      Specified by:
        `getFallbackSelectionFor` in interface `LoadErrorHandlingPolicy`
      Parameters:
        `fallbackOptions` - The available fallback options.
        `loadErrorInfo` - A `LoadErrorHandlingPolicy.LoadErrorInfo` holding information about the load error.
      Returns:
        The selected fallback, or `null` if the calling loader should not fall back.

    - #### 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 duration to wait before retrying in milliseconds, 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 being loaded.
      Returns:
        The minimum number of times to retry a load before a load error that can be retried may be considered fatal.
      See Also:
        `Loader.startLoading(Loadable, Callback, int)`

    - #### isEligibleForFallback

          protected boolean isEligibleForFallback​(IOException exception)

      Returns whether an error should trigger a fallback if possible.