DefaultLoadErrorHandlingPolicy


@UnstableApi
class DefaultLoadErrorHandlingPolicy : LoadErrorHandlingPolicy


Default implementation of LoadErrorHandlingPolicy.

Summary

Constants

const Long

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

const Int

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

const Int

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

const Long

This property is deprecated.

Use DEFAULT_TRACK_EXCLUSION_MS instead.

const Long

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

Public constructors

Creates an instance with default behavior.

DefaultLoadErrorHandlingPolicy(minimumLoadableRetryCount: Int)

Creates an instance with the given value for getMinimumLoadableRetryCount.

Public functions

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 functions

Boolean

Returns whether an error should trigger a fallback if possible.

Inherited Constants

From androidx.media3.exoplayer.upstream.LoadErrorHandlingPolicy
const Int

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

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 functions

From androidx.media3.exoplayer.upstream.LoadErrorHandlingPolicy
Unit

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

Constants

DEFAULT_LOCATION_EXCLUSION_MS

const val DEFAULT_LOCATION_EXCLUSION_MS = 300000: Long

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

DEFAULT_MIN_LOADABLE_RETRY_COUNT

const val DEFAULT_MIN_LOADABLE_RETRY_COUNT = 3: Int

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

DEFAULT_MIN_LOADABLE_RETRY_COUNT_PROGRESSIVE_LIVE

const val DEFAULT_MIN_LOADABLE_RETRY_COUNT_PROGRESSIVE_LIVE = 6: Int

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

DEFAULT_TRACK_BLACKLIST_MS

const val DEFAULT_TRACK_BLACKLIST_MS = 60000: Long

DEFAULT_TRACK_EXCLUSION_MS

const val DEFAULT_TRACK_EXCLUSION_MS = 60000: Long

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

Public constructors

DefaultLoadErrorHandlingPolicy

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

DefaultLoadErrorHandlingPolicy(minimumLoadableRetryCount: Int)

Creates an instance with the given value for getMinimumLoadableRetryCount.

Parameters
minimumLoadableRetryCount: Int

See getMinimumLoadableRetryCount.

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.

getMinimumLoadableRetryCount

fun getMinimumLoadableRetryCount(dataType: Int): Int

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

getRetryDelayMsFor

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

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 functions

isEligibleForFallback

protected fun isEligibleForFallback(exception: IOException!): Boolean

Returns whether an error should trigger a fallback if possible.