@UnstableApi
abstract class Chunk : Loader.Loadable

Known direct subclasses
DataChunk

A base class for Chunk implementations where the data should be loaded into a byte[] before being consumed.

InitializationChunk

A Chunk that uses an Extractor to decode initialization data for single track.

MediaChunk

An abstract base class for Chunks that contain media samples.

Known indirect subclasses
BaseMediaChunk

A base implementation of MediaChunk that outputs to a BaseMediaChunkOutput.

ContainerMediaChunk

A BaseMediaChunk that uses an Extractor to decode sample data.

FakeMediaChunk

Fake MediaChunk.

SingleSampleMediaChunk

This class is deprecated.

The only use for this class is subtitle playback, but it is only compatible with legacy subtitle decoding, which is not supported by default.


An abstract base class for Loadable implementations that load chunks of data required for the playback of streams.

Summary

Public constructors

Chunk(
    dataSource: DataSource!,
    dataSpec: DataSpec!,
    @C.DataType type: Int,
    trackFormat: Format!,
    @C.SelectionReason trackSelectionReason: Int,
    trackSelectionData: Any?,
    startTimeUs: Long,
    endTimeUs: Long
)

Public functions

Long

Returns the number of bytes that have been loaded.

Long

Returns the duration of the chunk in microseconds.

(Mutable)Map<String!, (Mutable)List<String!>!>!

Returns the response headers associated with the last open call.

Uri!

Returns the Uri associated with the last open call.

Public properties

DataSpec!

The DataSpec that defines the data to be loaded.

Long

The end time of the media contained by the chunk, or TIME_UNSET if the data being loaded does not contain media samples.

Long

Identifies the load task for this loadable.

Long

The start time of the media contained by the chunk, or TIME_UNSET if the data being loaded does not contain media samples.

Format!

The format of the track to which this chunk belongs.

Any?

Optional data associated with the selection of the track to which this chunk belongs.

Int

One of the selection reasons if the chunk belongs to a track.

Int

The data type of the chunk.

Protected properties

StatsDataSource!

Inherited functions

From androidx.media3.exoplayer.upstream.Loader.Loadable
abstract Unit

Cancels the load.

abstract Unit

Performs the load, returning on completion or cancellation.

Public constructors

Chunk

Chunk(
    dataSource: DataSource!,
    dataSpec: DataSpec!,
    @C.DataType type: Int,
    trackFormat: Format!,
    @C.SelectionReason trackSelectionReason: Int,
    trackSelectionData: Any?,
    startTimeUs: Long,
    endTimeUs: Long
)
Parameters
dataSource: DataSource!

The source from which the data should be loaded.

dataSpec: DataSpec!

Defines the data to be loaded.

@C.DataType type: Int

See type.

trackFormat: Format!

See trackFormat.

@C.SelectionReason trackSelectionReason: Int

See trackSelectionReason.

trackSelectionData: Any?

See trackSelectionData.

startTimeUs: Long

See startTimeUs.

endTimeUs: Long

See endTimeUs.

Public functions

bytesLoaded

fun bytesLoaded(): Long

Returns the number of bytes that have been loaded. Must only be called after the load completed, failed, or was canceled.

getDurationUs

fun getDurationUs(): Long

Returns the duration of the chunk in microseconds.

getResponseHeaders

fun getResponseHeaders(): (Mutable)Map<String!, (Mutable)List<String!>!>!

Returns the response headers associated with the last open call. Must only be called after the load completed, failed, or was canceled.

getUri

fun getUri(): Uri!

Returns the Uri associated with the last open call. If redirection occurred, this is the redirected uri. Must only be called after the load completed, failed, or was canceled.

See also
getUri

Public properties

dataSpec

val dataSpecDataSpec!

The DataSpec that defines the data to be loaded.

endTimeUs

val endTimeUsLong

The end time of the media contained by the chunk, or TIME_UNSET if the data being loaded does not contain media samples.

loadTaskId

val loadTaskIdLong

Identifies the load task for this loadable.

startTimeUs

val startTimeUsLong

The start time of the media contained by the chunk, or TIME_UNSET if the data being loaded does not contain media samples.

trackFormat

val trackFormatFormat!

The format of the track to which this chunk belongs.

trackSelectionData

val trackSelectionDataAny?

Optional data associated with the selection of the track to which this chunk belongs. Null if the chunk does not belong to a track, or if there is no associated track selection data.

trackSelectionReason

@C.SelectionReason
val trackSelectionReasonInt

One of the selection reasons if the chunk belongs to a track. SELECTION_REASON_UNKNOWN if the chunk does not belong to a track, or if the selection reason is unknown.

type

@C.DataType
val typeInt

The data type of the chunk. For reporting only.

Protected properties

dataSource

protected val dataSourceStatsDataSource!