# LoadErrorHandlingPolicy

# LoadErrorHandlingPolicy

Artifact:[androidx.media3:media3-exoplayer](https://developer.android.com/jetpack/androidx/releases/media3)  
[View Source](https://cs.android.com/search?q=file:androidx/media3/exoplayer/upstream/LoadErrorHandlingPolicy.java+class:androidx.media3.exoplayer.upstream.LoadErrorHandlingPolicy)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/media3/exoplayer/upstream/LoadErrorHandlingPolicy "View this page in Java")

<br />

```
@UnstableApi
interface LoadErrorHandlingPolicy
```

<br />

Known direct subclasses  
[DefaultLoadErrorHandlingPolicy](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/DefaultLoadErrorHandlingPolicy)  

|----------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [DefaultLoadErrorHandlingPolicy](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/DefaultLoadErrorHandlingPolicy) | Default implementation of[LoadErrorHandlingPolicy](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/LoadErrorHandlingPolicy). |

*** ** * ** ***

A policy that defines how load errors are handled.

Some loaders are able to choose between a number of alternate resources. Such loaders will call[getFallbackSelectionFor](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/LoadErrorHandlingPolicy#getFallbackSelectionFor(androidx.media3.exoplayer.upstream.LoadErrorHandlingPolicy.FallbackOptions,androidx.media3.exoplayer.upstream.LoadErrorHandlingPolicy.LoadErrorInfo))when a load error occurs. The[FallbackSelection](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/LoadErrorHandlingPolicy.FallbackSelection)returned by the policy defines whether the loader should fall back to using another resource, and if so the duration for which the failing resource should be excluded.

When fallback does not take place, a loader will call[getRetryDelayMsFor](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/LoadErrorHandlingPolicy#getRetryDelayMsFor(androidx.media3.exoplayer.upstream.LoadErrorHandlingPolicy.LoadErrorInfo)). The value returned by the policy defines whether the failed load can be retried, and if so the duration to wait before retrying. If the policy indicates that a load error should not be retried, it will be considered fatal by the loader. The loader may also consider load errors that can be retried fatal if at least[getMinimumLoadableRetryCount](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/LoadErrorHandlingPolicy#getMinimumLoadableRetryCount(int))retries have been attempted.

Methods are invoked on the playback thread.

## Summary

|                                                                                                                                                                                                                                                                                                                                                                                                             ### Nested types                                                                                                                                                                                                                                                                                                                                                                                                              |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `class `[LoadErrorHandlingPolicy.FallbackOptions](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/LoadErrorHandlingPolicy.FallbackOptions) Holds information about the available fallback options.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `class `[LoadErrorHandlingPolicy.FallbackSelection](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/LoadErrorHandlingPolicy.FallbackSelection) A selected fallback option.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `@`[Documented](https://developer.android.com/reference/java/lang/annotation/Documented.html) `@`[Retention](https://developer.android.com/reference/java/lang/annotation/Retention.html)`(value = `[RetentionPolicy.SOURCE](https://developer.android.com/reference/java/lang/annotation/RetentionPolicy.html#SOURCE)`)` `@`[Target](https://developer.android.com/reference/java/lang/annotation/Target.html)`(value = `[ElementType.TYPE_USE](https://developer.android.com/reference/java/lang/annotation/ElementType.html#TYPE_USE)`)` `@`[IntDef](https://developer.android.com/reference/kotlin/androidx/annotation/IntDef)`(value = )` `annotation `[LoadErrorHandlingPolicy.FallbackType](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/LoadErrorHandlingPolicy.FallbackType) Fallback type. |
| `class `[LoadErrorHandlingPolicy.LoadErrorInfo](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/LoadErrorHandlingPolicy.LoadErrorInfo) Holds information about a load task error.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |

|                                    ### Constants                                    |
|-------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [FALLBACK_TYPE_LOCATION](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/LoadErrorHandlingPolicy#FALLBACK_TYPE_LOCATION())` = 1` Fallback to the same resource at a different location (i.e., a different URL through which the exact same data can be requested).                        |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [FALLBACK_TYPE_TRACK](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/LoadErrorHandlingPolicy#FALLBACK_TYPE_TRACK())` = 2` Fallback to a different track (i.e., a different representation of the same content; for example the same video encoded at a different bitrate or resolution). |

|                                                                            ### Public functions                                                                             |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [LoadErrorHandlingPolicy.FallbackSelection](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/LoadErrorHandlingPolicy.FallbackSelection)`?` | [getFallbackSelectionFor](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/LoadErrorHandlingPolicy#getFallbackSelectionFor(androidx.media3.exoplayer.upstream.LoadErrorHandlingPolicy.FallbackOptions,androidx.media3.exoplayer.upstream.LoadErrorHandlingPolicy.LoadErrorInfo))`(` ` fallbackOptions: `[LoadErrorHandlingPolicy.FallbackOptions](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/LoadErrorHandlingPolicy.FallbackOptions)`!,` ` loadErrorInfo: `[LoadErrorHandlingPolicy.LoadErrorInfo](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/LoadErrorHandlingPolicy.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](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                                                                                 | [getMinimumLoadableRetryCount](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/LoadErrorHandlingPolicy#getMinimumLoadableRetryCount(int))`(dataType: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Returns the minimum number of times to retry a load before a load error that can be retried may be considered fatal.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)                                                                                               | [getRetryDelayMsFor](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/LoadErrorHandlingPolicy#getRetryDelayMsFor(androidx.media3.exoplayer.upstream.LoadErrorHandlingPolicy.LoadErrorInfo))`(` ` loadErrorInfo: `[LoadErrorHandlingPolicy.LoadErrorInfo](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/LoadErrorHandlingPolicy.LoadErrorInfo)`!` `)` Returns whether a loader can retry on encountering an error, and if so the duration to wait before retrying.                                                                                                                                                                                                                                                                                                                                              |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                                                               | [onLoadTaskConcluded](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/LoadErrorHandlingPolicy#onLoadTaskConcluded(long))`(loadTaskId: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`)` Called once`loadTaskId`will not be associated with any more load errors.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |

## Constants

### FALLBACK_TYPE_LOCATION

```
const val FALLBACK_TYPE_LOCATION = 1: Int
```

Fallback to the same resource at a different location (i.e., a different URL through which the exact same data can be requested).  

### FALLBACK_TYPE_TRACK

```
const val FALLBACK_TYPE_TRACK = 2: Int
```

Fallback to a different track (i.e., a different representation of the same content; for example the same video encoded at a different bitrate or resolution).  

## Public functions

### getFallbackSelectionFor

```
fun getFallbackSelectionFor(
    fallbackOptions: LoadErrorHandlingPolicy.FallbackOptions!,
    loadErrorInfo: LoadErrorHandlingPolicy.LoadErrorInfo!
): LoadErrorHandlingPolicy.FallbackSelection?
```

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.

If the returned[fallback type](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/LoadErrorHandlingPolicy.FallbackSelection#type())was not[advertised as available](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/LoadErrorHandlingPolicy.FallbackOptions#isFallbackAvailable(int)), then the loader will not fall back.  

|                                                                                         Parameters                                                                                         |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `fallbackOptions: `[LoadErrorHandlingPolicy.FallbackOptions](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/LoadErrorHandlingPolicy.FallbackOptions)`!` | The available fallback options.                                                                                                                                                    |
| `loadErrorInfo: `[LoadErrorHandlingPolicy.LoadErrorInfo](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/LoadErrorHandlingPolicy.LoadErrorInfo)`!`       | A[LoadErrorInfo](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/LoadErrorHandlingPolicy.LoadErrorInfo)holding information about the load error. |

|                                                                                   Returns                                                                                   |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------|
| [LoadErrorHandlingPolicy.FallbackSelection](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/LoadErrorHandlingPolicy.FallbackSelection)`?` | The selected fallback, or`null`if the calling loader should not fall back. |

### getMinimumLoadableRetryCount

```
fun getMinimumLoadableRetryCount(dataType: Int): Int
```

Returns the minimum number of times to retry a load before a load error that can be retried may be considered fatal.  

|                                       Parameters                                        |
|-----------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------|
| `dataType: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | One of the[C.DATA_TYPE_*](https://developer.android.com/reference/kotlin/androidx/media3/common/C)constants indicating the type of data being loaded. |

|                                   Returns                                   |
|-----------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The minimum number of times to retry a load before a load error that can be retried may be considered fatal. |

|                                                                                      See also                                                                                      |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [startLoading](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/Loader#startLoading(T,androidx.media3.exoplayer.upstream.Loader.Callback<T>,int)) |   |

### getRetryDelayMsFor

```
fun getRetryDelayMsFor(
    loadErrorInfo: LoadErrorHandlingPolicy.LoadErrorInfo!
): Long
```

Returns whether a loader can retry on encountering an error, and if so the duration to wait before retrying. A return value of[TIME_UNSET](https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET())indicates that the error is fatal and should not be retried.

For loads that can be retried, loaders may ignore the retry delay returned by this method in order to wait for a specific event before retrying.  

|                                                                                      Parameters                                                                                      |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `loadErrorInfo: `[LoadErrorHandlingPolicy.LoadErrorInfo](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/LoadErrorHandlingPolicy.LoadErrorInfo)`!` | A[LoadErrorInfo](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/LoadErrorHandlingPolicy.LoadErrorInfo)holding information about the load error. |

|                                    Returns                                    |
|-------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) | The duration to wait before retrying in milliseconds, or[TIME_UNSET](https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET())if the error is fatal and should not be retried. |

### onLoadTaskConcluded

```
fun onLoadTaskConcluded(loadTaskId: Long): Unit
```

Called once`loadTaskId`will not be associated with any more load errors.

Implementations should clean up any resources associated with`loadTaskId`when this method is called.