# ContainerMediaChunk

Artifact: [androidx.media3:media3-exoplayer](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/exoplayer/source/chunk/ContainerMediaChunk.java+class:androidx.media3.exoplayer.source.chunk.ContainerMediaChunk)

*** ** * ** ***


```
@UnstableApi
class ContainerMediaChunk : BaseMediaChunk
```

<br />

|---|---|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) |||||
| ↳ | [androidx.media3.exoplayer.source.chunk.Chunk](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/Chunk) ||||
|   | ↳ | [androidx.media3.exoplayer.source.chunk.MediaChunk](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/MediaChunk) |||
|   |   | ↳ | [androidx.media3.exoplayer.source.chunk.BaseMediaChunk](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/BaseMediaChunk) ||
|   |   |   | ↳ | [androidx.media3.exoplayer.source.chunk.ContainerMediaChunk](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/ContainerMediaChunk) |

*** ** * ** ***

A `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/BaseMediaChunk` that uses an `https://developer.android.com/reference/kotlin/androidx/media3/extractor/Extractor` to decode sample data.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/ContainerMediaChunk#ContainerMediaChunk(androidx.media3.datasource.DataSource,androidx.media3.datasource.DataSpec,androidx.media3.common.Format,int,java.lang.Object,long,long,long,long,long,int,long,androidx.media3.exoplayer.source.chunk.ChunkExtractor)( dataSource: https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource!, dataSpec: https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec!, trackFormat: https://developer.android.com/reference/kotlin/androidx/media3/common/Format!, @https://developer.android.com/reference/kotlin/androidx/media3/common/C.SelectionReason trackSelectionReason: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, trackSelectionData: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?, startTimeUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, endTimeUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, clippedStartTimeUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, clippedEndTimeUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, chunkIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, chunkCount: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, sampleOffsetUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, chunkExtractor: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/ChunkExtractor! )` |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/ContainerMediaChunk#cancelLoad()()` Cancels the load. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/ContainerMediaChunk#getNextChunkIndex()()` Returns the next chunk index or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#INDEX_UNSET()` if it is not known. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/ContainerMediaChunk#isLoadCanceled()()` Returns whether the current chunk's load has been canceled from `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/ContainerMediaChunk#cancelLoad()`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/ContainerMediaChunk#isLoadCompleted()()` Returns whether the chunk has been fully loaded. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/ContainerMediaChunk#load()()` Performs the load, returning on completion or cancellation. |

| ### Protected functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/ChunkExtractor.TrackOutputProvider!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/ContainerMediaChunk#getTrackOutputProvider(androidx.media3.exoplayer.source.chunk.BaseMediaChunkOutput)(baseMediaChunkOutput: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/BaseMediaChunkOutput!)` Returns the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/ChunkExtractor.TrackOutputProvider` to be used by the wrapped extractor. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://checkerframework.org/api/com/google/errorprone/annotations/ForOverride.html https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/ContainerMediaChunk#onLoadEnded()()` Method that is called to signal that a `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/ContainerMediaChunk#load()` has concluded. |

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/ContainerMediaChunk#nextLoadPosition()` |

### Inherited functions

From [androidx.media3.exoplayer.source.chunk.BaseMediaChunk](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/BaseMediaChunk) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/BaseMediaChunk#getFirstSampleIndex(int)(trackIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

Returns the index of the first sample in the specified track of the output that will originate from this chunk.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/BaseMediaChunk#init(androidx.media3.exoplayer.source.chunk.BaseMediaChunkOutput)(output: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/BaseMediaChunkOutput!)`

Initializes the chunk for loading, setting the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/BaseMediaChunkOutput` that will receive samples as they are loaded.
From [androidx.media3.exoplayer.source.chunk.Chunk](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/Chunk) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/Chunk#bytesLoaded()()`

Returns the number of bytes that have been loaded.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/Chunk#getDurationUs()()`

Returns the duration of the chunk in microseconds.
`(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>!>!` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/Chunk#getResponseHeaders()()`

Returns the response headers associated with the last `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource#open(androidx.media3.datasource.DataSpec)` call.
`https://developer.android.com/reference/android/net/Uri.html!` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/Chunk#getUri()()`

Returns the `https://developer.android.com/reference/android/net/Uri.html` associated with the last `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource#open(androidx.media3.datasource.DataSpec)` call.

### Inherited properties

From [androidx.media3.exoplayer.source.chunk.BaseMediaChunk](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/BaseMediaChunk) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/BaseMediaChunk#clippedEndTimeUs()`

The time from which output will end, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET()` if output will end at the end of the chunk.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/BaseMediaChunk#clippedStartTimeUs()`

The time from which output will begin, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET()` if output will begin from the start of the chunk.
`@https://checkerframework.org/api/org/checkerframework/checker/nullness/qual/MonotonicNonNull.html https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/BaseMediaChunkOutput!` `@https://checkerframework.org/api/org/checkerframework/checker/nullness/qual/MonotonicNonNull.html
https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/BaseMediaChunk#output()` From [androidx.media3.exoplayer.source.chunk.Chunk](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/Chunk) `https://developer.android.com/reference/kotlin/androidx/media3/datasource/StatsDataSource!` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/Chunk#dataSource()` `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec!` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/Chunk#dataSpec()`

The `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec` that defines the data to be loaded.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/Chunk#endTimeUs()`

The end time of the media contained by the chunk, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET()` if the data being loaded does not contain media samples.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/Chunk#loadTaskId()`

Identifies the load task for this loadable.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/Chunk#startTimeUs()`

The start time of the media contained by the chunk, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET()` if the data being loaded does not contain media samples.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/Chunk#steeredPathwayId()`

The ID of the steered pathway from which data is being loaded, or `null` if not applicable.
`https://developer.android.com/reference/kotlin/androidx/media3/common/Format!` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/Chunk#trackFormat()`

The format of the track to which this chunk belongs.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/Chunk#trackSelectionData()`

Optional data associated with the selection of the track to which this chunk belongs.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `@https://developer.android.com/reference/kotlin/androidx/media3/common/C.SelectionReason
https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/Chunk#trackSelectionReason()`

One of the `https://developer.android.com/reference/kotlin/androidx/media3/common/C.SelectionReason` if the chunk belongs to a track.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `@https://developer.android.com/reference/kotlin/androidx/media3/common/C.DataType
https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/Chunk#type()`

The `https://developer.android.com/reference/kotlin/androidx/media3/common/C.DataType` of the chunk.
From [androidx.media3.exoplayer.source.chunk.MediaChunk](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/MediaChunk) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/MediaChunk#chunkIndex()`

The chunk index, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#INDEX_UNSET()` if it is not known.

## Public constructors

### ContainerMediaChunk

```
ContainerMediaChunk(
    dataSource: DataSource!,
    dataSpec: DataSpec!,
    trackFormat: Format!,
    @C.SelectionReason trackSelectionReason: Int,
    trackSelectionData: Any?,
    startTimeUs: Long,
    endTimeUs: Long,
    clippedStartTimeUs: Long,
    clippedEndTimeUs: Long,
    chunkIndex: Long,
    chunkCount: Int,
    sampleOffsetUs: Long,
    chunkExtractor: ChunkExtractor!
)
```

| Parameters |
|---|---|
| `dataSource: https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource!` | The source from which the data should be loaded. |
| `dataSpec: https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec!` | Defines the data to be loaded. |
| `trackFormat: https://developer.android.com/reference/kotlin/androidx/media3/common/Format!` | See `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/Chunk#trackFormat()`. |
| `@https://developer.android.com/reference/kotlin/androidx/media3/common/C.SelectionReason trackSelectionReason: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | See `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/Chunk#trackSelectionReason()`. |
| `trackSelectionData: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?` | See `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/Chunk#trackSelectionData()`. |
| `startTimeUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The start time of the media contained by the chunk, in microseconds. |
| `endTimeUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The end time of the media contained by the chunk, in microseconds. |
| `clippedStartTimeUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The time in the chunk from which output will begin, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET()` to output from the start of the chunk. |
| `clippedEndTimeUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The time in the chunk from which output will end, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET()` to output to the end of the chunk. |
| `chunkIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The index of the chunk, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#INDEX_UNSET()` if it is not known. |
| `chunkCount: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The number of chunks in the underlying media that are spanned by this instance. Normally equal to one, but may be larger if multiple chunks as defined by the underlying media are being merged into a single load. |
| `sampleOffsetUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | An offset to add to the sample timestamps parsed by the extractor. |
| `chunkExtractor: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/ChunkExtractor!` | A wrapped extractor to use for parsing the data. |

## Public functions

### cancelLoad

```
fun cancelLoad(): Unit
```

Cancels the load.

Loadable implementations should ensure that a currently executing `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/Loader.Loadable#load()` call will exit reasonably quickly after this method is called. The `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/Loader.Loadable#load()` call may exit either by returning or by throwing an `https://developer.android.com/reference/java/io/IOException.html`.

If there is a currently executing `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/Loader.Loadable#load()` call, then the thread on which that call is being made will be interrupted immediately after the call to this method. Hence implementations do not need to (and should not attempt to) interrupt the loading thread themselves.

Although the loading thread will be interrupted, Loadable implementations should not use the interrupted status of the loading thread in `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/Loader.Loadable#load()` to determine whether the load has been canceled. This approach is not robust \[Internal ref: b/79223737\]. Instead, implementations should use their own flag to signal cancelation (for example, using `https://developer.android.com/reference/java/util/concurrent/atomic/AtomicBoolean.html`).

### getNextChunkIndex

```
fun getNextChunkIndex(): Long
```

Returns the next chunk index or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#INDEX_UNSET()` if it is not known.

### isLoadCanceled

```
fun isLoadCanceled(): Boolean
```

Returns whether the current chunk's load has been canceled from `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/ContainerMediaChunk#cancelLoad()`.

### isLoadCompleted

```
fun isLoadCompleted(): Boolean
```

Returns whether the chunk has been fully loaded.

### load

```
fun load(): Unit
```

Performs the load, returning on completion or cancellation.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | If the input could not be loaded. |

## Protected functions

### getTrackOutputProvider

```
protected fun getTrackOutputProvider(baseMediaChunkOutput: BaseMediaChunkOutput!): ChunkExtractor.TrackOutputProvider!
```

Returns the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/ChunkExtractor.TrackOutputProvider` to be used by the wrapped extractor.

| Parameters |
|---|---|
| `baseMediaChunkOutput: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/BaseMediaChunkOutput!` | The `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/BaseMediaChunkOutput` most recently passed to `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/BaseMediaChunk#init(androidx.media3.exoplayer.source.chunk.BaseMediaChunkOutput)`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/ChunkExtractor.TrackOutputProvider!` | A `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/ChunkExtractor.TrackOutputProvider` to be used by the wrapped extractor. |

### onLoadEnded

```
@ForOverride
protected fun onLoadEnded(): Unit
```

Method that is called to signal that a `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/ContainerMediaChunk#load()` has concluded. This is called in both successful and error scenarios before the `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource` is closed.

## Public properties

### nextLoadPosition

```
val nextLoadPosition: Long
```