public interface LoadErrorHandlingPolicy
Loaders
are handled.
Loader clients may blacklist a resource when a load error occurs. Blacklisting works around
load errors by loading an alternative resource. Clients do not try blacklisting when a resource
does not have an alternative. When a resource does have valid alternatives, getBlacklistDurationMsFor(int, long, IOException, int)
defines whether the resource should be
blacklisted. Blacklisting will succeed if any of the alternatives is not in the black list.
When blacklisting does not take place, getRetryDelayMsFor(int, long, IOException,
int)
defines whether the load is retried. Errors whose load is not retried are propagated. Load
errors whose load is retried are propagated according to getMinimumLoadableRetryCount(int)
.
Methods are invoked on the playback thread.
Modifier and Type | Method and Description |
---|---|
long |
getBlacklistDurationMsFor(int dataType,
long loadDurationMs,
IOException exception,
int errorCount)
Returns the number of milliseconds for which a resource associated to a provided load error
should be blacklisted, or
C.TIME_UNSET if the resource should not be blacklisted. |
int |
getMinimumLoadableRetryCount(int dataType)
Returns the minimum number of times to retry a load in the case of a load error, before
propagating the error.
|
long |
getRetryDelayMsFor(int dataType,
long loadDurationMs,
IOException exception,
int errorCount)
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. |
long getBlacklistDurationMsFor(int dataType, long loadDurationMs, IOException exception, int errorCount)
C.TIME_UNSET
if the resource should not be blacklisted.dataType
- One of the C.DATA_TYPE_*
constants indicating the type of data to
load.loadDurationMs
- The duration in milliseconds of the load up to the point at which the
error occurred, including any previous attempts.exception
- The load error.errorCount
- The number of errors this load has encountered, including this one.C.TIME_UNSET
if the resource should
not be blacklisted.long getRetryDelayMsFor(int dataType, long loadDurationMs, IOException exception, int errorCount)
C.TIME_UNSET
if the error is fatal and should not be retried.
Loader
clients may ignore the retry delay returned by this method in order to wait
for a specific event before retrying. However, the load is retried if and only if this method
does not return C.TIME_UNSET
.
dataType
- One of the C.DATA_TYPE_*
constants indicating the type of data to
load.loadDurationMs
- The duration in milliseconds of the load up to the point at which the
error occurred, including any previous attempts.exception
- The load error.errorCount
- The number of errors this load has encountered, including this one.C.TIME_UNSET
if the error is fatal and should not be retried.int getMinimumLoadableRetryCount(int dataType)
dataType
- One of the C.DATA_TYPE_*
constants indicating the type of data to
load.Loader.startLoading(Loadable, Callback, int)