Loader.Callback


public interface Loader.Callback<T extends Loader.Loadable>

Known direct subclasses
ChunkSampleStream

A SampleStream that loads media in Chunks, obtained from a ChunkSource.

DefaultHlsPlaylistTracker

Default implementation for HlsPlaylistTracker.

SsMediaSource

A SmoothStreaming MediaSource.


A callback to be notified of Loader events.

Summary

Public methods

abstract void
onLoadCanceled(
    T loadable,
    long elapsedRealtimeMs,
    long loadDurationMs,
    boolean released
)

Called when a load has been canceled.

abstract void
onLoadCompleted(T loadable, long elapsedRealtimeMs, long loadDurationMs)

Called when a load has completed.

abstract Loader.LoadErrorAction
onLoadError(
    T loadable,
    long elapsedRealtimeMs,
    long loadDurationMs,
    IOException error,
    int errorCount
)

Called when a load encounters an error.

default void
onLoadStarted(
    T loadable,
    long elapsedRealtimeMs,
    long loadDurationMs,
    int retryCount
)

Called when a load has started for the first time or through a retry.

Public methods

onLoadCanceled

abstract void onLoadCanceled(
    T loadable,
    long elapsedRealtimeMs,
    long loadDurationMs,
    boolean released
)

Called when a load has been canceled.

Note: If the Loader has not been released then there is guaranteed to be a memory barrier between load exiting and this callback being called. If the has been released then this callback may be called before load exits.

Parameters
T loadable

The loadable whose load has been canceled.

long elapsedRealtimeMs

elapsedRealtime when the load was canceled.

long loadDurationMs

The duration in milliseconds of the load since startLoading was called up to the point at which it was canceled.

boolean released

True if the load was canceled because the Loader was released. False otherwise.

onLoadCompleted

abstract void onLoadCompleted(T loadable, long elapsedRealtimeMs, long loadDurationMs)

Called when a load has completed.

Note: There is guaranteed to be a memory barrier between load exiting and this callback being called.

Parameters
T loadable

The loadable whose load has completed.

long elapsedRealtimeMs

elapsedRealtime when the load ended.

long loadDurationMs

The duration in milliseconds of the load since startLoading was called.

onLoadError

abstract Loader.LoadErrorAction onLoadError(
    T loadable,
    long elapsedRealtimeMs,
    long loadDurationMs,
    IOException error,
    int errorCount
)

Called when a load encounters an error.

Note: There is guaranteed to be a memory barrier between load exiting and this callback being called.

Parameters
T loadable

The loadable whose load has encountered an error.

long elapsedRealtimeMs

elapsedRealtime when the error occurred.

long loadDurationMs

The duration in milliseconds of the load since startLoading was called up to the point at which the error occurred.

IOException error

The load error.

int errorCount

The number of errors this load has encountered, including this one.

Returns
Loader.LoadErrorAction

The desired error handling action. One of RETRY, RETRY_RESET_ERROR_COUNT, DONT_RETRY, DONT_RETRY_FATAL or a retry action created by createRetryAction.

onLoadStarted

default void onLoadStarted(
    T loadable,
    long elapsedRealtimeMs,
    long loadDurationMs,
    int retryCount
)

Called when a load has started for the first time or through a retry.

Parameters
T loadable

The loadable whose load has completed.

long elapsedRealtimeMs

elapsedRealtime when the load attempts to start.

long loadDurationMs

The duration in milliseconds of the load since startLoading was called.

int retryCount

The number of failed attempts since startLoading was called (this is zero for the first load attempt).