Loader.Callback


interface Loader.Callback<T : 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 functions

Unit
onLoadCanceled(
    loadable: T!,
    elapsedRealtimeMs: Long,
    loadDurationMs: Long,
    released: Boolean
)

Called when a load has been canceled.

Unit
onLoadCompleted(loadable: T!, elapsedRealtimeMs: Long, loadDurationMs: Long)

Called when a load has completed.

Loader.LoadErrorAction!
onLoadError(
    loadable: T!,
    elapsedRealtimeMs: Long,
    loadDurationMs: Long,
    error: IOException!,
    errorCount: Int
)

Called when a load encounters an error.

Unit
onLoadStarted(
    loadable: T!,
    elapsedRealtimeMs: Long,
    loadDurationMs: Long,
    retryCount: Int
)

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

Public functions

onLoadCanceled

fun onLoadCanceled(
    loadable: T!,
    elapsedRealtimeMs: Long,
    loadDurationMs: Long,
    released: Boolean
): Unit

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
loadable: T!

The loadable whose load has been canceled.

elapsedRealtimeMs: Long

elapsedRealtime when the load was canceled.

loadDurationMs: Long

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

released: Boolean

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

onLoadCompleted

fun onLoadCompleted(loadable: T!, elapsedRealtimeMs: Long, loadDurationMs: Long): Unit

Called when a load has completed.

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

Parameters
loadable: T!

The loadable whose load has completed.

elapsedRealtimeMs: Long

elapsedRealtime when the load ended.

loadDurationMs: Long

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

onLoadError

fun onLoadError(
    loadable: T!,
    elapsedRealtimeMs: Long,
    loadDurationMs: Long,
    error: IOException!,
    errorCount: Int
): Loader.LoadErrorAction!

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
loadable: T!

The loadable whose load has encountered an error.

elapsedRealtimeMs: Long

elapsedRealtime when the error occurred.

loadDurationMs: Long

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

error: IOException!

The load error.

errorCount: Int

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

fun onLoadStarted(
    loadable: T!,
    elapsedRealtimeMs: Long,
    loadDurationMs: Long,
    retryCount: Int
): Unit

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

Parameters
loadable: T!

The loadable whose load has completed.

elapsedRealtimeMs: Long

elapsedRealtime when the load attempts to start.

loadDurationMs: Long

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

retryCount: Int

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