Class Loader
- java.lang.Object
-
- com.google.android.exoplayer2.upstream.Loader
-
- All Implemented Interfaces:
LoaderErrorThrower
@Deprecated public final class Loader extends Object implements LoaderErrorThrower
Deprecated.com.google.android.exoplayer2 is deprecated. Please migrate to androidx.media3 (which contains the same ExoPlayer code). See the migration guide for more details, including a script to help with the migration.Manages the background loading ofLoader.Loadables.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceLoader.Callback<T extends Loader.Loadable>Deprecated.A callback to be notified ofLoaderevents.static interfaceLoader.LoadableDeprecated.An object that can be loaded using aLoader.static classLoader.LoadErrorActionDeprecated.Action that can be taken in response toLoader.Callback.onLoadError(Loadable, long, long, IOException, int).static interfaceLoader.ReleaseCallbackDeprecated.A callback to be notified when aLoaderhas finished being released.static classLoader.UnexpectedLoaderExceptionDeprecated.Thrown when an unexpected exception or error is encountered during loading.-
Nested classes/interfaces inherited from interface com.google.android.exoplayer2.upstream.LoaderErrorThrower
LoaderErrorThrower.Placeholder
-
-
Field Summary
Fields Modifier and Type Field Description static Loader.LoadErrorActionDONT_RETRYDeprecated.Discards the failedLoader.Loadableand ignores any errors that have occurred.static Loader.LoadErrorActionDONT_RETRY_FATALDeprecated.Discards the failedLoader.Loadable.static Loader.LoadErrorActionRETRYDeprecated.Retries the load using the default delay.static Loader.LoadErrorActionRETRY_RESET_ERROR_COUNTDeprecated.Retries the load using the default delay and resets the error count.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidcancelLoading()Deprecated.Cancels the current load.voidclearFatalError()Deprecated.Clears any stored fatal error.static Loader.LoadErrorActioncreateRetryAction(boolean resetErrorCount, long retryDelayMillis)Deprecated.Creates aLoader.LoadErrorActionfor retrying with the given parameters.booleanhasFatalError()Deprecated.Whether the last call tostartLoading(T, com.google.android.exoplayer2.upstream.Loader.Callback<T>, int)resulted in a fatal error.booleanisLoading()Deprecated.Returns whether the loader is currently loading.voidmaybeThrowError()Deprecated.Throws a fatal error, or a non-fatal error if loading is currently backed off and the currentLoader.Loadablehas incurred a number of errors greater than theLoaders default minimum number of retries.voidmaybeThrowError(int minRetryCount)Deprecated.Throws a fatal error, or a non-fatal error if loading is currently backed off and the currentLoader.Loadablehas incurred a number of errors greater than the specified minimum number of retries.voidrelease()Deprecated.Releases the loader.voidrelease(Loader.ReleaseCallback callback)Deprecated.Releases the loader.<T extends Loader.Loadable>
longstartLoading(T loadable, Loader.Callback<T> callback, int defaultMinRetryCount)Deprecated.Starts loading aLoader.Loadable.
-
-
-
Field Detail
-
RETRY
public static final Loader.LoadErrorAction RETRY
Deprecated.Retries the load using the default delay.
-
RETRY_RESET_ERROR_COUNT
public static final Loader.LoadErrorAction RETRY_RESET_ERROR_COUNT
Deprecated.Retries the load using the default delay and resets the error count.
-
DONT_RETRY
public static final Loader.LoadErrorAction DONT_RETRY
Deprecated.Discards the failedLoader.Loadableand ignores any errors that have occurred.
-
DONT_RETRY_FATAL
public static final Loader.LoadErrorAction DONT_RETRY_FATAL
Deprecated.Discards the failedLoader.Loadable. The next call tomaybeThrowError()will throw the last load error.
-
-
Constructor Detail
-
Loader
public Loader(String threadNameSuffix)
Deprecated.- Parameters:
threadNameSuffix- A name suffix for the loader's thread. This should be the name of the component using the loader.
-
-
Method Detail
-
createRetryAction
public static Loader.LoadErrorAction createRetryAction(boolean resetErrorCount, long retryDelayMillis)
Deprecated.Creates aLoader.LoadErrorActionfor retrying with the given parameters.- Parameters:
resetErrorCount- Whether the previous error count should be set to zero.retryDelayMillis- The number of milliseconds to wait before retrying.- Returns:
- A
Loader.LoadErrorActionfor retrying with the given parameters.
-
hasFatalError
public boolean hasFatalError()
Deprecated.Whether the last call tostartLoading(T, com.google.android.exoplayer2.upstream.Loader.Callback<T>, int)resulted in a fatal error. CallingmaybeThrowError()will throw the fatal error.
-
clearFatalError
public void clearFatalError()
Deprecated.Clears any stored fatal error.
-
startLoading
public <T extends Loader.Loadable> long startLoading(T loadable, Loader.Callback<T> callback, int defaultMinRetryCount)
Deprecated.Starts loading aLoader.Loadable.The calling thread must be a
Looperthread, which is the thread on which theLoader.Callbackwill be called.- Type Parameters:
T- The type of the loadable.- Parameters:
loadable- TheLoader.Loadableto load.callback- A callback to be called when the load ends.defaultMinRetryCount- The minimum number of times the load must be retried beforemaybeThrowError()will propagate an error.- Returns:
SystemClock.elapsedRealtime()when the load started.- Throws:
IllegalStateException- If the calling thread does not have an associatedLooper.
-
isLoading
public boolean isLoading()
Deprecated.Returns whether the loader is currently loading.
-
cancelLoading
public void cancelLoading()
Deprecated.Cancels the current load.- Throws:
IllegalStateException- If the loader is not currently loading.
-
release
public void release()
Deprecated.Releases the loader. This method should be called when the loader is no longer required.
-
release
public void release(@Nullable Loader.ReleaseCallback callback)Deprecated.Releases the loader. This method should be called when the loader is no longer required.- Parameters:
callback- An optional callback to be called on the loading thread once the loader has been released.
-
maybeThrowError
public void maybeThrowError() throws IOExceptionDeprecated.Description copied from interface:LoaderErrorThrowerThrows a fatal error, or a non-fatal error if loading is currently backed off and the currentLoader.Loadablehas incurred a number of errors greater than theLoaders default minimum number of retries. Else does nothing.- Specified by:
maybeThrowErrorin interfaceLoaderErrorThrower- Throws:
IOException- The error.
-
maybeThrowError
public void maybeThrowError(int minRetryCount) throws IOExceptionDeprecated.Description copied from interface:LoaderErrorThrowerThrows a fatal error, or a non-fatal error if loading is currently backed off and the currentLoader.Loadablehas incurred a number of errors greater than the specified minimum number of retries. Else does nothing.- Specified by:
maybeThrowErrorin interfaceLoaderErrorThrower- Parameters:
minRetryCount- A minimum retry count that must be exceeded for a non-fatal error to be thrown. Should be non-negative.- Throws:
IOException- The error.
-
-