DefaultLoadErrorHandlingPolicy


@UnstableApi
public class DefaultLoadErrorHandlingPolicy implements LoadErrorHandlingPolicy


Default implementation of LoadErrorHandlingPolicy.

Summary

Constants

static final long

The default duration for which a location is excluded in milliseconds.

static final int

The default minimum number of times to retry loading data prior to propagating the error.

static final int

The default minimum number of times to retry loading prior to failing for progressive live streams.

static final long

This field is deprecated.

Use DEFAULT_TRACK_EXCLUSION_MS instead.

static final long

The default duration for which a track is excluded in milliseconds.

Public constructors

Creates an instance with default behavior.

DefaultLoadErrorHandlingPolicy(int minimumLoadableRetryCount)

Creates an instance with the given value for getMinimumLoadableRetryCount.

Public methods

@Nullable 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.

int

See DefaultLoadErrorHandlingPolicy and DefaultLoadErrorHandlingPolicy for documentation about the behavior of this method.

long

Retries for any exception that is not a subclass of ParserException, , CleartextNotPermittedException or , and for which isCausedByPositionOutOfRange returns false.

Protected methods

boolean

Returns whether an error should trigger a fallback if possible.

Inherited Constants

From androidx.media3.exoplayer.upstream.LoadErrorHandlingPolicy
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).

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).

Inherited methods

From androidx.media3.exoplayer.upstream.LoadErrorHandlingPolicy
void
onLoadTaskConcluded(long loadTaskId)

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

Constants

DEFAULT_LOCATION_EXCLUSION_MS

public static final long DEFAULT_LOCATION_EXCLUSION_MS = 300000

The default duration for which a location is excluded in milliseconds.

DEFAULT_MIN_LOADABLE_RETRY_COUNT

public static final int DEFAULT_MIN_LOADABLE_RETRY_COUNT = 3

The default minimum number of times to retry loading data prior to propagating the error.

DEFAULT_MIN_LOADABLE_RETRY_COUNT_PROGRESSIVE_LIVE

public static final int DEFAULT_MIN_LOADABLE_RETRY_COUNT_PROGRESSIVE_LIVE = 6

The default minimum number of times to retry loading prior to failing for progressive live streams.

DEFAULT_TRACK_BLACKLIST_MS

public static final long DEFAULT_TRACK_BLACKLIST_MS = 60000

DEFAULT_TRACK_EXCLUSION_MS

public static final long DEFAULT_TRACK_EXCLUSION_MS = 60000

The default duration for which a track is excluded in milliseconds.

Public constructors

DefaultLoadErrorHandlingPolicy

public DefaultLoadErrorHandlingPolicy()

Creates an instance with default behavior.

getMinimumLoadableRetryCount will return DEFAULT_MIN_LOADABLE_RETRY_COUNT_PROGRESSIVE_LIVE for dataTypeDATA_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.

Parameters
int minimumLoadableRetryCount

See getMinimumLoadableRetryCount.

Public methods

getFallbackSelectionFor

public @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.

getMinimumLoadableRetryCount

public int getMinimumLoadableRetryCount(int dataType)

See DefaultLoadErrorHandlingPolicy and DefaultLoadErrorHandlingPolicy for documentation about the behavior of this method.

getRetryDelayMsFor

public long getRetryDelayMsFor(
    LoadErrorHandlingPolicy.LoadErrorInfo loadErrorInfo
)

Retries for any exception that is not a subclass of ParserException, , CleartextNotPermittedException or , and for which isCausedByPositionOutOfRange returns false. The retry delay is calculated as Math.min((errorCount - 1) * 1000, 5000).

Protected methods

isEligibleForFallback

protected boolean isEligibleForFallback(IOException exception)

Returns whether an error should trigger a fallback if possible.