LoadErrorHandlingPolicy
@UnstableApi
public interface LoadErrorHandlingPolicy
DefaultLoadErrorHandlingPolicy |
Default implementation of |
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 when a load error occurs. The 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. 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 retries have been attempted.
Methods are invoked on the playback thread.
Summary
Nested types |
|---|
public final class LoadErrorHandlingPolicy.FallbackOptionsHolds information about the available fallback options. |
public final class LoadErrorHandlingPolicy.FallbackSelectionA selected fallback option. |
@DocumentedFallback type. |
public final class LoadErrorHandlingPolicy.LoadErrorInfoHolds information about a load task error. |
Constants |
|
|---|---|
default static final int |
Fallback to the same resource at a different location (i.e., a different URL through which the exact same data can be requested). |
default static final 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 methods |
|
|---|---|
abstract @Nullable LoadErrorHandlingPolicy.FallbackSelection |
getFallbackSelectionFor(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. |
abstract int |
getMinimumLoadableRetryCount(int dataType)Returns the minimum number of times to retry a load before a load error that can be retried may be considered fatal. |
abstract long |
getRetryDelayMsFor(Returns whether a loader can retry on encountering an error, and if so the duration to wait before retrying. |
default void |
onLoadTaskConcluded(long loadTaskId)Called once |
Constants
FALLBACK_TYPE_LOCATION
default static final int 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).
FALLBACK_TYPE_TRACK
default static final int 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 methods
getFallbackSelectionFor
abstract @Nullable 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.
If the returned fallback type was not advertised as available, then the loader will not fall back.
| Parameters | |
|---|---|
LoadErrorHandlingPolicy.FallbackOptions fallbackOptions |
The available fallback options. |
LoadErrorHandlingPolicy.LoadErrorInfo loadErrorInfo |
A |
| Returns | |
|---|---|
@Nullable LoadErrorHandlingPolicy.FallbackSelection |
The selected fallback, or |
getMinimumLoadableRetryCount
abstract int getMinimumLoadableRetryCount(int dataType)
Returns the minimum number of times to retry a load before a load error that can be retried may be considered fatal.
| Parameters | |
|---|---|
int dataType |
One of the |
| Returns | |
|---|---|
int |
The minimum number of times to retry a load before a load error that can be retried may be considered fatal. |
| See also | |
|---|---|
startLoading |
getRetryDelayMsFor
abstract long getRetryDelayMsFor(
LoadErrorHandlingPolicy.LoadErrorInfo loadErrorInfo
)
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 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 | |
|---|---|
LoadErrorHandlingPolicy.LoadErrorInfo loadErrorInfo |
A |
| Returns | |
|---|---|
long |
The duration to wait before retrying in milliseconds, or |
onLoadTaskConcluded
default void onLoadTaskConcluded(long loadTaskId)
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.