# BaseMediaChunk

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/BaseMediaChunk.java+class:androidx.media3.exoplayer.source.chunk.BaseMediaChunk)

*** ** * ** ***


```
@UnstableApi
public abstract class BaseMediaChunk extends MediaChunk
```

<br />

|---|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) ||||
| ↳ | [androidx.media3.exoplayer.source.chunk.Chunk](https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/Chunk) |||
|   | ↳ | [androidx.media3.exoplayer.source.chunk.MediaChunk](https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/MediaChunk) ||
|   |   | ↳ | [androidx.media3.exoplayer.source.chunk.BaseMediaChunk](https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/BaseMediaChunk) |

Known direct subclasses [ContainerMediaChunk](https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/ContainerMediaChunk), [SingleSampleMediaChunk](https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/SingleSampleMediaChunk)

|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/ContainerMediaChunk` | A `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/BaseMediaChunk` that uses an `https://developer.android.com/reference/androidx/media3/extractor/Extractor` to decode sample data. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/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. <br /> |

*** ** * ** ***

A base implementation of `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/MediaChunk` that outputs to a `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/BaseMediaChunkOutput`.

## Summary

| ### Public fields |
|---|---|
| `final long` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/BaseMediaChunk#clippedEndTimeUs()` The time from which output will end, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if output will end at the end of the chunk. |
| `final long` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/BaseMediaChunk#clippedStartTimeUs()` The time from which output will begin, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if output will begin from the start of the chunk. |

| ### Protected fields |
|---|---|
| `@https://checkerframework.org/api/org/checkerframework/checker/nullness/qual/MonotonicNonNull.html https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/BaseMediaChunkOutput` | `@https://checkerframework.org/api/org/checkerframework/checker/nullness/qual/MonotonicNonNull.html https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/BaseMediaChunk#output()` |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/BaseMediaChunk#BaseMediaChunk(androidx.media3.datasource.DataSource,androidx.media3.datasource.DataSpec,androidx.media3.common.Format,int,java.lang.Object,long,long,long,long,long)( https://developer.android.com/reference/androidx/media3/datasource/DataSource dataSource, https://developer.android.com/reference/androidx/media3/datasource/DataSpec dataSpec, https://developer.android.com/reference/androidx/media3/common/Format trackFormat, @https://developer.android.com/reference/androidx/media3/common/C.SelectionReason int trackSelectionReason, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html trackSelectionData, long startTimeUs, long endTimeUs, long clippedStartTimeUs, long clippedEndTimeUs, long chunkIndex )` |

| ### Public methods |
|---|---|
| `final int` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/BaseMediaChunk#getFirstSampleIndex(int)(int trackIndex)` Returns the index of the first sample in the specified track of the output that will originate from this chunk. |
| `void` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/BaseMediaChunk#init(androidx.media3.exoplayer.source.chunk.BaseMediaChunkOutput)(https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/BaseMediaChunkOutput output)` Initializes the chunk for loading, setting the `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/BaseMediaChunkOutput` that will receive samples as they are loaded. |

| ### Protected methods |
|---|---|
| `final https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/BaseMediaChunkOutput` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/BaseMediaChunk#getOutput()()` Returns the output most recently passed to `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/BaseMediaChunk#init(androidx.media3.exoplayer.source.chunk.BaseMediaChunkOutput)`. |

| ### Inherited fields |
|---|
| From [androidx.media3.exoplayer.source.chunk.Chunk](https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/Chunk) |---|---| | `final https://developer.android.com/reference/androidx/media3/datasource/StatsDataSource` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/Chunk#dataSource()` | | `final https://developer.android.com/reference/androidx/media3/datasource/DataSpec` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/Chunk#dataSpec()` The `https://developer.android.com/reference/androidx/media3/datasource/DataSpec` that defines the data to be loaded. | | `final long` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/Chunk#endTimeUs()` The end time of the media contained by the chunk, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if the data being loaded does not contain media samples. | | `final long` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/Chunk#loadTaskId()` Identifies the load task for this loadable. | | `final long` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/Chunk#startTimeUs()` The start time of the media contained by the chunk, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if the data being loaded does not contain media samples. | | `final @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/Chunk#steeredPathwayId()` The ID of the steered pathway from which data is being loaded, or `null` if not applicable. | | `final https://developer.android.com/reference/androidx/media3/common/Format` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/Chunk#trackFormat()` The format of the track to which this chunk belongs. | | `final @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/Chunk#trackSelectionData()` Optional data associated with the selection of the track to which this chunk belongs. | | `final int` | `@https://developer.android.com/reference/androidx/media3/common/C.SelectionReason https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/Chunk#trackSelectionReason()` One of the `https://developer.android.com/reference/androidx/media3/common/C.SelectionReason` if the chunk belongs to a track. | | `final int` | `@https://developer.android.com/reference/androidx/media3/common/C.DataType https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/Chunk#type()` The `https://developer.android.com/reference/androidx/media3/common/C.DataType` of the chunk. | |
| From [androidx.media3.exoplayer.source.chunk.MediaChunk](https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/MediaChunk) |---|---| | `final long` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/MediaChunk#chunkIndex()` The chunk index, or `https://developer.android.com/reference/androidx/media3/common/C#INDEX_UNSET()` if it is not known. | |

| ### Inherited methods |
|---|
| From [androidx.media3.exoplayer.source.chunk.Chunk](https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/Chunk) |---|---| | `final long` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/Chunk#bytesLoaded()()` Returns the number of bytes that have been loaded. | | `final long` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/Chunk#getDurationUs()()` Returns the duration of the chunk in microseconds. | | `final https://developer.android.com/reference/java/util/Map.html<https://developer.android.com/reference/java/lang/String.html, https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/java/lang/String.html>>` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/Chunk#getResponseHeaders()()` Returns the response headers associated with the last `https://developer.android.com/reference/androidx/media3/datasource/DataSource#open(androidx.media3.datasource.DataSpec)` call. | | `final https://developer.android.com/reference/android/net/Uri.html` | `https://developer.android.com/reference/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/androidx/media3/datasource/DataSource#open(androidx.media3.datasource.DataSpec)` call. | |
| From [androidx.media3.exoplayer.upstream.Loader.Loadable](https://developer.android.com/reference/androidx/media3/exoplayer/upstream/Loader.Loadable) |---|---| | `abstract void` | `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/Loader.Loadable#cancelLoad()()` Cancels the load. | | `abstract void` | `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/Loader.Loadable#load()()` Performs the load, returning on completion or cancellation. | |
| From [androidx.media3.exoplayer.source.chunk.MediaChunk](https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/MediaChunk) |---|---| | `long` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/MediaChunk#getNextChunkIndex()()` Returns the next chunk index or `https://developer.android.com/reference/androidx/media3/common/C#INDEX_UNSET()` if it is not known. | | `abstract boolean` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/MediaChunk#isLoadCompleted()()` Returns whether the chunk has been fully loaded. | |

## Public fields

### clippedEndTimeUs

```
public final long clippedEndTimeUs
```

The time from which output will end, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if output will end at the end of the chunk.

### clippedStartTimeUs

```
public final long clippedStartTimeUs
```

The time from which output will begin, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if output will begin from the start of the chunk.

## Protected fields

### output

```
@MonotonicNonNull
protected @MonotonicNonNull BaseMediaChunkOutput output
```

## Public constructors

### BaseMediaChunk

```
public BaseMediaChunk(
    DataSource dataSource,
    DataSpec dataSpec,
    Format trackFormat,
    @C.SelectionReason int trackSelectionReason,
    @Nullable Object trackSelectionData,
    long startTimeUs,
    long endTimeUs,
    long clippedStartTimeUs,
    long clippedEndTimeUs,
    long chunkIndex
)
```

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/datasource/DataSource dataSource` | The source from which the data should be loaded. |
| `https://developer.android.com/reference/androidx/media3/datasource/DataSpec dataSpec` | Defines the data to be loaded. |
| `https://developer.android.com/reference/androidx/media3/common/Format trackFormat` | See `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/Chunk#trackFormat()`. |
| `@https://developer.android.com/reference/androidx/media3/common/C.SelectionReason int trackSelectionReason` | See `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/Chunk#trackSelectionReason()`. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html trackSelectionData` | See `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/Chunk#trackSelectionData()`. |
| `long startTimeUs` | The start time of the media contained by the chunk, in microseconds. |
| `long endTimeUs` | The end time of the media contained by the chunk, in microseconds. |
| `long clippedStartTimeUs` | The time in the chunk from which output will begin, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` to output from the start of the chunk. |
| `long clippedEndTimeUs` | The time in the chunk from which output will end, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` to output to the end of the chunk. |
| `long chunkIndex` | The index of the chunk, or `https://developer.android.com/reference/androidx/media3/common/C#INDEX_UNSET()` if it is not known. |

## Public methods

### getFirstSampleIndex

```
public final int getFirstSampleIndex(int trackIndex)
```

Returns the index of the first sample in the specified track of the output that will originate from this chunk.

### init

```
public void init(BaseMediaChunkOutput output)
```

Initializes the chunk for loading, setting the `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/BaseMediaChunkOutput` that will receive samples as they are loaded.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/BaseMediaChunkOutput output` | The output that will receive the loaded media samples. |

## Protected methods

### getOutput

```
protected final BaseMediaChunkOutput getOutput()
```

Returns the output most recently passed to `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/BaseMediaChunk#init(androidx.media3.exoplayer.source.chunk.BaseMediaChunkOutput)`.